') !== '7';
});
// @@replace logic
fixRegexpWellKnownSymbolLogic('replace', function (_, nativeReplace, maybeCallNative) {
var UNSAFE_SUBSTITUTE = REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE ? '$' : '$0';
return [
// `String.prototype.replace` method
// https://tc39.es/ecma262/#sec-string.prototype.replace
function replace(searchValue, replaceValue) {
var O = requireObjectCoercible(this);
var replacer = searchValue == undefined ? undefined : getMethod(searchValue, REPLACE);
return replacer
? functionCall(replacer, searchValue, O, replaceValue)
: functionCall(nativeReplace, toString_1(O), searchValue, replaceValue);
},
// `RegExp.prototype[@@replace]` method
// https://tc39.es/ecma262/#sec-regexp.prototype-@@replace
function (string, replaceValue) {
var rx = anObject(this);
var S = toString_1(string);
if (
typeof replaceValue == 'string' &&
stringIndexOf(replaceValue, UNSAFE_SUBSTITUTE) === -1 &&
stringIndexOf(replaceValue, '$<') === -1
) {
var res = maybeCallNative(nativeReplace, rx, S, replaceValue);
if (res.done) return res.value;
}
var functionalReplace = isCallable(replaceValue);
if (!functionalReplace) replaceValue = toString_1(replaceValue);
var global = rx.global;
if (global) {
var fullUnicode = rx.unicode;
rx.lastIndex = 0;
}
var results = [];
while (true) {
var result = regexpExecAbstract(rx, S);
if (result === null) break;
push$1(results, result);
if (!global) break;
var matchStr = toString_1(result[0]);
if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode);
}
var accumulatedResult = '';
var nextSourcePosition = 0;
for (var i = 0; i < results.length; i++) {
result = results[i];
var matched = toString_1(result[0]);
var position = max(min$1(toIntegerOrInfinity(result.index), S.length), 0);
var captures = [];
// NOTE: This is equivalent to
// captures = result.slice(1).map(maybeToString)
// but for some reason `nativeSlice.call(result, 1, result.length)` (called in
// the slice polyfill when slicing native arrays) "doesn't work" in safari 9 and
// causes a crash (https://pastebin.com/N21QzeQA) when trying to debug it.
for (var j = 1; j < result.length; j++) push$1(captures, maybeToString(result[j]));
var namedCaptures = result.groups;
if (functionalReplace) {
var replacerArgs = concat([matched], captures, position, S);
if (namedCaptures !== undefined) push$1(replacerArgs, namedCaptures);
var replacement = toString_1(functionApply(replaceValue, undefined, replacerArgs));
} else {
replacement = getSubstitution(matched, S, position, captures, namedCaptures, replaceValue);
}
if (position >= nextSourcePosition) {
accumulatedResult += stringSlice$1(S, nextSourcePosition, position) + replacement;
nextSourcePosition = position + matched.length;
}
}
return accumulatedResult + stringSlice$1(S, nextSourcePosition);
}
];
}, !REPLACE_SUPPORTS_NAMED_GROUPS || !REPLACE_KEEPS_$0 || REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE);
// @@match logic
fixRegexpWellKnownSymbolLogic('match', function (MATCH, nativeMatch, maybeCallNative) {
return [
// `String.prototype.match` method
// https://tc39.es/ecma262/#sec-string.prototype.match
function match(regexp) {
var O = requireObjectCoercible(this);
var matcher = regexp == undefined ? undefined : getMethod(regexp, MATCH);
return matcher ? functionCall(matcher, regexp, O) : new RegExp(regexp)[MATCH](toString_1(O));
},
// `RegExp.prototype[@@match]` method
// https://tc39.es/ecma262/#sec-regexp.prototype-@@match
function (string) {
var rx = anObject(this);
var S = toString_1(string);
var res = maybeCallNative(nativeMatch, rx, S);
if (res.done) return res.value;
if (!rx.global) return regexpExecAbstract(rx, S);
var fullUnicode = rx.unicode;
rx.lastIndex = 0;
var A = [];
var n = 0;
var result;
while ((result = regexpExecAbstract(rx, S)) !== null) {
var matchStr = toString_1(result[0]);
A[n] = matchStr;
if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode);
n++;
}
return n === 0 ? null : A;
}
];
});
var UNSUPPORTED_Y = regexpStickyHelpers.UNSUPPORTED_Y;
var MAX_UINT32 = 0xFFFFFFFF;
var min = Math.min;
var $push = [].push;
var exec = functionUncurryThis(/./.exec);
var push = functionUncurryThis($push);
var stringSlice = functionUncurryThis(''.slice);
// Chrome 51 has a buggy "split" implementation when RegExp#exec !== nativeExec
// Weex JS has frozen built-in prototypes, so use try / catch wrapper
var SPLIT_WORKS_WITH_OVERWRITTEN_EXEC = !fails(function () {
// eslint-disable-next-line regexp/no-empty-group -- required for testing
var re = /(?:)/;
var originalExec = re.exec;
re.exec = function () { return originalExec.apply(this, arguments); };
var result = 'ab'.split(re);
return result.length !== 2 || result[0] !== 'a' || result[1] !== 'b';
});
// @@split logic
fixRegexpWellKnownSymbolLogic('split', function (SPLIT, nativeSplit, maybeCallNative) {
var internalSplit;
if (
'abbc'.split(/(b)*/)[1] == 'c' ||
// eslint-disable-next-line regexp/no-empty-group -- required for testing
'test'.split(/(?:)/, -1).length != 4 ||
'ab'.split(/(?:ab)*/).length != 2 ||
'.'.split(/(.?)(.?)/).length != 4 ||
// eslint-disable-next-line regexp/no-empty-capturing-group, regexp/no-empty-group -- required for testing
'.'.split(/()()/).length > 1 ||
''.split(/.?/).length
) {
// based on es5-shim implementation, need to rework it
internalSplit = function (separator, limit) {
var string = toString_1(requireObjectCoercible(this));
var lim = limit === undefined ? MAX_UINT32 : limit >>> 0;
if (lim === 0) return [];
if (separator === undefined) return [string];
// If `separator` is not a regex, use native split
if (!isRegexp(separator)) {
return functionCall(nativeSplit, string, separator, lim);
}
var output = [];
var flags = (separator.ignoreCase ? 'i' : '') +
(separator.multiline ? 'm' : '') +
(separator.unicode ? 'u' : '') +
(separator.sticky ? 'y' : '');
var lastLastIndex = 0;
// Make `global` and avoid `lastIndex` issues by working with a copy
var separatorCopy = new RegExp(separator.source, flags + 'g');
var match, lastIndex, lastLength;
while (match = functionCall(regexpExec, separatorCopy, string)) {
lastIndex = separatorCopy.lastIndex;
if (lastIndex > lastLastIndex) {
push(output, stringSlice(string, lastLastIndex, match.index));
if (match.length > 1 && match.index < string.length) functionApply($push, output, arraySliceSimple(match, 1));
lastLength = match[0].length;
lastLastIndex = lastIndex;
if (output.length >= lim) break;
}
if (separatorCopy.lastIndex === match.index) separatorCopy.lastIndex++; // Avoid an infinite loop
}
if (lastLastIndex === string.length) {
if (lastLength || !exec(separatorCopy, '')) push(output, '');
} else push(output, stringSlice(string, lastLastIndex));
return output.length > lim ? arraySliceSimple(output, 0, lim) : output;
};
// Chakra, V8
} else if ('0'.split(undefined, 0).length) {
internalSplit = function (separator, limit) {
return separator === undefined && limit === 0 ? [] : functionCall(nativeSplit, this, separator, limit);
};
} else internalSplit = nativeSplit;
return [
// `String.prototype.split` method
// https://tc39.es/ecma262/#sec-string.prototype.split
function split(separator, limit) {
var O = requireObjectCoercible(this);
var splitter = separator == undefined ? undefined : getMethod(separator, SPLIT);
return splitter
? functionCall(splitter, separator, O, limit)
: functionCall(internalSplit, toString_1(O), separator, limit);
},
// `RegExp.prototype[@@split]` method
// https://tc39.es/ecma262/#sec-regexp.prototype-@@split
//
// NOTE: This cannot be properly polyfilled in engines that don't support
// the 'y' flag.
function (string, limit) {
var rx = anObject(this);
var S = toString_1(string);
var res = maybeCallNative(internalSplit, rx, S, limit, internalSplit !== nativeSplit);
if (res.done) return res.value;
var C = speciesConstructor(rx, RegExp);
var unicodeMatching = rx.unicode;
var flags = (rx.ignoreCase ? 'i' : '') +
(rx.multiline ? 'm' : '') +
(rx.unicode ? 'u' : '') +
(UNSUPPORTED_Y ? 'g' : 'y');
// ^(? + rx + ) is needed, in combination with some S slicing, to
// simulate the 'y' flag.
var splitter = new C(UNSUPPORTED_Y ? '^(?:' + rx.source + ')' : rx, flags);
var lim = limit === undefined ? MAX_UINT32 : limit >>> 0;
if (lim === 0) return [];
if (S.length === 0) return regexpExecAbstract(splitter, S) === null ? [S] : [];
var p = 0;
var q = 0;
var A = [];
while (q < S.length) {
splitter.lastIndex = UNSUPPORTED_Y ? 0 : q;
var z = regexpExecAbstract(splitter, UNSUPPORTED_Y ? stringSlice(S, q) : S);
var e;
if (
z === null ||
(e = min(toLength(splitter.lastIndex + (UNSUPPORTED_Y ? q : 0)), S.length)) === p
) {
q = advanceStringIndex(S, q, unicodeMatching);
} else {
push(A, stringSlice(S, p, q));
if (A.length === lim) return A;
for (var i = 1; i <= z.length - 1; i++) {
push(A, z[i]);
if (A.length === lim) return A;
}
q = p = e;
}
}
push(A, stringSlice(S, p));
return A;
}
];
}, !SPLIT_WORKS_WITH_OVERWRITTEN_EXEC, UNSUPPORTED_Y);
var un$Join = functionUncurryThis([].join);
var ES3_STRINGS = indexedObject != Object;
var STRICT_METHOD = arrayMethodIsStrict('join', ',');
// `Array.prototype.join` method
// https://tc39.es/ecma262/#sec-array.prototype.join
_export({ target: 'Array', proto: true, forced: ES3_STRINGS || !STRICT_METHOD }, {
join: function join(separator) {
return un$Join(toIndexedObject(this), separator === undefined ? ',' : separator);
}
});
/* eslint-disable no-use-before-define */
var Utils$1 = $__default["default"].fn.bootstrapTable.utils;
var searchControls = 'select, input:not([type="checkbox"]):not([type="radio"])';
function getInputClass(that) {
var isSelect = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
var formControlClass = isSelect ? that.constants.classes.select : that.constants.classes.input;
return that.options.iconSize ? Utils$1.sprintf('%s-%s', formControlClass, that.options.iconSize) : formControlClass;
}
function getOptionsFromSelectControl(selectControl) {
return selectControl[0].options;
}
function getControlContainer(that) {
if (that.options.filterControlContainer) {
return $__default["default"]("".concat(that.options.filterControlContainer));
}
if (that.options.height && that._initialized) {
return $__default["default"]('.fixed-table-header table thead');
}
return that.$header;
}
function isKeyAllowed(keyCode) {
return $__default["default"].inArray(keyCode, [37, 38, 39, 40]) > -1;
}
function getSearchControls(that) {
return getControlContainer(that).find(searchControls);
}
function existOptionInSelectControl(selectControl, value) {
var options = getOptionsFromSelectControl(selectControl);
for (var i = 0; i < options.length; i++) {
if (options[i].value === Utils$1.unescapeHTML(value)) {
// The value is not valid to add
return true;
}
} // If we get here, the value is valid to add
return false;
}
function addOptionToSelectControl(selectControl, _value, text, selected, shouldCompareText) {
var value = _value === undefined || _value === null ? '' : _value.toString().trim();
value = Utils$1.removeHTML(value);
text = Utils$1.removeHTML(text);
if (existOptionInSelectControl(selectControl, value)) {
return;
}
var isSelected = shouldCompareText ? value === selected || text === selected : value === selected;
var option = new Option(text, value, false, isSelected);
selectControl.get(0).add(option);
}
function sortSelectControl(selectControl, orderBy) {
var $selectControl = selectControl.get(0);
if (orderBy === 'server') {
return;
}
var tmpAry = new Array();
for (var i = 0; i < $selectControl.options.length; i++) {
tmpAry[i] = new Array();
tmpAry[i][0] = $selectControl.options[i].text;
tmpAry[i][1] = $selectControl.options[i].value;
tmpAry[i][2] = $selectControl.options[i].selected;
}
tmpAry.sort(function (a, b) {
return Utils$1.sort(a[0], b[0], orderBy === 'desc' ? -1 : 1);
});
while ($selectControl.options.length > 0) {
$selectControl.options[0] = null;
}
for (var _i = 0; _i < tmpAry.length; _i++) {
var op = new Option(tmpAry[_i][0], tmpAry[_i][1], false, tmpAry[_i][2]);
$selectControl.add(op);
}
}
function fixHeaderCSS(_ref) {
var $tableHeader = _ref.$tableHeader;
$tableHeader.css('height', $tableHeader.find('table').outerHeight(true));
}
function getElementClass($element) {
return $element.attr('class').replace('form-control', '').replace('focus-temp', '').replace('search-input', '').trim();
}
function getCursorPosition(el) {
if ($__default["default"](el).is('input[type=search]')) {
var pos = 0;
if ('selectionStart' in el) {
pos = el.selectionStart;
} else if ('selection' in document) {
el.focus();
var Sel = document.selection.createRange();
var SelLength = document.selection.createRange().text.length;
Sel.moveStart('character', -el.value.length);
pos = Sel.text.length - SelLength;
}
return pos;
}
return -1;
}
function cacheValues(that) {
var searchControls = getSearchControls(that);
that._valuesFilterControl = [];
searchControls.each(function () {
var $field = $__default["default"](this);
var fieldClass = getElementClass($field);
if (that.options.height && !that.options.filterControlContainer) {
$field = $__default["default"](".fixed-table-header .".concat(fieldClass));
} else if (that.options.filterControlContainer) {
$field = $__default["default"]("".concat(that.options.filterControlContainer, " .").concat(fieldClass));
} else {
$field = $__default["default"](".".concat(fieldClass));
}
that._valuesFilterControl.push({
field: $field.closest('[data-field]').data('field'),
value: $field.val(),
position: getCursorPosition($field.get(0)),
hasFocus: $field.is(':focus')
});
});
}
function setCaretPosition(elem, caretPos) {
try {
if (elem) {
if (elem.createTextRange) {
var range = elem.createTextRange();
range.move('character', caretPos);
range.select();
} else {
elem.setSelectionRange(caretPos, caretPos);
}
}
} catch (ex) {// ignored
}
}
function setValues(that) {
var field = null;
var result = [];
var searchControls = getSearchControls(that);
if (that._valuesFilterControl.length > 0) {
// Callback to apply after settings fields values
var callbacks = [];
searchControls.each(function (i, el) {
var $this = $__default["default"](el);
field = $this.closest('[data-field]').data('field');
result = that._valuesFilterControl.filter(function (valueObj) {
return valueObj.field === field;
});
if (result.length > 0) {
if (result[0].hasFocus || result[0].value) {
var fieldToFocusCallback = function (element, cacheElementInfo) {
// Closure here to capture the field information
var closedCallback = function closedCallback() {
if (cacheElementInfo.hasFocus) {
element.focus();
}
if (Array.isArray(cacheElementInfo.value)) {
var $element = $__default["default"](element);
$__default["default"].each(cacheElementInfo.value, function (i, e) {
$element.find(Utils$1.sprintf('option[value=\'%s\']', e)).prop('selected', true);
});
} else {
element.value = cacheElementInfo.value;
}
setCaretPosition(element, cacheElementInfo.position);
};
return closedCallback;
}($this.get(0), result[0]);
callbacks.push(fieldToFocusCallback);
}
}
}); // Callback call.
if (callbacks.length > 0) {
callbacks.forEach(function (callback) {
return callback();
});
}
}
}
function collectBootstrapTableFilterCookies() {
var cookies = [];
var foundCookies = document.cookie.match(/bs\.table\.(filterControl|searchText)/g);
var foundLocalStorage = localStorage;
if (foundCookies) {
$__default["default"].each(foundCookies, function (i, _cookie) {
var cookie = _cookie;
if (/./.test(cookie)) {
cookie = cookie.split('.').pop();
}
if ($__default["default"].inArray(cookie, cookies) === -1) {
cookies.push(cookie);
}
});
}
if (foundLocalStorage) {
for (var i = 0; i < foundLocalStorage.length; i++) {
var cookie = foundLocalStorage.key(i);
if (/./.test(cookie)) {
cookie = cookie.split('.').pop();
}
if (!cookies.includes(cookie)) {
cookies.push(cookie);
}
}
}
return cookies;
}
function escapeID(id) {
// eslint-disable-next-line no-useless-escape
return String(id).replace(/([:.\[\],])/g, '\\$1');
}
function isColumnSearchableViaSelect(_ref2) {
var filterControl = _ref2.filterControl,
searchable = _ref2.searchable;
return filterControl && filterControl.toLowerCase() === 'select' && searchable;
}
function isFilterDataNotGiven(_ref3) {
var filterData = _ref3.filterData;
return filterData === undefined || filterData.toLowerCase() === 'column';
}
function hasSelectControlElement(selectControl) {
return selectControl && selectControl.length > 0;
}
function initFilterSelectControls(that) {
var data = that.options.data;
$__default["default"].each(that.header.fields, function (j, field) {
var column = that.columns[that.fieldsColumnsIndex[field]];
var selectControl = getControlContainer(that).find("select.bootstrap-table-filter-control-".concat(escapeID(column.field)));
if (isColumnSearchableViaSelect(column) && isFilterDataNotGiven(column) && hasSelectControlElement(selectControl)) {
if (!selectControl[0].multiple && selectControl.get(selectControl.length - 1).options.length === 0) {
// Added the default option, must use a non-breaking space( ) to pass the W3C validator
addOptionToSelectControl(selectControl, '', column.filterControlPlaceholder || ' ', column.filterDefault);
}
var uniqueValues = {};
for (var i = 0; i < data.length; i++) {
// Added a new value
var fieldValue = Utils$1.getItemField(data[i], field, false);
var formatter = that.options.editable && column.editable ? column._formatter : that.header.formatters[j];
var formattedValue = Utils$1.calculateObjectValue(that.header, formatter, [fieldValue, data[i], i], fieldValue);
if (!fieldValue) {
fieldValue = formattedValue;
column._forceFormatter = true;
}
if (column.filterDataCollector) {
formattedValue = Utils$1.calculateObjectValue(that.header, column.filterDataCollector, [fieldValue, data[i], formattedValue], formattedValue);
}
if (column.searchFormatter) {
fieldValue = formattedValue;
}
uniqueValues[formattedValue] = fieldValue;
if (_typeof(formattedValue) === 'object' && formattedValue !== null) {
formattedValue.forEach(function (value) {
addOptionToSelectControl(selectControl, value, value, column.filterDefault);
});
continue;
}
} // eslint-disable-next-line guard-for-in
for (var key in uniqueValues) {
addOptionToSelectControl(selectControl, uniqueValues[key], key, column.filterDefault);
}
}
});
}
function getFilterDataMethod(objFilterDataMethod, searchTerm) {
var keys = Object.keys(objFilterDataMethod);
for (var i = 0; i < keys.length; i++) {
if (keys[i] === searchTerm) {
return objFilterDataMethod[searchTerm];
}
}
return null;
}
function createControls(that, header) {
var addedFilterControl = false;
var html;
$__default["default"].each(that.columns, function (_, column) {
html = [];
if (!column.visible) {
return;
}
if (!column.filterControl && !that.options.filterControlContainer) {
html.push('');
} else if (that.options.filterControlContainer) {
// Use a filter control container instead of th
var $filterControls = $__default["default"](".bootstrap-table-filter-control-".concat(column.field));
$__default["default"].each($filterControls, function (_, filterControl) {
var $filterControl = $__default["default"](filterControl);
if (!$filterControl.is('[type=radio]')) {
var placeholder = column.filterControlPlaceholder || '';
$filterControl.attr('placeholder', placeholder).val(column.filterDefault);
}
$filterControl.attr('data-field', column.field);
});
addedFilterControl = true;
} else {
// Create the control based on the html defined in the filterTemplate array.
var nameControl = column.filterControl.toLowerCase();
html.push('');
addedFilterControl = true;
if (column.searchable && that.options.filterTemplate[nameControl]) {
html.push(that.options.filterTemplate[nameControl](that, column, column.filterControlPlaceholder ? column.filterControlPlaceholder : '', column.filterDefault));
}
} // Filtering by default when it is set.
if (column.filterControl && '' !== column.filterDefault && 'undefined' !== typeof column.filterDefault) {
if ($__default["default"].isEmptyObject(that.filterColumnsPartial)) {
that.filterColumnsPartial = {};
}
that.filterColumnsPartial[column.field] = column.filterDefault;
}
$__default["default"].each(header.find('th'), function (_, th) {
var $th = $__default["default"](th);
if ($th.data('field') === column.field) {
$th.find('.filter-control').remove();
$th.find('.fht-cell').html(html.join(''));
return false;
}
});
if (column.filterData && column.filterData.toLowerCase() !== 'column') {
var filterDataType = getFilterDataMethod(filterDataMethods, column.filterData.substring(0, column.filterData.indexOf(':')));
var filterDataSource;
var selectControl;
if (filterDataType) {
filterDataSource = column.filterData.substring(column.filterData.indexOf(':') + 1, column.filterData.length);
selectControl = header.find(".bootstrap-table-filter-control-".concat(escapeID(column.field)));
addOptionToSelectControl(selectControl, '', column.filterControlPlaceholder, column.filterDefault, true);
filterDataType(that, filterDataSource, selectControl, that.options.filterOrderBy, column.filterDefault);
} else {
throw new SyntaxError('Error. You should use any of these allowed filter data methods: var, obj, json, url, func.' + ' Use like this: var: {key: "value"}');
}
}
});
if (addedFilterControl) {
header.off('keyup', 'input').on('keyup', 'input', function (_ref4, obj) {
var currentTarget = _ref4.currentTarget,
keyCode = _ref4.keyCode;
keyCode = obj ? obj.keyCode : keyCode;
if (that.options.searchOnEnterKey && keyCode !== 13) {
return;
}
if (isKeyAllowed(keyCode)) {
return;
}
var $currentTarget = $__default["default"](currentTarget);
if ($currentTarget.is(':checkbox') || $currentTarget.is(':radio')) {
return;
}
clearTimeout(currentTarget.timeoutId || 0);
currentTarget.timeoutId = setTimeout(function () {
that.onColumnSearch({
currentTarget: currentTarget,
keyCode: keyCode
});
}, that.options.searchTimeOut);
});
header.off('change', 'select', '.fc-multipleselect').on('change', 'select', '.fc-multipleselect', function (_ref5) {
var currentTarget = _ref5.currentTarget,
keyCode = _ref5.keyCode;
var $selectControl = $__default["default"](currentTarget);
var value = $selectControl.val();
if (Array.isArray(value)) {
for (var i = 0; i < value.length; i++) {
if (value[i] && value[i].length > 0 && value[i].trim()) {
$selectControl.find("option[value=\"".concat(value[i], "\"]")).attr('selected', true);
}
}
} else if (value && value.length > 0 && value.trim()) {
$selectControl.find('option[selected]').removeAttr('selected');
$selectControl.find("option[value=\"".concat(value, "\"]")).attr('selected', true);
} else {
$selectControl.find('option[selected]').removeAttr('selected');
}
clearTimeout(currentTarget.timeoutId || 0);
currentTarget.timeoutId = setTimeout(function () {
that.onColumnSearch({
currentTarget: currentTarget,
keyCode: keyCode
});
}, that.options.searchTimeOut);
});
header.off('mouseup', 'input:not([type=radio])').on('mouseup', 'input:not([type=radio])', function (_ref6) {
var currentTarget = _ref6.currentTarget,
keyCode = _ref6.keyCode;
var $input = $__default["default"](currentTarget);
var oldValue = $input.val();
if (oldValue === '') {
return;
}
setTimeout(function () {
var newValue = $input.val();
if (newValue === '') {
clearTimeout(currentTarget.timeoutId || 0);
currentTarget.timeoutId = setTimeout(function () {
that.onColumnSearch({
currentTarget: currentTarget,
keyCode: keyCode
});
}, that.options.searchTimeOut);
}
}, 1);
});
header.off('change', 'input[type=radio]').on('change', 'input[type=radio]', function (_ref7) {
var currentTarget = _ref7.currentTarget,
keyCode = _ref7.keyCode;
clearTimeout(currentTarget.timeoutId || 0);
currentTarget.timeoutId = setTimeout(function () {
that.onColumnSearch({
currentTarget: currentTarget,
keyCode: keyCode
});
}, that.options.searchTimeOut);
}); // See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date
if (header.find('.date-filter-control').length > 0) {
$__default["default"].each(that.columns, function (i, _ref8) {
var filterDefault = _ref8.filterDefault,
filterControl = _ref8.filterControl,
field = _ref8.field,
filterDatepickerOptions = _ref8.filterDatepickerOptions;
if (filterControl !== undefined && filterControl.toLowerCase() === 'datepicker') {
var $datepicker = header.find(".date-filter-control.bootstrap-table-filter-control-".concat(field));
if (filterDefault) {
$datepicker.value(filterDefault);
}
if (filterDatepickerOptions.min) {
$datepicker.attr('min', filterDatepickerOptions.min);
}
if (filterDatepickerOptions.max) {
$datepicker.attr('max', filterDatepickerOptions.max);
}
if (filterDatepickerOptions.step) {
$datepicker.attr('step', filterDatepickerOptions.step);
}
if (filterDatepickerOptions.pattern) {
$datepicker.attr('pattern', filterDatepickerOptions.pattern);
}
$datepicker.on('change', function (_ref9) {
var currentTarget = _ref9.currentTarget;
clearTimeout(currentTarget.timeoutId || 0);
currentTarget.timeoutId = setTimeout(function () {
that.onColumnSearch({
currentTarget: currentTarget
});
}, that.options.searchTimeOut);
});
}
});
}
if (that.options.sidePagination !== 'server') {
that.triggerSearch();
}
if (!that.options.filterControlVisible) {
header.find('.filter-control, .no-filter-control').hide();
}
} else {
header.find('.filter-control, .no-filter-control').hide();
}
that.trigger('created-controls');
}
function getDirectionOfSelectOptions(_alignment) {
var alignment = _alignment === undefined ? 'left' : _alignment.toLowerCase();
switch (alignment) {
case 'left':
return 'ltr';
case 'right':
return 'rtl';
case 'auto':
return 'auto';
default:
return 'ltr';
}
}
function syncHeaders(that) {
if (!that.options.height) {
return;
}
var fixedHeader = $__default["default"]('.fixed-table-header table thead');
if (fixedHeader.length === 0) {
return;
}
that.$header.children().find('th[data-field]').each(function (_, element) {
if (element.classList[0] !== 'bs-checkbox') {
var $element = $__default["default"](element);
var $field = $element.data('field');
var $fixedField = $__default["default"]("th[data-field='".concat($field, "']")).not($element);
var input = $element.find('input');
var fixedInput = $fixedField.find('input');
if (input.length > 0 && fixedInput.length > 0) {
if (input.val() !== fixedInput.val()) {
input.val(fixedInput.val());
}
}
}
});
}
var filterDataMethods = {
func: function func(that, filterDataSource, selectControl, filterOrderBy, selected) {
var variableValues = window[filterDataSource].apply(); // eslint-disable-next-line guard-for-in
for (var key in variableValues) {
addOptionToSelectControl(selectControl, key, variableValues[key], selected);
}
if (that.options.sortSelectOptions) {
sortSelectControl(selectControl, filterOrderBy);
}
setValues(that);
},
obj: function obj(that, filterDataSource, selectControl, filterOrderBy, selected) {
var objectKeys = filterDataSource.split('.');
var variableName = objectKeys.shift();
var variableValues = window[variableName];
if (objectKeys.length > 0) {
objectKeys.forEach(function (key) {
variableValues = variableValues[key];
});
} // eslint-disable-next-line guard-for-in
for (var key in variableValues) {
addOptionToSelectControl(selectControl, key, variableValues[key], selected);
}
if (that.options.sortSelectOptions) {
sortSelectControl(selectControl, filterOrderBy);
}
setValues(that);
},
var: function _var(that, filterDataSource, selectControl, filterOrderBy, selected) {
var variableValues = window[filterDataSource];
var isArray = Array.isArray(variableValues);
for (var key in variableValues) {
if (isArray) {
addOptionToSelectControl(selectControl, variableValues[key], variableValues[key], selected, true);
} else {
addOptionToSelectControl(selectControl, key, variableValues[key], selected, true);
}
}
if (that.options.sortSelectOptions) {
sortSelectControl(selectControl, filterOrderBy);
}
setValues(that);
},
url: function url(that, filterDataSource, selectControl, filterOrderBy, selected) {
$__default["default"].ajax({
url: filterDataSource,
dataType: 'json',
success: function success(data) {
// eslint-disable-next-line guard-for-in
for (var key in data) {
addOptionToSelectControl(selectControl, key, data[key], selected);
}
if (that.options.sortSelectOptions) {
sortSelectControl(selectControl, filterOrderBy);
}
setValues(that);
}
});
},
json: function json(that, filterDataSource, selectControl, filterOrderBy, selected) {
var variableValues = JSON.parse(filterDataSource); // eslint-disable-next-line guard-for-in
for (var key in variableValues) {
addOptionToSelectControl(selectControl, key, variableValues[key], selected);
}
if (that.options.sortSelectOptions) {
sortSelectControl(selectControl, filterOrderBy);
}
setValues(that);
}
};
var Utils = $__default["default"].fn.bootstrapTable.utils;
$__default["default"].extend($__default["default"].fn.bootstrapTable.defaults, {
filterControl: false,
filterControlVisible: true,
// eslint-disable-next-line no-unused-vars
onColumnSearch: function onColumnSearch(field, text) {
return false;
},
onCreatedControls: function onCreatedControls() {
return false;
},
alignmentSelectControlOptions: undefined,
filterTemplate: {
input: function input(that, column, placeholder, value) {
return Utils.sprintf('', getInputClass(that), column.field, 'undefined' === typeof placeholder ? '' : placeholder, 'undefined' === typeof value ? '' : value);
},
select: function select(that, column) {
return Utils.sprintf('', getInputClass(that, true), column.field, '', '', getDirectionOfSelectOptions(that.options.alignmentSelectControlOptions));
},
datepicker: function datepicker(that, column, value) {
return Utils.sprintf('', getInputClass(that), column.field, 'undefined' === typeof value ? '' : value);
}
},
searchOnEnterKey: false,
showFilterControlSwitch: false,
sortSelectOptions: false,
// internal variables
_valuesFilterControl: [],
_initialized: false,
_isRendering: false,
_usingMultipleSelect: false
});
$__default["default"].extend($__default["default"].fn.bootstrapTable.columnDefaults, {
filterControl: undefined,
// input, select, datepicker
filterControlMultipleSelect: false,
filterControlMultipleSelectOptions: {},
filterDataCollector: undefined,
filterData: undefined,
filterDatepickerOptions: {},
filterStrictSearch: false,
filterStartsWithSearch: false,
filterControlPlaceholder: '',
filterDefault: '',
filterOrderBy: 'asc',
// asc || desc
filterCustomSearch: undefined
});
$__default["default"].extend($__default["default"].fn.bootstrapTable.Constructor.EVENTS, {
'column-search.bs.table': 'onColumnSearch',
'created-controls.bs.table': 'onCreatedControls'
});
$__default["default"].extend($__default["default"].fn.bootstrapTable.defaults.icons, {
filterControlSwitchHide: {
bootstrap3: 'glyphicon-zoom-out icon-zoom-out',
bootstrap5: 'bi-zoom-out',
materialize: 'zoom_out'
}[$__default["default"].fn.bootstrapTable.theme] || 'fa-search-minus',
filterControlSwitchShow: {
bootstrap3: 'glyphicon-zoom-in icon-zoom-in',
bootstrap5: 'bi-zoom-in',
materialize: 'zoom_in'
}[$__default["default"].fn.bootstrapTable.theme] || 'fa-search-plus'
});
$__default["default"].extend($__default["default"].fn.bootstrapTable.locales, {
formatFilterControlSwitch: function formatFilterControlSwitch() {
return 'Hide/Show controls';
},
formatFilterControlSwitchHide: function formatFilterControlSwitchHide() {
return 'Hide controls';
},
formatFilterControlSwitchShow: function formatFilterControlSwitchShow() {
return 'Show controls';
}
});
$__default["default"].extend($__default["default"].fn.bootstrapTable.defaults, $__default["default"].fn.bootstrapTable.locales);
$__default["default"].extend($__default["default"].fn.bootstrapTable.defaults, {
formatClearSearch: function formatClearSearch() {
return 'Clear filters';
}
});
$__default["default"].fn.bootstrapTable.methods.push('triggerSearch');
$__default["default"].fn.bootstrapTable.methods.push('clearFilterControl');
$__default["default"].fn.bootstrapTable.methods.push('toggleFilterControl');
$__default["default"].BootstrapTable = /*#__PURE__*/function (_$$BootstrapTable) {
_inherits(_class, _$$BootstrapTable);
var _super = _createSuper(_class);
function _class() {
_classCallCheck(this, _class);
return _super.apply(this, arguments);
}
_createClass(_class, [{
key: "init",
value: function init() {
var _this = this;
// Make sure that the filterControl option is set
if (this.options.filterControl) {
// Make sure that the internal variables are set correctly
this._valuesFilterControl = [];
this._initialized = false;
this._usingMultipleSelect = false;
this._isRendering = false;
this.$el.on('reset-view.bs.table', Utils.debounce(function () {
initFilterSelectControls(_this);
setValues(_this);
}, 3)).on('toggle.bs.table', Utils.debounce(function (_, cardView) {
_this._initialized = false;
if (!cardView) {
initFilterSelectControls(_this);
setValues(_this);
_this._initialized = true;
}
}, 1)).on('post-header.bs.table', Utils.debounce(function () {
initFilterSelectControls(_this);
setValues(_this);
}, 3)).on('column-switch.bs.table', Utils.debounce(function () {
setValues(_this);
if (_this.options.height) {
_this.fitHeader();
}
}, 1)).on('post-body.bs.table', Utils.debounce(function () {
if (_this.options.height && !_this.options.filterControlContainer && _this.options.filterControlVisible) {
fixHeaderCSS(_this);
}
_this.$tableLoading.css('top', _this.$header.outerHeight() + 1);
}, 1)).on('all.bs.table', function () {
syncHeaders(_this);
});
}
_get(_getPrototypeOf(_class.prototype), "init", this).call(this);
}
}, {
key: "initBody",
value: function initBody() {
var _this2 = this;
_get(_getPrototypeOf(_class.prototype), "initBody", this).call(this);
if (!this.options.filterControl) {
return;
}
setTimeout(function () {
initFilterSelectControls(_this2);
setValues(_this2);
}, 3);
}
}, {
key: "load",
value: function load(data) {
_get(_getPrototypeOf(_class.prototype), "load", this).call(this, data);
if (!this.options.filterControl) {
return;
}
createControls(this, getControlContainer(this));
setValues(this);
}
}, {
key: "initHeader",
value: function initHeader() {
_get(_getPrototypeOf(_class.prototype), "initHeader", this).call(this);
if (!this.options.filterControl) {
return;
}
createControls(this, getControlContainer(this));
this._initialized = true;
}
}, {
key: "initSearch",
value: function initSearch() {
var _this3 = this;
var that = this;
var filterPartial = $__default["default"].isEmptyObject(that.filterColumnsPartial) ? null : that.filterColumnsPartial;
_get(_getPrototypeOf(_class.prototype), "initSearch", this).call(this);
if (this.options.sidePagination === 'server' || filterPartial === null) {
return;
} // Check partial column filter
that.data = filterPartial ? that.data.filter(function (item, i) {
var itemIsExpected = [];
var keys1 = Object.keys(item);
var keys2 = Object.keys(filterPartial);
var keys = keys1.concat(keys2.filter(function (item) {
return !keys1.includes(item);
}));
keys.forEach(function (key) {
var thisColumn = that.columns[that.fieldsColumnsIndex[key]];
var rawFilterValue = filterPartial[key] || '';
var filterValue = rawFilterValue.toLowerCase();
var value = Utils.unescapeHTML(Utils.getItemField(item, key, false));
var tmpItemIsExpected;
if (filterValue === '') {
tmpItemIsExpected = true;
} else {
// Fix #142: search use formatted data
if (thisColumn) {
if (thisColumn.searchFormatter || thisColumn._forceFormatter) {
value = $__default["default"].fn.bootstrapTable.utils.calculateObjectValue(that.header, that.header.formatters[$__default["default"].inArray(key, that.header.fields)], [value, item, i], value);
}
}
if ($__default["default"].inArray(key, that.header.fields) !== -1) {
if (value === undefined || value === null) {
tmpItemIsExpected = false;
} else if (_typeof(value) === 'object' && thisColumn.filterCustomSearch) {
itemIsExpected.push(that.isValueExpected(rawFilterValue, value, thisColumn, key));
return;
} else if (_typeof(value) === 'object' && Array.isArray(value)) {
value.forEach(function (objectValue) {
if (tmpItemIsExpected) {
return;
}
if (_this3.options.searchAccentNeutralise) {
objectValue = Utils.normalizeAccent(objectValue);
}
tmpItemIsExpected = that.isValueExpected(filterValue, objectValue, thisColumn, key);
});
} else if (_typeof(value) === 'object' && !Array.isArray(value)) {
Object.values(value).forEach(function (objectValue) {
if (tmpItemIsExpected) {
return;
}
if (_this3.options.searchAccentNeutralise) {
objectValue = Utils.normalizeAccent(objectValue);
}
tmpItemIsExpected = that.isValueExpected(filterValue, objectValue, thisColumn, key);
});
} else if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
if (_this3.options.searchAccentNeutralise) {
value = Utils.normalizeAccent(value);
}
tmpItemIsExpected = that.isValueExpected(filterValue, value, thisColumn, key);
}
}
}
itemIsExpected.push(tmpItemIsExpected);
});
return !itemIsExpected.includes(false);
}) : that.data;
that.unsortedData = _toConsumableArray(that.data);
}
}, {
key: "isValueExpected",
value: function isValueExpected(searchValue, value, column, key) {
var tmpItemIsExpected = false;
if (column.filterStrictSearch) {
tmpItemIsExpected = value.toString().toLowerCase() === searchValue.toString().toLowerCase();
} else if (column.filterStartsWithSearch) {
tmpItemIsExpected = "".concat(value).toLowerCase().indexOf(searchValue) === 0;
} else if (column.filterControl === 'datepicker') {
tmpItemIsExpected = new Date(value) === new Date(searchValue);
} else if (this.options.regexSearch) {
tmpItemIsExpected = Utils.regexCompare(value, searchValue);
} else {
tmpItemIsExpected = "".concat(value).toLowerCase().includes(searchValue);
}
var largerSmallerEqualsRegex = /(?:(<=|=>|=<|>=|>|<)(?:\s+)?(\d+)?|(\d+)?(\s+)?(<=|=>|=<|>=|>|<))/gm;
var matches = largerSmallerEqualsRegex.exec(searchValue);
if (matches) {
var operator = matches[1] || "".concat(matches[5], "l");
var comparisonValue = matches[2] || matches[3];
var int = parseInt(value, 10);
var comparisonInt = parseInt(comparisonValue, 10);
switch (operator) {
case '>':
case ' comparisonInt;
break;
case '<':
case '>l':
tmpItemIsExpected = int < comparisonInt;
break;
case '<=':
case '=<':
case '>=l':
case '=>l':
tmpItemIsExpected = int <= comparisonInt;
break;
case '>=':
case '=>':
case '<=l':
case '== comparisonInt;
break;
}
}
if (column.filterCustomSearch) {
var customSearchResult = Utils.calculateObjectValue(this, column.filterCustomSearch, [searchValue, value, key, this.options.data], true);
if (customSearchResult !== null) {
tmpItemIsExpected = customSearchResult;
}
}
return tmpItemIsExpected;
}
}, {
key: "initColumnSearch",
value: function initColumnSearch(filterColumnsDefaults) {
cacheValues(this);
if (filterColumnsDefaults) {
this.filterColumnsPartial = filterColumnsDefaults;
this.updatePagination(); // eslint-disable-next-line guard-for-in
for (var filter in filterColumnsDefaults) {
this.trigger('column-search', filter, filterColumnsDefaults[filter]);
}
}
}
}, {
key: "initToolbar",
value: function initToolbar() {
this.showToolbar = this.showToolbar || this.options.showFilterControlSwitch;
this.showSearchClearButton = this.options.filterControl && this.options.showSearchClearButton;
if (this.options.showFilterControlSwitch) {
this.buttons = Object.assign(this.buttons, {
filterControlSwitch: {
text: this.options.filterControlVisible ? this.options.formatFilterControlSwitchHide() : this.options.formatFilterControlSwitchShow(),
icon: this.options.filterControlVisible ? this.options.icons.filterControlSwitchHide : this.options.icons.filterControlSwitchShow,
event: this.toggleFilterControl,
attributes: {
'aria-label': this.options.formatFilterControlSwitch(),
title: this.options.formatFilterControlSwitch()
}
}
});
}
_get(_getPrototypeOf(_class.prototype), "initToolbar", this).call(this);
}
}, {
key: "resetSearch",
value: function resetSearch(text) {
if (this.options.filterControl && this.options.showSearchClearButton) {
this.clearFilterControl();
}
_get(_getPrototypeOf(_class.prototype), "resetSearch", this).call(this, text);
}
}, {
key: "clearFilterControl",
value: function clearFilterControl() {
if (!this.options.filterControl) {
return;
}
var that = this;
var table = this.$el.closest('table');
var cookies = collectBootstrapTableFilterCookies();
var controls = getSearchControls(that); // const search = Utils.getSearchInput(this)
var hasValues = false;
var timeoutId = 0; // Clear cache values
$__default["default"].each(that._valuesFilterControl, function (i, item) {
hasValues = hasValues ? true : item.value !== '';
item.value = '';
}); // Clear controls in UI
$__default["default"].each(controls, function (i, item) {
item.value = '';
}); // Cache controls again
setValues(that); // clear cookies once the filters are clean
clearTimeout(timeoutId);
timeoutId = setTimeout(function () {
if (cookies && cookies.length > 0) {
$__default["default"].each(cookies, function (i, item) {
if (that.deleteCookie !== undefined) {
that.deleteCookie(item);
}
});
}
}, that.options.searchTimeOut); // If there is not any value in the controls exit this method
if (!hasValues) {
return;
} // Clear each type of filter if it exists.
// Requires the body to reload each time a type of filter is found because we never know
// which ones are going to be present.
if (controls.length > 0) {
this.filterColumnsPartial = {};
controls.eq(0).trigger(this.tagName === 'INPUT' ? 'keyup' : 'change', {
keyCode: 13
});
/* controls.each(function () {
$(this).trigger(this.tagName === 'INPUT' ? 'keyup' : 'change', { keyCode: 13 })
})*/
} else {
return;
}
/* if (search.length > 0) {
that.resetSearch('fc')
}*/
// use the default sort order if it exists. do nothing if it does not
if (that.options.sortName !== table.data('sortName') || that.options.sortOrder !== table.data('sortOrder')) {
var sorter = this.$header.find(Utils.sprintf('[data-field="%s"]', $__default["default"](controls[0]).closest('table').data('sortName')));
if (sorter.length > 0) {
that.onSort({
type: 'keypress',
currentTarget: sorter
});
$__default["default"](sorter).find('.sortable').trigger('click');
}
}
} // EVENTS
}, {
key: "onColumnSearch",
value: function onColumnSearch(_ref) {
var _this4 = this;
var currentTarget = _ref.currentTarget,
keyCode = _ref.keyCode;
if (isKeyAllowed(keyCode)) {
return;
}
cacheValues(this); // Cookie extension support
if (!this.options.cookie) {
this.options.pageNumber = 1;
} else {
// Force call the initServer method in Cookie extension
this._filterControlValuesLoaded = true;
}
if ($__default["default"].isEmptyObject(this.filterColumnsPartial)) {
this.filterColumnsPartial = {};
} // If searchOnEnterKey is set to true, then we need to iterate over all controls and grab their values.
var controls = this.options.searchOnEnterKey ? getSearchControls(this).toArray() : [currentTarget];
controls.forEach(function (element) {
var $element = $__default["default"](element);
var elementValue = $element.val();
var text = elementValue ? elementValue.trim() : '';
var $field = $element.closest('[data-field]').data('field');
_this4.trigger('column-search', $field, text);
if (text) {
_this4.filterColumnsPartial[$field] = text;
} else {
delete _this4.filterColumnsPartial[$field];
}
});
this.onSearch({
currentTarget: currentTarget
}, false);
}
}, {
key: "toggleFilterControl",
value: function toggleFilterControl() {
this.options.filterControlVisible = !this.options.filterControlVisible; // Controls in original header or container.
var $filterControls = getControlContainer(this).find('.filter-control, .no-filter-control');
if (this.options.filterControlVisible) {
$filterControls.show();
} else {
$filterControls.hide();
this.clearFilterControl();
} // Controls in fixed header
if (this.options.height) {
var $fixedControls = $__default["default"]('.fixed-table-header table thead').find('.filter-control, .no-filter-control');
$fixedControls.toggle(this.options.filterControlVisible);
fixHeaderCSS(this);
}
var icon = this.options.showButtonIcons ? this.options.filterControlVisible ? this.options.icons.filterControlSwitchHide : this.options.icons.filterControlSwitchShow : '';
var text = this.options.showButtonText ? this.options.filterControlVisible ? this.options.formatFilterControlSwitchHide() : this.options.formatFilterControlSwitchShow() : '';
this.$toolbar.find('>.columns').find('.filter-control-switch').html("".concat(Utils.sprintf(this.constants.html.icon, this.options.iconsPrefix, icon), " ").concat(text));
}
}, {
key: "triggerSearch",
value: function triggerSearch() {
var searchControls = getSearchControls(this);
searchControls.each(function () {
var $element = $__default["default"](this);
if ($element.is('select')) {
$element.trigger('change');
} else {
$element.trigger('keyup');
}
});
}
}, {
key: "_toggleColumn",
value: function _toggleColumn(index, checked, needUpdate) {
this._initialized = false;
_get(_getPrototypeOf(_class.prototype), "_toggleColumn", this).call(this, index, checked, needUpdate);
syncHeaders(this);
}
}]);
return _class;
}($__default["default"].BootstrapTable);
}));