(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('core-js/modules/es.array.concat.js'), require('core-js/modules/es.array.filter.js'), require('core-js/modules/es.array.find.js'), require('core-js/modules/es.array.includes.js'), require('core-js/modules/es.array.index-of.js'), require('core-js/modules/es.array.join.js'), require('core-js/modules/es.array.sort.js'), require('core-js/modules/es.object.keys.js'), require('core-js/modules/es.object.to-string.js'), require('core-js/modules/es.regexp.exec.js'), require('core-js/modules/es.regexp.to-string.js'), require('core-js/modules/es.string.match.js'), require('core-js/modules/es.string.replace.js'), require('core-js/modules/es.string.starts-with.js'), require('core-js/modules/es.string.trim.js'), require('core-js/modules/web.dom-collections.for-each.js'), require('jquery')) : typeof define === 'function' && define.amd ? define(['exports', 'core-js/modules/es.array.concat.js', 'core-js/modules/es.array.filter.js', 'core-js/modules/es.array.find.js', 'core-js/modules/es.array.includes.js', 'core-js/modules/es.array.index-of.js', 'core-js/modules/es.array.join.js', 'core-js/modules/es.array.sort.js', 'core-js/modules/es.object.keys.js', 'core-js/modules/es.object.to-string.js', 'core-js/modules/es.regexp.exec.js', 'core-js/modules/es.regexp.to-string.js', 'core-js/modules/es.string.match.js', 'core-js/modules/es.string.replace.js', 'core-js/modules/es.string.starts-with.js', 'core-js/modules/es.string.trim.js', 'core-js/modules/web.dom-collections.for-each.js', 'jquery'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.BootstrapTable = {}, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, global.jQuery)); })(this, (function (exports, es_array_concat_js, es_array_filter_js, es_array_find_js, es_array_includes_js, es_array_indexOf_js, es_array_join_js, es_array_sort_js, es_object_keys_js, es_object_toString_js, es_regexp_exec_js, es_regexp_toString_js, es_string_match_js, es_string_replace_js, es_string_startsWith_js, es_string_trim_js, web_domCollections_forEach_js, $) { 'use strict'; function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } /* eslint-disable no-use-before-define */ var Utils = $.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.sprintf('%s %s-%s', formControlClass, formControlClass, that.options.iconSize) : formControlClass; } function getOptionsFromSelectControl(selectControl) { return selectControl[0].options; } function getControlContainer(that) { if (that.options.filterControlContainer) { return $("".concat(that.options.filterControlContainer)); } if (that.options.height && that._initialized) { return that.$tableContainer.find('.fixed-table-header table thead'); } return that.$header; } function isKeyAllowed(keyCode) { return $.inArray(keyCode, [37, 38, 39, 40]) > -1; } function getSearchControls(that) { return getControlContainer(that).find(searchControls); } function hideUnusedSelectOptions(selectControl, uniqueValues) { var options = getOptionsFromSelectControl(selectControl); for (var i = 0; i < options.length; i++) { if (options[i].value !== '') { if (!uniqueValues.hasOwnProperty(options[i].value)) { selectControl.find(Utils.sprintf('option[value=\'%s\']', options[i].value)).hide(); } else { selectControl.find(Utils.sprintf('option[value=\'%s\']', options[i].value)).show(); } } } } function existOptionInSelectControl(selectControl, value) { var options = getOptionsFromSelectControl(selectControl); for (var i = 0; i < options.length; i++) { if (options[i].value === Utils.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.removeHTML(Utils.unescapeHTML(value)); text = Utils.removeHTML(Utils.unescapeHTML(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, options) { 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.sort(a[0], b[0], orderBy === 'desc' ? -1 : 1, options); }); 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').split(' ').filter(function (className) { return className.startsWith('bootstrap-table-filter-control-'); }); } function getCursorPosition(el) { if ($(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 = $(this); var fieldClass = escapeID(getElementClass($field)); if (that.options.height && !that.options.filterControlContainer) { $field = that.$el.find(".fixed-table-header .".concat(fieldClass)); } else if (that.options.filterControlContainer) { $field = $("".concat(that.options.filterControlContainer, " .").concat(fieldClass)); } else { $field = that.$el.find(".".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 = $(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 = $(element); $.each(cacheElementInfo.value, function (i, e) { $element.find(Utils.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 cookieRegex = /bs\.table\.(filterControl|searchText)/g; var foundCookies = document.cookie.match(cookieRegex); var foundLocalStorage = localStorage; if (foundCookies) { $.each(foundCookies, function (i, _cookie) { var cookie = _cookie; if (/./.test(cookie)) { cookie = cookie.split('.').pop(); } if ($.inArray(cookie, cookies) === -1) { cookies.push(cookie); } }); } if (!foundLocalStorage) { return cookies; } Object.keys(localStorage).forEach(function (cookie) { if (!cookieRegex.test(cookie)) { return; } 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; $.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.getItemField(data[i], field, false); var formatter = that.options.editable && column.editable ? column._formatter : that.header.formatters[j]; var formattedValue = Utils.calculateObjectValue(that.header, formatter, [fieldValue, data[i], i], fieldValue); if (fieldValue === undefined || fieldValue === null) { fieldValue = formattedValue; column._forceFormatter = true; } if (column.filterDataCollector) { formattedValue = Utils.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); } if (that.options.sortSelectOptions) { sortSelectControl(selectControl, column.filterOrderBy, that.options); } } }); } 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; $.each(that.columns, function (_, column) { html = []; if (!column.visible && !(that.options.filterControlContainer && $(".bootstrap-table-filter-control-".concat(escapeID(column.field))).length >= 1)) { return; } if (!column.filterControl && !that.options.filterControlContainer) { html.push('
'); } else if (that.options.filterControlContainer) { // Use a filter control container instead of th var $filterControls = $(".bootstrap-table-filter-control-".concat(escapeID(column.field))); $.each($filterControls, function (_, filterControl) { var $filterControl = $(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('