/** * ag-grid-community - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components * @version v25.0.0 * @link http://www.ag-grid.com/ ' * @license MIT */ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); /** * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components * @version v25.0.0 * @link http://www.ag-grid.com/ * @license MIT */ /** * If value is undefined, null or blank, returns null, otherwise returns the value * @param {T} value * @returns {T | null} */ function makeNull(value) { return value == null || value === '' ? null : value; } function exists(value, allowEmptyString) { if (allowEmptyString === void 0) { allowEmptyString = false; } return value != null && (allowEmptyString || value !== ''); } function missing(value) { return !exists(value); } function missingOrEmpty(value) { return !value || missing(value) || value.length === 0; } function toStringOrNull(value) { return exists(value) && value.toString ? value.toString() : null; } // for parsing html attributes, where we want empty strings and missing attributes to be undefined function attrToNumber(value) { if (value === undefined) { // undefined or empty means ignore the value return; } if (value === null || value === '') { // null or blank means clear return null; } if (typeof value === 'number') { return isNaN(value) ? undefined : value; } var valueParsed = parseInt(value, 10); return isNaN(valueParsed) ? undefined : valueParsed; } // for parsing html attributes, where we want empty strings and missing attributes to be undefined function attrToBoolean(value) { if (value === undefined) { // undefined or empty means ignore the value return; } if (value === null || value === '') { // null means clear return false; } if (value === true || value === false) { // if simple boolean, return the boolean return value; } // if equal to the string 'true' (ignoring case) then return true return (/true/i).test(value); } // for parsing html attributes, where we want empty strings and missing attributes to be undefined function attrToString(value) { if (value == null || value === '') { return; } return value; } /** @deprecated */ function referenceCompare(left, right) { if (left == null && right == null) { return true; } if (left == null && right != null) { return false; } if (left != null && right == null) { return false; } return left === right; } function jsonEquals(val1, val2) { var val1Json = val1 ? JSON.stringify(val1) : null; var val2Json = val2 ? JSON.stringify(val2) : null; return val1Json === val2Json; } function defaultComparator(valueA, valueB, accentedCompare) { if (accentedCompare === void 0) { accentedCompare = false; } var valueAMissing = valueA == null; var valueBMissing = valueB == null; // this is for aggregations sum and avg, where the result can be a number that is wrapped. // if we didn't do this, then the toString() value would be used, which would result in // the strings getting used instead of the numbers. if (valueA && valueA.toNumber) { valueA = valueA.toNumber(); } if (valueB && valueB.toNumber) { valueB = valueB.toNumber(); } if (valueAMissing && valueBMissing) { return 0; } if (valueAMissing) { return -1; } if (valueBMissing) { return 1; } function doQuickCompare(a, b) { return (a > b ? 1 : (a < b ? -1 : 0)); } if (typeof valueA !== 'string') { return doQuickCompare(valueA, valueB); } if (!accentedCompare) { return doQuickCompare(valueA, valueB); } try { // using local compare also allows chinese comparisons return valueA.localeCompare(valueB); } catch (e) { // if something wrong with localeCompare, eg not supported // by browser, then just continue with the quick one return doQuickCompare(valueA, valueB); } } function find(collection, predicate, value) { if (collection === null || collection === undefined) { return null; } if (!Array.isArray(collection)) { var objToArray = values(collection); return find(objToArray, predicate, value); } var collectionAsArray = collection; var firstMatchingItem = null; for (var i = 0; i < collectionAsArray.length; i++) { var item = collectionAsArray[i]; if (typeof predicate === 'string') { if (item[predicate] === value) { firstMatchingItem = item; break; } } else { var callback = predicate; if (callback(item)) { firstMatchingItem = item; break; } } } return firstMatchingItem; } function values(object) { if (object instanceof Set || object instanceof Map) { var values_1 = []; object.forEach(function (value) { return values_1.push(value); }); return values_1; } return Object.keys(object).map(function (key) { return object[key]; }); } var GenericUtils = /*#__PURE__*/Object.freeze({ __proto__: null, makeNull: makeNull, exists: exists, missing: missing, missingOrEmpty: missingOrEmpty, toStringOrNull: toStringOrNull, attrToNumber: attrToNumber, attrToBoolean: attrToBoolean, attrToString: attrToString, referenceCompare: referenceCompare, jsonEquals: jsonEquals, defaultComparator: defaultComparator, find: find, values: values }); /** * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components * @version v25.0.0 * @link http://www.ag-grid.com/ * @license MIT */ var ColumnKeyCreator = /** @class */ (function () { function ColumnKeyCreator() { this.existingKeys = {}; } ColumnKeyCreator.prototype.addExistingKeys = function (keys) { for (var i = 0; i < keys.length; i++) { this.existingKeys[keys[i]] = true; } }; ColumnKeyCreator.prototype.getUniqueKey = function (colId, colField) { // in case user passed in number for colId, convert to string colId = toStringOrNull(colId); var count = 0; while (true) { var idToTry = void 0; if (colId) { idToTry = colId; if (count !== 0) { idToTry += '_' + count; } } else if (colField) { idToTry = colField; if (count !== 0) { idToTry += '_' + count; } } else { idToTry = '' + count; } if (!this.existingKeys[idToTry]) { this.existingKeys[idToTry] = true; return idToTry; } count++; } }; return ColumnKeyCreator; }()); /** * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components * @version v25.0.0 * @link http://www.ag-grid.com/ * @license MIT */ function firstExistingValue() { var values = []; for (var _i = 0; _i < arguments.length; _i++) { values[_i] = arguments[_i]; } for (var i = 0; i < values.length; i++) { var value = values[i]; if (exists(value)) { return value; } } return null; } /** @deprecated */ function anyExists(values) { return values && firstExistingValue(values) != null; } function existsAndNotEmpty(value) { return value != null && value.length > 0; } function last(arr) { if (!arr || !arr.length) { return undefined; } return arr[arr.length - 1]; } function areEqual(a, b, comparator) { if (a == null && b == null) { return true; } return a != null && b != null && a.length === b.length && every(a, function (value, index) { return comparator ? comparator(value, b[index]) : b[index] === value; }); } /** @deprecated */ function compareArrays(array1, array2) { return areEqual(array1, array2); } /** @deprecated */ function shallowCompare(arr1, arr2) { return areEqual(arr1, arr2); } function sortNumerically(array) { return array.sort(function (a, b) { return a - b; }); } function removeRepeatsFromArray(array, object) { if (!array) { return; } for (var index = array.length - 2; index >= 0; index--) { var thisOneMatches = array[index] === object; var nextOneMatches = array[index + 1] === object; if (thisOneMatches && nextOneMatches) { array.splice(index + 1, 1); } } } function removeFromArray(array, object) { var index = array.indexOf(object); if (index >= 0) { array.splice(index, 1); } } function removeAllFromArray(array, toRemove) { forEach(toRemove, function (item) { return removeFromArray(array, item); }); } function insertIntoArray(array, object, toIndex) { array.splice(toIndex, 0, object); } function insertArrayIntoArray(dest, src, toIndex) { if (dest == null || src == null) { return; } // put items in backwards, otherwise inserted items end up in reverse order for (var i = src.length - 1; i >= 0; i--) { var item = src[i]; insertIntoArray(dest, item, toIndex); } } function moveInArray(array, objectsToMove, toIndex) { // first take out items from the array removeAllFromArray(array, objectsToMove); // now add the objects, in same order as provided to us, that means we start at the end // as the objects will be pushed to the right as they are inserted forEach(objectsToMove.slice().reverse(), function (obj) { return insertIntoArray(array, obj, toIndex); }); } function includes(array, value) { return array.indexOf(value) > -1; } function flatten(arrayOfArrays) { return [].concat.apply([], arrayOfArrays); } function pushAll(target, source) { if (source == null || target == null) { return; } forEach(source, function (value) { return target.push(value); }); } function toStrings(array) { return map(array, toStringOrNull); } function findIndex(collection, predicate) { for (var i = 0; i < collection.length; i++) { if (predicate(collection[i], i, collection)) { return i; } } return -1; } /** * The implementation of Array.prototype.every in browsers is always slower than just using a simple for loop, so * use this for improved performance. * https://jsbench.me/bek91dtit8/ */ function every(list, predicate) { if (list == null) { return true; } for (var i = 0; i < list.length; i++) { if (!predicate(list[i], i)) { return false; } } return true; } /** * The implementation of Array.prototype.some in browsers is always slower than just using a simple for loop, so * use this for improved performance. * https://jsbench.me/5dk91e4tmt/ */ function some(list, predicate) { if (list == null) { return false; } for (var i = 0; i < list.length; i++) { if (predicate(list[i], i)) { return true; } } return false; } /** * The implementation of Array.prototype.forEach in browsers is often slower than just using a simple for loop, so * use this for improved performance. * https://jsbench.me/apk91elt8a/ */ function forEach(list, action) { if (list == null) { return; } for (var i = 0; i < list.length; i++) { action(list[i], i); } } function forEachReverse(list, action) { if (list == null) { return; } for (var i = list.length - 1; i >= 0; i--) { action(list[i], i); } } /** * The implementation of Array.prototype.map in browsers is generally the same as just using a simple for loop. However, * Firefox does exhibit some difference, and this performs no worse in other browsers, so use this if you want improved * performance. * https://jsbench.me/njk91ez8pc/ */ function map(list, process) { if (list == null) { return null; } var mapped = []; for (var i = 0; i < list.length; i++) { mapped.push(process(list[i], i)); } return mapped; } /** * The implementation of Array.prototype.filter in browsers is always slower than just using a simple for loop, so * use this for improved performance. * https://jsbench.me/7bk91fk08c/ */ function filter(list, predicate) { if (list == null) { return null; } var filtered = []; for (var i = 0; i < list.length; i++) { if (predicate(list[i], i)) { filtered.push(list[i]); } } return filtered; } /** * The implementation of Array.prototype.reduce in browsers is generally the same as just using a simple for loop. However, * Chrome does exhibit some difference, and this performs no worse in other browsers, so use this if you want improved * performance. * https://jsbench.me/7vk92n6u1f/ */ function reduce(list, step, initial) { if (list == null || initial == null) { return null; } var result = initial; for (var i = 0; i < list.length; i++) { result = step(result, list[i], i); } return result; } /** @deprecated */ function forEachSnapshotFirst(list, callback) { if (!list) { return; } var arrayCopy = list.slice(0); arrayCopy.forEach(callback); } var ArrayUtils = /*#__PURE__*/Object.freeze({ __proto__: null, firstExistingValue: firstExistingValue, anyExists: anyExists, existsAndNotEmpty: existsAndNotEmpty, last: last, areEqual: areEqual, compareArrays: compareArrays, shallowCompare: shallowCompare, sortNumerically: sortNumerically, removeRepeatsFromArray: removeRepeatsFromArray, removeFromArray: removeFromArray, removeAllFromArray: removeAllFromArray, insertIntoArray: insertIntoArray, insertArrayIntoArray: insertArrayIntoArray, moveInArray: moveInArray, includes: includes, flatten: flatten, pushAll: pushAll, toStrings: toStrings, findIndex: findIndex, every: every, some: some, forEach: forEach, forEachReverse: forEachReverse, map: map, filter: filter, reduce: reduce, forEachSnapshotFirst: forEachSnapshotFirst }); /** * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components * @version v25.0.0 * @link http://www.ag-grid.com/ * @license MIT */ function iterateObject(object, callback) { if (object == null) { return; } if (Array.isArray(object)) { forEach(object, function (value, index) { return callback("" + index, value); }); } else { forEach(Object.keys(object), function (key) { return callback(key, object[key]); }); } } function cloneObject(object) { var copy = {}; var keys = Object.keys(object); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = object[key]; copy[key] = value; } return copy; } function deepCloneObject(object) { return JSON.parse(JSON.stringify(object)); } // returns copy of an object, doing a deep clone of any objects with that object. // this is used for eg creating copies of Column Definitions, where we want to // deep copy all objects, but do not want to deep copy functions (eg when user provides // a function or class for colDef.cellRenderer) function deepCloneDefinition(object, keysToSkip) { if (!object) { return; } var obj = object; var res = {}; Object.keys(obj).forEach(function (key) { if (keysToSkip && keysToSkip.indexOf(key) >= 0) { return; } var value = obj[key]; // 'simple object' means a bunch of key/value pairs, eg {filter: 'myFilter'}. it does // NOT include the following: // 1) arrays // 2) functions or classes (eg ColumnAPI instance) var sourceIsSimpleObject = isNonNullObject(value) && value.constructor === Object; if (sourceIsSimpleObject) { res[key] = deepCloneDefinition(value); } else { res[key] = value; } }); return res; } function getProperty(object, key) { return object[key]; } function setProperty(object, key, value) { object[key] = value; } /** * Will copy the specified properties from `source` into the equivalent properties on `target`, ignoring properties with * a value of `undefined`. */ function copyPropertiesIfPresent(source, target) { var properties = []; for (var _i = 2; _i < arguments.length; _i++) { properties[_i - 2] = arguments[_i]; } forEach(properties, function (p) { return copyPropertyIfPresent(source, target, p); }); } /** * Will copy the specified property from `source` into the equivalent property on `target`, unless the property has a * value of `undefined`. If a transformation is provided, it will be applied to the value before being set on `target`. */ function copyPropertyIfPresent(source, target, property, transform) { var value = getProperty(source, property); if (value !== undefined) { setProperty(target, property, transform ? transform(value) : value); } } function getAllKeysInObjects(objects) { var allValues = {}; objects.filter(function (obj) { return obj != null; }).forEach(function (obj) { forEach(Object.keys(obj), function (key) { return allValues[key] = null; }); }); return Object.keys(allValues); } function getAllValuesInObject(obj) { if (!obj) { return []; } if (typeof Object.values === 'function') { return Object.values(obj); } var ret = []; for (var key in obj) { if (obj.hasOwnProperty(key) && obj.propertyIsEnumerable(key)) { ret.push(obj[key]); } } return ret; } function mergeDeep(dest, source, copyUndefined, makeCopyOfSimpleObjects) { if (copyUndefined === void 0) { copyUndefined = true; } if (makeCopyOfSimpleObjects === void 0) { makeCopyOfSimpleObjects = false; } if (!exists(source)) { return; } iterateObject(source, function (key, sourceValue) { var destValue = dest[key]; if (destValue === sourceValue) { return; } // when creating params, we don't want to just copy objects over. otherwise merging ColDefs (eg DefaultColDef // and Column Types) would result in params getting shared between objects. // by putting an empty value into destValue first, it means we end up copying over values from // the source object, rather than just copying in the source object in it's entirety. if (makeCopyOfSimpleObjects) { var objectIsDueToBeCopied = destValue == null && sourceValue != null; if (objectIsDueToBeCopied) { // 'simple object' means a bunch of key/value pairs, eg {filter: 'myFilter'}, as opposed // to a Class instance (such as ColumnAPI instance). var sourceIsSimpleObject = typeof sourceValue === 'object' && sourceValue.constructor === Object; var dontCopy = sourceIsSimpleObject; if (dontCopy) { destValue = {}; dest[key] = destValue; } } } if (isNonNullObject(sourceValue) && isNonNullObject(destValue) && !Array.isArray(destValue)) { mergeDeep(destValue, sourceValue, copyUndefined, makeCopyOfSimpleObjects); } else if (copyUndefined || sourceValue !== undefined) { dest[key] = sourceValue; } }); } function assign(object) { var sources = []; for (var _i = 1; _i < arguments.length; _i++) { sources[_i - 1] = arguments[_i]; } forEach(sources, function (source) { return iterateObject(source, function (key, value) { return object[key] = value; }); }); return object; } function missingOrEmptyObject(value) { return missing(value) || Object.keys(value).length === 0; } function get(source, expression, defaultValue) { if (source == null) { return defaultValue; } var keys = expression.split('.'); var objectToRead = source; while (keys.length > 1) { objectToRead = objectToRead[keys.shift()]; if (objectToRead == null) { return defaultValue; } } var value = objectToRead[keys[0]]; return value != null ? value : defaultValue; } function set(target, expression, value) { if (target == null) { return; } var keys = expression.split('.'); var objectToUpdate = target; while (keys.length > 1) { objectToUpdate = objectToUpdate[keys.shift()]; if (objectToUpdate == null) { return; } } objectToUpdate[keys[0]] = value; } function deepFreeze(object) { Object.freeze(object); forEach(values(object), function (v) { if (isNonNullObject(v) || typeof v === 'function') { deepFreeze(v); } }); return object; } function getValueUsingField(data, field, fieldContainsDots) { if (!field || !data) { return; } // if no '.', then it's not a deep value if (!fieldContainsDots) { return data[field]; } // otherwise it is a deep value, so need to dig for it var fields = field.split('.'); var currentObject = data; for (var i = 0; i < fields.length; i++) { if (currentObject == null) { return undefined; } currentObject = currentObject[fields[i]]; } return currentObject; } // used by ColumnAPI and GridAPI to remove all references, so keeping grid in memory resulting in a // memory leak if user is not disposing of the GridAPI or ColumnApi references function removeAllReferences(obj, objectName) { Object.keys(obj).forEach(function (key) { var value = obj[key]; // we want to replace all the @autowired services, which are objects. any simple types (boolean, string etc) // we don't care about if (typeof value === 'object') { obj[key] = undefined; } }); var proto = Object.getPrototypeOf(obj); var properties = {}; Object.keys(proto).forEach(function (key) { var value = proto[key]; // leave all basic types - this is needed for GridAPI to leave the "destroyed: boolean" attribute alone if (typeof value === 'function') { var func = function () { console.warn("ag-Grid: " + objectName + " function " + key + "() cannot be called as the grid has been \ndestroyed. Please don't call grid API functions on destroyed grids - as a matter of fact you \nshouldn't be keeping the API reference, your application has a memory leak! Remove the API reference \nwhen the grid is destroyed."); }; properties[key] = { value: func, writable: true }; } }); Object.defineProperties(obj, properties); } function isNonNullObject(value) { return typeof value === 'object' && value !== null; } var ObjectUtils = /*#__PURE__*/Object.freeze({ __proto__: null, iterateObject: iterateObject, cloneObject: cloneObject, deepCloneObject: deepCloneObject, deepCloneDefinition: deepCloneDefinition, getProperty: getProperty, setProperty: setProperty, copyPropertiesIfPresent: copyPropertiesIfPresent, copyPropertyIfPresent: copyPropertyIfPresent, getAllKeysInObjects: getAllKeysInObjects, getAllValuesInObject: getAllValuesInObject, mergeDeep: mergeDeep, assign: assign, missingOrEmptyObject: missingOrEmptyObject, get: get, set: set, deepFreeze: deepFreeze, getValueUsingField: getValueUsingField, removeAllReferences: removeAllReferences, isNonNullObject: isNonNullObject }); /** * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components * @version v25.0.0 * @link http://www.ag-grid.com/ * @license MIT */ var FUNCTION_STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg; var FUNCTION_ARGUMENT_NAMES = /([^\s,]+)/g; var doOnceFlags = {}; /** * If the key was passed before, then doesn't execute the func * @param {Function} func * @param {string} key */ function doOnce(func, key) { if (doOnceFlags[key]) { return; } func(); doOnceFlags[key] = true; } function getFunctionName(funcConstructor) { // for every other browser in the world if (funcConstructor.name) { return funcConstructor.name; } // for the pestilence that is ie11 var matches = /function\s+([^\(]+)/.exec(funcConstructor.toString()); return matches && matches.length === 2 ? matches[1].trim() : null; } /** @deprecated */ function getFunctionParameters(func) { var fnStr = func.toString().replace(FUNCTION_STRIP_COMMENTS, ''); return fnStr.slice(fnStr.indexOf('(') + 1, fnStr.indexOf(')')).match(FUNCTION_ARGUMENT_NAMES) || []; } function isFunction(val) { return !!(val && val.constructor && val.call && val.apply); } function executeInAWhile(funcs) { executeAfter(funcs, 400); } function executeNextVMTurn(funcs) { executeAfter(funcs, 0); } function executeAfter(funcs, milliseconds) { if (milliseconds === void 0) { milliseconds = 0; } if (funcs.length > 0) { window.setTimeout(function () { return funcs.forEach(function (func) { return func(); }); }, milliseconds); } } /** * from https://stackoverflow.com/questions/24004791/can-someone-explain-the-debounce-function-in-javascript * @param {Function} func The function to be debounced * @param {number} wait The time in ms to debounce * @param {boolean} immediate If it should run immediately or wait for the initial debounce delay * @return {Function} The debounced function */ function debounce(func, wait, immediate) { if (immediate === void 0) { immediate = false; } // 'private' variable for instance // The returned function will be able to reference this due to closure. // Each call to the returned function will share this common timer. var timeout; // Calling debounce returns a new anonymous function return function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } // reference the context and args for the setTimeout function var context = this; // Should the function be called now? If immediate is true // and not already in a timeout then the answer is: Yes var callNow = immediate && !timeout; // This is the basic debounce behaviour where you can call this // function several times, but it will only execute once // [before or after imposing a delay]. // Each time the returned function is called, the timer starts over. window.clearTimeout(timeout); // Set the new timeout timeout = window.setTimeout(function () { // Inside the timeout function, clear the timeout variable // which will let the next execution run when in 'immediate' mode timeout = null; // Check if the function already ran with the immediate flag if (!immediate) { // Call the original function with apply // apply lets you define the 'this' object as well as the arguments // (both captured before setTimeout) func.apply(context, args); } }, wait); // Immediate mode and no wait timer? Execute the function.. if (callNow) { func.apply(context, args); } }; } function compose() { var fns = []; for (var _i = 0; _i < arguments.length; _i++) { fns[_i] = arguments[_i]; } return function (arg) { return fns.reduce(function (composed, f) { return f(composed); }, arg); }; } function callIfPresent(func) { if (func) { func(); } } var FunctionUtils = /*#__PURE__*/Object.freeze({ __proto__: null, doOnce: doOnce, getFunctionName: getFunctionName, getFunctionParameters: getFunctionParameters, isFunction: isFunction, executeInAWhile: executeInAWhile, executeNextVMTurn: executeNextVMTurn, executeAfter: executeAfter, debounce: debounce, compose: compose, callIfPresent: callIfPresent }); /** * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components * @version v25.0.0 * @link http://www.ag-grid.com/ * @license MIT */ var Context = /** @class */ (function () { function Context(params, logger) { this.beanWrappers = {}; this.destroyed = false; if (!params || !params.beanClasses) { return; } this.contextParams = params; this.logger = logger; this.logger.log(">> creating ag-Application Context"); this.createBeans(); var beanInstances = this.getBeanInstances(); this.wireBeans(beanInstances); this.logger.log(">> ag-Application Context ready - component is alive"); } Context.prototype.getBeanInstances = function () { return values(this.beanWrappers).map(function (beanEntry) { return beanEntry.beanInstance; }); }; Context.prototype.createBean = function (bean, afterPreCreateCallback) { if (!bean) { throw Error("Can't wire to bean since it is null"); } this.wireBeans([bean], afterPreCreateCallback); return bean; }; Context.prototype.wireBeans = function (beanInstances, afterPreCreateCallback) { this.autoWireBeans(beanInstances); this.methodWireBeans(beanInstances); this.callLifeCycleMethods(beanInstances, 'preConstructMethods'); // the callback sets the attributes, so the component has access to attributes // before postConstruct methods in the component are executed if (exists(afterPreCreateCallback)) { beanInstances.forEach(afterPreCreateCallback); } this.callLifeCycleMethods(beanInstances, 'postConstructMethods'); }; Context.prototype.createBeans = function () { var _this = this; // register all normal beans this.contextParams.beanClasses.forEach(this.createBeanWrapper.bind(this)); // register override beans, these will overwrite beans above of same name // instantiate all beans - overridden beans will be left out iterateObject(this.beanWrappers, function (key, beanEntry) { var constructorParamsMeta; if (beanEntry.bean.__agBeanMetaData && beanEntry.bean.__agBeanMetaData.autowireMethods && beanEntry.bean.__agBeanMetaData.autowireMethods.agConstructor) { constructorParamsMeta = beanEntry.bean.__agBeanMetaData.autowireMethods.agConstructor; } var constructorParams = _this.getBeansForParameters(constructorParamsMeta, beanEntry.bean.name); var newInstance = applyToConstructor(beanEntry.bean, constructorParams); beanEntry.beanInstance = newInstance; }); var createdBeanNames = Object.keys(this.beanWrappers).join(', '); this.logger.log("created beans: " + createdBeanNames); }; // tslint:disable-next-line Context.prototype.createBeanWrapper = function (Bean) { var metaData = Bean.__agBeanMetaData; if (!metaData) { var beanName = void 0; if (Bean.prototype.constructor) { beanName = getFunctionName(Bean.prototype.constructor); } else { beanName = "" + Bean; } console.error("Context item " + beanName + " is not a bean"); return; } var beanEntry = { bean: Bean, beanInstance: null, beanName: metaData.beanName }; this.beanWrappers[metaData.beanName] = beanEntry; }; Context.prototype.autoWireBeans = function (beanInstances) { var _this = this; beanInstances.forEach(function (beanInstance) { _this.forEachMetaDataInHierarchy(beanInstance, function (metaData, beanName) { var attributes = metaData.agClassAttributes; if (!attributes) { return; } attributes.forEach(function (attribute) { var otherBean = _this.lookupBeanInstance(beanName, attribute.beanName, attribute.optional); beanInstance[attribute.attributeName] = otherBean; }); }); }); }; Context.prototype.methodWireBeans = function (beanInstances) { var _this = this; beanInstances.forEach(function (beanInstance) { _this.forEachMetaDataInHierarchy(beanInstance, function (metaData, beanName) { iterateObject(metaData.autowireMethods, function (methodName, wireParams) { // skip constructor, as this is dealt with elsewhere if (methodName === "agConstructor") { return; } var initParams = _this.getBeansForParameters(wireParams, beanName); beanInstance[methodName].apply(beanInstance, initParams); }); }); }); }; Context.prototype.forEachMetaDataInHierarchy = function (beanInstance, callback) { var prototype = Object.getPrototypeOf(beanInstance); while (prototype != null) { var constructor = prototype.constructor; if (constructor.hasOwnProperty('__agBeanMetaData')) { var metaData = constructor.__agBeanMetaData; var beanName = this.getBeanName(constructor); callback(metaData, beanName); } prototype = Object.getPrototypeOf(prototype); } }; Context.prototype.getBeanName = function (constructor) { if (constructor.__agBeanMetaData && constructor.__agBeanMetaData.beanName) { return constructor.__agBeanMetaData.beanName; } var constructorString = constructor.toString(); var beanName = constructorString.substring(9, constructorString.indexOf("(")); return beanName; }; Context.prototype.getBeansForParameters = function (parameters, beanName) { var _this = this; var beansList = []; if (parameters) { iterateObject(parameters, function (paramIndex, otherBeanName) { var otherBean = _this.lookupBeanInstance(beanName, otherBeanName); beansList[Number(paramIndex)] = otherBean; }); } return beansList; }; Context.prototype.lookupBeanInstance = function (wiringBean, beanName, optional) { if (optional === void 0) { optional = false; } if (beanName === "context") { return this; } if (this.contextParams.providedBeanInstances && this.contextParams.providedBeanInstances.hasOwnProperty(beanName)) { return this.contextParams.providedBeanInstances[beanName]; } var beanEntry = this.beanWrappers[beanName]; if (beanEntry) { return beanEntry.beanInstance; } if (!optional) { console.error("ag-Grid: unable to find bean reference " + beanName + " while initialising " + wiringBean); } return null; }; Context.prototype.callLifeCycleMethods = function (beanInstances, lifeCycleMethod) { var _this = this; beanInstances.forEach(function (beanInstance) { return _this.callLifeCycleMethodsOnBean(beanInstance, lifeCycleMethod); }); }; Context.prototype.callLifeCycleMethodsOnBean = function (beanInstance, lifeCycleMethod, methodToIgnore) { // putting all methods into a map removes duplicates var allMethods = {}; // dump methods from each level of the metadata hierarchy this.forEachMetaDataInHierarchy(beanInstance, function (metaData) { var methods = metaData[lifeCycleMethod]; if (methods) { methods.forEach(function (methodName) { if (methodName != methodToIgnore) { allMethods[methodName] = true; } }); } }); var allMethodsList = Object.keys(allMethods); allMethodsList.forEach(function (methodName) { return beanInstance[methodName](); }); }; Context.prototype.getBean = function (name) { return this.lookupBeanInstance("getBean", name, true); }; Context.prototype.destroy = function () { if (this.destroyed) { return; } this.logger.log(">> Shutting down ag-Application Context"); var beanInstances = this.getBeanInstances(); this.destroyBeans(beanInstances); this.contextParams.providedBeanInstances = null; this.destroyed = true; this.logger.log(">> ag-Application Context shut down - component is dead"); }; Context.prototype.destroyBean = function (bean) { if (!bean) { return; } this.destroyBeans([bean]); }; Context.prototype.destroyBeans = function (beans) { var _this = this; if (!beans) { return []; } beans.forEach(function (bean) { _this.callLifeCycleMethodsOnBean(bean, 'preDestroyMethods', 'destroy'); // call destroy() explicitly if it exists var beanAny = bean; if (typeof beanAny.destroy === 'function') { beanAny.destroy(); } }); return []; }; return Context; }()); // taken from: http://stackoverflow.com/questions/3362471/how-can-i-call-a-javascript-constructor-using-call-or-apply // allows calling 'apply' on a constructor function applyToConstructor(constructor, argArray) { var args = [null].concat(argArray); var factoryFunction = constructor.bind.apply(constructor, args); return new factoryFunction(); } function PreConstruct(target, methodName, descriptor) { var props = getOrCreateProps(target.constructor); if (!props.preConstructMethods) { props.preConstructMethods = []; } props.preConstructMethods.push(methodName); } function PostConstruct(target, methodName, descriptor) { var props = getOrCreateProps(target.constructor); if (!props.postConstructMethods) { props.postConstructMethods = []; } props.postConstructMethods.push(methodName); } function PreDestroy(target, methodName, descriptor) { var props = getOrCreateProps(target.constructor); if (!props.preDestroyMethods) { props.preDestroyMethods = []; } props.preDestroyMethods.push(methodName); } function Bean(beanName) { return function (classConstructor) { var props = getOrCreateProps(classConstructor); props.beanName = beanName; }; } function Autowired(name) { return function (target, propertyKey, descriptor) { autowiredFunc(target, name, false, target, propertyKey, null); }; } function Optional(name) { return function (target, propertyKey, descriptor) { autowiredFunc(target, name, true, target, propertyKey, null); }; } function autowiredFunc(target, name, optional, classPrototype, methodOrAttributeName, index) { if (name === null) { console.error("ag-Grid: Autowired name should not be null"); return; } if (typeof index === "number") { console.error("ag-Grid: Autowired should be on an attribute"); return; } // it's an attribute on the class var props = getOrCreateProps(target.constructor); if (!props.agClassAttributes) { props.agClassAttributes = []; } props.agClassAttributes.push({ attributeName: methodOrAttributeName, beanName: name, optional: optional }); } function Qualifier(name) { return function (classPrototype, methodOrAttributeName, index) { var constructor = typeof classPrototype == "function" ? classPrototype : classPrototype.constructor; var props; if (typeof index === "number") { // it's a parameter on a method var methodName = void 0; if (methodOrAttributeName) { props = getOrCreateProps(constructor); methodName = methodOrAttributeName; } else { props = getOrCreateProps(constructor); methodName = "agConstructor"; } if (!props.autowireMethods) { props.autowireMethods = {}; } if (!props.autowireMethods[methodName]) { props.autowireMethods[methodName] = {}; } props.autowireMethods[methodName][index] = name; } }; } function getOrCreateProps(target) { if (!target.hasOwnProperty("__agBeanMetaData")) { target.__agBeanMetaData = {}; } return target.__agBeanMetaData; } /** * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components * @version v25.0.0 * @link http://www.ag-grid.com/ * @license MIT */ var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __param = (undefined && undefined.__param) || function (paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } }; var EventService = /** @class */ (function () { function EventService() { this.allSyncListeners = new Map(); this.allAsyncListeners = new Map(); this.globalSyncListeners = new Set(); this.globalAsyncListeners = new Set(); this.asyncFunctionsQueue = []; this.scheduled = false; // using an object performs better than a Set for the number of different events we have this.firedEvents = {}; } // because this class is used both inside the context and outside the context, we do not // use autowired attributes, as that would be confusing, as sometimes the attributes // would be wired, and sometimes not. // // the global event servers used by ag-Grid is autowired by the context once, and this // setBeans method gets called once. // // the times when this class is used outside of the context (eg RowNode has an instance of this // class) then it is not a bean, and this setBeans method is not called. EventService.prototype.setBeans = function (loggerFactory, gridOptionsWrapper, globalEventListener, frameworkOverrides) { if (globalEventListener === void 0) { globalEventListener = null; } this.logger = loggerFactory.create('EventService'); this.frameworkOverrides = frameworkOverrides; if (globalEventListener) { var async = gridOptionsWrapper.useAsyncEvents(); this.addGlobalListener(globalEventListener, async); } }; EventService.prototype.getListeners = function (eventType, async) { var listenerMap = async ? this.allAsyncListeners : this.allSyncListeners; var listeners = listenerMap.get(eventType); if (!listeners) { listeners = new Set(); listenerMap.set(eventType, listeners); } return listeners; }; EventService.prototype.addEventListener = function (eventType, listener, async) { if (async === void 0) { async = false; } this.getListeners(eventType, async).add(listener); }; EventService.prototype.removeEventListener = function (eventType, listener, async) { if (async === void 0) { async = false; } this.getListeners(eventType, async).delete(listener); }; EventService.prototype.addGlobalListener = function (listener, async) { if (async === void 0) { async = false; } (async ? this.globalAsyncListeners : this.globalSyncListeners).add(listener); }; EventService.prototype.removeGlobalListener = function (listener, async) { if (async === void 0) { async = false; } (async ? this.globalAsyncListeners : this.globalSyncListeners).delete(listener); }; EventService.prototype.dispatchEvent = function (event) { this.dispatchToListeners(event, true); this.dispatchToListeners(event, false); this.firedEvents[event.type] = true; }; EventService.prototype.dispatchEventOnce = function (event) { if (!this.firedEvents[event.type]) { this.dispatchEvent(event); } }; EventService.prototype.dispatchToListeners = function (event, async) { var _this = this; var eventType = event.type; var processEventListeners = function (listeners) { return listeners.forEach(function (listener) { if (async) { _this.dispatchAsync(function () { return listener(event); }); } else { listener(event); } }); }; processEventListeners(this.getListeners(eventType, async)); var globalListeners = async ? this.globalAsyncListeners : this.globalSyncListeners; globalListeners.forEach(function (listener) { if (async) { _this.dispatchAsync(function () { return _this.frameworkOverrides.dispatchEvent(eventType, function () { return listener(eventType, event); }); }); } else { _this.frameworkOverrides.dispatchEvent(eventType, function () { return listener(eventType, event); }); } }); }; // this gets called inside the grid's thread, for each event that it // wants to set async. the grid then batches the events into one setTimeout() // because setTimeout() is an expensive operation. ideally we would have // each event in it's own setTimeout(), but we batch for performance. EventService.prototype.dispatchAsync = function (func) { // add to the queue for executing later in the next VM turn this.asyncFunctionsQueue.push(func); // check if timeout is already scheduled. the first time the grid calls // this within it's thread turn, this should be false, so it will schedule // the 'flush queue' method the first time it comes here. then the flag is // set to 'true' so it will know it's already scheduled for subsequent calls. if (!this.scheduled) { // if not scheduled, schedule one window.setTimeout(this.flushAsyncQueue.bind(this), 0); // mark that it is scheduled this.scheduled = true; } }; // this happens in the next VM turn only, and empties the queue of events EventService.prototype.flushAsyncQueue = function () { this.scheduled = false; // we take a copy, because the event listener could be using // the grid, which would cause more events, which would be potentially // added to the queue, so safe to take a copy, the new events will // get executed in a later VM turn rather than risk updating the // queue as we are flushing it. var queueCopy = this.asyncFunctionsQueue.slice(); this.asyncFunctionsQueue = []; // execute the queue queueCopy.forEach(function (func) { return func(); }); }; __decorate([ __param(0, Qualifier('loggerFactory')), __param(1, Qualifier('gridOptionsWrapper')), __param(2, Qualifier('globalEventListener')), __param(3, Qualifier('frameworkOverrides')) ], EventService.prototype, "setBeans", null); EventService = __decorate([ Bean('eventService') ], EventService); return EventService; }()); /** * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components * @version v25.0.0 * @link http://www.ag-grid.com/ * @license MIT */ var Constants = /** @class */ (function () { function Constants() { } Constants.STEP_EVERYTHING = 0; Constants.STEP_FILTER = 1; Constants.STEP_SORT = 2; Constants.STEP_MAP = 3; Constants.STEP_AGGREGATE = 4; Constants.STEP_PIVOT = 5; Constants.ROW_BUFFER_SIZE = 10; Constants.LAYOUT_INTERVAL = 500; Constants.BATCH_WAIT_MILLIS = 50; Constants.EXPORT_TYPE_DRAG_COPY = 'dragCopy'; Constants.EXPORT_TYPE_CLIPBOARD = 'clipboard'; Constants.EXPORT_TYPE_EXCEL = 'excel'; Constants.EXPORT_TYPE_CSV = 'csv'; Constants.ROW_MODEL_TYPE_INFINITE = 'infinite'; Constants.ROW_MODEL_TYPE_VIEWPORT = 'viewport'; Constants.ROW_MODEL_TYPE_CLIENT_SIDE = 'clientSide'; Constants.ROW_MODEL_TYPE_SERVER_SIDE = 'serverSide'; Constants.ALWAYS = 'always'; Constants.ONLY_WHEN_GROUPING = 'onlyWhenGrouping'; Constants.PINNED_TOP = 'top'; Constants.PINNED_BOTTOM = 'bottom'; Constants.DOM_LAYOUT_NORMAL = 'normal'; Constants.DOM_LAYOUT_PRINT = 'print'; Constants.DOM_LAYOUT_AUTO_HEIGHT = 'autoHeight'; Constants.GROUP_AUTO_COLUMN_ID = 'ag-Grid-AutoColumn'; Constants.SOURCE_PASTE = 'paste'; Constants.PINNED_RIGHT = 'right'; Constants.PINNED_LEFT = 'left'; Constants.SORT_ASC = 'asc'; Constants.SORT_DESC = 'desc'; Constants.INPUT_SELECTOR = 'input, select, button, textarea'; Constants.FOCUSABLE_SELECTOR = '[tabindex], input, select, button, textarea'; Constants.FOCUSABLE_EXCLUDE = '.ag-hidden, .ag-hidden *, [disabled], .ag-disabled, .ag-disabled *'; return Constants; }()); /** * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components * @version v25.0.0 * @link http://www.ag-grid.com/ * @license MIT */ (function (ModuleNames) { // when using modules, user references this ModuleNames["CommunityCoreModule"] = "@ag-grid-community/core"; // when not using modules, user references this ModuleNames["CommunityAllModules"] = "@ag-grid-community/all"; // community modules ModuleNames["InfiniteRowModelModule"] = "@ag-grid-community/infinite-row-model"; ModuleNames["ClientSideRowModelModule"] = "@ag-grid-community/client-side-row-model"; ModuleNames["CsvExportModule"] = "@ag-grid-community/csv-export"; ModuleNames["RowNodeCache"] = "@ag-grid-community/row-node-cache"; // enterprise core - users never import on this, but other enterprise modules do ModuleNames["EnterpriseCoreModule"] = "@ag-grid-enterprise/core"; // when not using modules, user references this ModuleNames["EnterpriseAllModules"] = "@ag-grid-enterprise/all"; // enterprise modules ModuleNames["RowGroupingModule"] = "@ag-grid-enterprise/row-grouping"; ModuleNames["ColumnToolPanelModule"] = "@ag-grid-enterprise/column-tool-panel"; ModuleNames["FiltersToolPanelModule"] = "@ag-grid-enterprise/filter-tool-panel"; ModuleNames["MenuModule"] = "@ag-grid-enterprise/menu"; ModuleNames["SetFilterModule"] = "@ag-grid-enterprise/set-filter"; ModuleNames["MultiFilterModule"] = "@ag-grid-enterprise/multi-filter"; ModuleNames["StatusBarModule"] = "@ag-grid-enterprise/status-bar"; ModuleNames["SideBarModule"] = "@ag-grid-enterprise/side-bar"; ModuleNames["RangeSelectionModule"] = "@ag-grid-enterprise/range-selection"; ModuleNames["MasterDetailModule"] = "@ag-grid-enterprise/master-detail"; ModuleNames["RichSelectModule"] = "@ag-grid-enterprise/rich-select"; ModuleNames["GridChartsModule"] = "@ag-grid-enterprise/charts"; ModuleNames["ViewportRowModelModule"] = "@ag-grid-enterprise/viewport-row-model"; ModuleNames["ServerSideRowModelModule"] = "@ag-grid-enterprise/server-side-row-model"; ModuleNames["ExcelExportModule"] = "@ag-grid-enterprise/excel-export"; ModuleNames["ClipboardModule"] = "@ag-grid-enterprise/clipboard"; ModuleNames["DateTimeCellEditorModule"] = "@ag-grid-enterprise/date-time-cell-editor"; // framework wrappers currently don't provide beans, comps etc, so no need to be modules, // however i argue they should be as in theory they 'could' provide beans etc ModuleNames["AngularModule"] = "@ag-grid-community/angular"; ModuleNames["ReactModule"] = "@ag-grid-community/react"; ModuleNames["VueModule"] = "@ag-grid-community/vue"; ModuleNames["PolymerModule"] = "@ag-grid-community/polymer"; // and then this, which is definitely not a grid module, as it should not have any dependency // on the grid (ie shouldn't even reference the Module interface) // ChartsModule = "@ag-grid-community/charts-core", })(exports.ModuleNames || (exports.ModuleNames = {})); /** * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components * @version v25.0.0 * @link http://www.ag-grid.com/ * @license MIT */ var ModuleRegistry = /** @class */ (function () { function ModuleRegistry() { } ModuleRegistry.register = function (module, moduleBased) { if (moduleBased === void 0) { moduleBased = true; } ModuleRegistry.modulesMap[module.moduleName] = module; if (ModuleRegistry.moduleBased === undefined) { ModuleRegistry.moduleBased = moduleBased; } else { if (ModuleRegistry.moduleBased !== moduleBased) { doOnce(function () { console.warn("ag-Grid: You are mixing modules (i.e. @ag-grid-community/core) and packages (ag-grid-community) - you can only use one or the other of these mechanisms."); console.warn('Please see https://www.ag-grid.com/documentation/javascript/packages-modules/ for more information.'); }, 'ModulePackageCheck'); } } }; // noinspection JSUnusedGlobalSymbols ModuleRegistry.registerModules = function (modules, moduleBased) { if (moduleBased === void 0) { moduleBased = true; } if (!modules) { return; } modules.forEach(function (module) { return ModuleRegistry.register(module, moduleBased); }); }; ModuleRegistry.assertRegistered = function (moduleName, reason) { if (this.isRegistered(moduleName)) { return true; } var warningKey = reason + moduleName; var warningMessage = "ag-Grid: unable to use " + reason + " as module " + moduleName + " is not present. Please see: https://www.ag-grid.com/documentation/javascript/modules/"; doOnce(function () { console.warn(warningMessage); }, warningKey); return false; }; ModuleRegistry.isRegistered = function (moduleName) { return !!ModuleRegistry.modulesMap[moduleName]; }; ModuleRegistry.getRegisteredModules = function () { return values(ModuleRegistry.modulesMap); }; ModuleRegistry.isPackageBased = function () { return !ModuleRegistry.moduleBased; }; // having in a map a) removes duplicates and b) allows fast lookup ModuleRegistry.modulesMap = {}; return ModuleRegistry; }()); /** * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components * @version v25.0.0 * @link http://www.ag-grid.com/ * @license MIT */ var __decorate$1 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; // Wrapper around a user provide column definition. The grid treats the column definition as ready only. // This class contains all the runtime information about a column, plus some logic (the definition has no logic). // This class implements both interfaces ColumnGroupChild and OriginalColumnGroupChild as the class can // appear as a child of either the original tree or the displayed tree. However the relevant group classes // for each type only implements one, as each group can only appear in it's associated tree (eg OriginalColumnGroup // can only appear in OriginalColumn tree). var Column = /** @class */ (function () { function Column(colDef, userProvidedColDef, colId, primary) { this.moving = false; this.menuVisible = false; this.filterActive = false; this.eventService = new EventService(); this.rowGroupActive = false; this.pivotActive = false; this.aggregationActive = false; this.colDef = colDef; this.userProvidedColDef = userProvidedColDef; this.colId = colId; this.primary = primary; this.setState(colDef); } Column.prototype.setState = function (colDef) { // sort if (colDef.sort !== undefined) { if (colDef.sort === Constants.SORT_ASC || colDef.sort === Constants.SORT_DESC) { this.sort = colDef.sort; } } else { if (colDef.initialSort === Constants.SORT_ASC || colDef.initialSort === Constants.SORT_DESC) { this.sort = colDef.initialSort; } } // sortIndex var sortIndex = attrToNumber(colDef.sortIndex); var initialSortIndex = attrToNumber(colDef.initialSortIndex); if (sortIndex !== undefined) { if (sortIndex !== null) { this.sortIndex = sortIndex; } } else { if (initialSortIndex !== null) { this.sortIndex = initialSortIndex; } } // hide var hide = attrToBoolean(colDef.hide); var initialHide = attrToBoolean(colDef.initialHide); if (hide !== undefined) { this.visible = !hide; } else { this.visible = !initialHide; } // pinned if (colDef.pinned !== undefined) { this.setPinned(colDef.pinned); } else { this.setPinned(colDef.initialPinned); } // flex var flex = attrToNumber(colDef.flex); var initialFlex = attrToNumber(colDef.initialFlex); if (flex !== undefined) { this.flex = flex; } else if (initialFlex !== undefined) { this.flex = initialFlex; } }; // gets called when user provides an alternative colDef, eg Column.prototype.setColDef = function (colDef, userProvidedColDef) { this.colDef = colDef; this.userProvidedColDef = userProvidedColDef; }; Column.prototype.getUserProvidedColDef = function () { return this.userProvidedColDef; }; Column.prototype.setParent = function (parent) { this.parent = parent; }; Column.prototype.getParent = function () { return this.parent; }; Column.prototype.setOriginalParent = function (originalParent) { this.originalParent = originalParent; }; Column.prototype.getOriginalParent = function () { return this.originalParent; }; // this is done after constructor as it uses gridOptionsWrapper Column.prototype.initialise = function () { var minColWidth = this.gridOptionsWrapper.getMinColWidth(); var maxColWidth = this.gridOptionsWrapper.getMaxColWidth(); if (this.colDef.minWidth != null) { // we force min width to be at least one pixel, otherwise column will disappear this.minWidth = Math.max(this.colDef.minWidth, 1); } else { this.minWidth = minColWidth; } if (this.colDef.maxWidth != null) { this.maxWidth = this.colDef.maxWidth; } else { this.maxWidth = maxColWidth; } this.resetActualWidth('gridInitializing'); var suppressDotNotation = this.gridOptionsWrapper.isSuppressFieldDotNotation(); this.fieldContainsDots = exists(this.colDef.field) && this.colDef.field.indexOf('.') >= 0 && !suppressDotNotation; this.tooltipFieldContainsDots = exists(this.colDef.tooltipField) && this.colDef.tooltipField.indexOf('.') >= 0 && !suppressDotNotation; this.validate(); }; Column.prototype.resetActualWidth = function (source) { if (source === void 0) { source = 'api'; } var initialWidth = this.columnUtils.calculateColInitialWidth(this.colDef); this.setActualWidth(initialWidth, source, true); }; Column.prototype.isEmptyGroup = function () { return false; }; Column.prototype.isRowGroupDisplayed = function (colId) { if (missing(this.colDef) || missing(this.colDef.showRowGroup)) { return false; } var showingAllGroups = this.colDef.showRowGroup === true; var showingThisGroup = this.colDef.showRowGroup === colId; return showingAllGroups || showingThisGroup; }; Column.prototype.getUniqueId = function () { return this.getId(); }; Column.prototype.isPrimary = function () { return this.primary; }; Column.prototype.isFilterAllowed = function () { // filter defined means it's a string, class or true. // if its false, null or undefined then it's false. var filterDefined = !!this.colDef.filter || !!this.colDef.filterFramework; return this.primary && filterDefined; }; Column.prototype.isFieldContainsDots = function () { return this.fieldContainsDots; }; Column.prototype.isTooltipFieldContainsDots = function () { return this.tooltipFieldContainsDots; }; Column.prototype.validate = function () { var colDefAny = this.colDef; function warnOnce(msg, key, obj) { doOnce(function () { if (obj) { console.warn(msg, obj); } else { doOnce(function () { return console.warn(msg); }, key); } }, key); } if (!ModuleRegistry.isRegistered(exports.ModuleNames.RowGroupingModule)) { var rowGroupingItems = ['enableRowGroup', 'rowGroup', 'rowGroupIndex', 'enablePivot', 'enableValue', 'pivot', 'pivotIndex', 'aggFunc']; rowGroupingItems.forEach(function (item) { if (exists(colDefAny[item])) { if (ModuleRegistry.isPackageBased()) { warnOnce("ag-Grid: " + item + " is only valid in ag-grid-enterprise, your column definition should not have " + item, 'ColumnRowGroupingMissing' + item); } else { warnOnce("ag-Grid: " + item + " is only valid with ag-Grid Enterprise Module " + exports.ModuleNames.RowGroupingModule + " - your column definition should not have " + item, 'ColumnRowGroupingMissing' + item); } } }); } if (!ModuleRegistry.isRegistered(exports.ModuleNames.RichSelectModule)) { if (this.colDef.cellEditor === 'agRichSelect' || this.colDef.cellEditor === 'agRichSelectCellEditor') { if (ModuleRegistry.isPackageBased()) { warnOnce("ag-Grid: " + this.colDef.cellEditor + " can only be used with ag-grid-enterprise", 'ColumnRichSelectMissing'); } else { warnOnce("ag-Grid: " + this.colDef.cellEditor + " can only be used with ag-Grid Enterprise Module " + exports.ModuleNames.RichSelectModule, 'ColumnRichSelectMissing'); } } } if (!ModuleRegistry.isRegistered(exports.ModuleNames.DateTimeCellEditorModule)) { if (this.colDef.cellEditor === 'agRichSelect' || this.colDef.cellEditor === 'agDateTimeCellEditor') { if (ModuleRegistry.isPackageBased()) { warnOnce("ag-Grid: " + this.colDef.cellEditor + " can only be used with ag-grid-enterprise", 'ColumnDateTimeMissing'); } else { warnOnce("ag-Grid: " + this.colDef.cellEditor + " can only be used with ag-Grid Enterprise Module " + exports.ModuleNames.DateTimeCellEditorModule, 'ColumnDateTimeMissing'); } } } if (this.gridOptionsWrapper.isTreeData()) { var itemsNotAllowedWithTreeData = ['rowGroup', 'rowGroupIndex', 'pivot', 'pivotIndex']; itemsNotAllowedWithTreeData.forEach(function (item) { if (exists(colDefAny[item])) { warnOnce("ag-Grid: " + item + " is not possible when doing tree data, your column definition should not have " + item, 'TreeDataCannotRowGroup'); } }); } if (exists(this.colDef.width) && typeof this.colDef.width !== 'number') { warnOnce('ag-Grid: colDef.width should be a number, not ' + typeof this.colDef.width, 'ColumnCheck_asdfawef'); } }; Column.prototype.addEventListener = function (eventType, listener) { this.eventService.addEventListener(eventType, listener); }; Column.prototype.removeEventListener = function (eventType, listener) { this.eventService.removeEventListener(eventType, listener); }; Column.prototype.createIsColumnFuncParams = function (rowNode) { return { node: rowNode, data: rowNode.data, column: this, colDef: this.colDef, context: this.gridOptionsWrapper.getContext(), api: this.gridOptionsWrapper.getApi(), columnApi: this.gridOptionsWrapper.getColumnApi() }; }; Column.prototype.isSuppressNavigable = function (rowNode) { // if boolean set, then just use it if (typeof this.colDef.suppressNavigable === 'boolean') { return this.colDef.suppressNavigable; } // if function, then call the function to find out if (typeof this.colDef.suppressNavigable === 'function') { var params = this.createIsColumnFuncParams(rowNode); var userFunc = this.colDef.suppressNavigable; return userFunc(params); } return false; }; Column.prototype.isCellEditable = function (rowNode) { // only allow editing of groups if the user has this option enabled if (rowNode.group && !this.gridOptionsWrapper.isEnableGroupEdit()) { return false; } return this.isColumnFunc(rowNode, this.colDef.editable); }; Column.prototype.isRowDrag = function (rowNode) { return this.isColumnFunc(rowNode, this.colDef.rowDrag); }; Column.prototype.isDndSource = function (rowNode) { return this.isColumnFunc(rowNode, this.colDef.dndSource); }; Column.prototype.isCellCheckboxSelection = function (rowNode) { return this.isColumnFunc(rowNode, this.colDef.checkboxSelection); }; Column.prototype.isSuppressPaste = function (rowNode) { return this.isColumnFunc(rowNode, this.colDef ? this.colDef.suppressPaste : null); }; Column.prototype.isResizable = function () { return this.colDef.resizable === true; }; Column.prototype.isColumnFunc = function (rowNode, value) { // if boolean set, then just use it if (typeof value === 'boolean') { return value; } // if function, then call the function to find out if (typeof value === 'function') { var params = this.createIsColumnFuncParams(rowNode); var editableFunc = value; return editableFunc(params); } return false; }; Column.prototype.setMoving = function (moving, source) { if (source === void 0) { source = "api"; } this.moving = moving; this.eventService.dispatchEvent(this.createColumnEvent(Column.EVENT_MOVING_CHANGED, source)); }; Column.prototype.createColumnEvent = function (type, source) { return { api: this.gridApi, columnApi: this.columnApi, type: type, column: this, columns: [this], source: source }; }; Column.prototype.isMoving = function () { return this.moving; }; Column.prototype.getSort = function () { return this.sort; }; Column.prototype.setSort = function (sort, source) { if (source === void 0) { source = "api"; } if (this.sort !== sort) { this.sort = sort; this.eventService.dispatchEvent(this.createColumnEvent(Column.EVENT_SORT_CHANGED, source)); } }; Column.prototype.setMenuVisible = function (visible, source) { if (source === void 0) { source = "api"; } if (this.menuVisible !== visible) { this.menuVisible = visible; this.eventService.dispatchEvent(this.createColumnEvent(Column.EVENT_MENU_VISIBLE_CHANGED, source)); } }; Column.prototype.isMenuVisible = function () { return this.menuVisible; }; Column.prototype.isSortAscending = function () { return this.sort === Constants.SORT_ASC; }; Column.prototype.isSortDescending = function () { return this.sort === Constants.SORT_DESC; }; Column.prototype.isSortNone = function () { return missing(this.sort); }; Column.prototype.isSorting = function () { return exists(this.sort); }; Column.prototype.getSortIndex = function () { return this.sortIndex; }; Column.prototype.setSortIndex = function (sortOrder) { this.sortIndex = sortOrder; }; Column.prototype.setAggFunc = function (aggFunc) { this.aggFunc = aggFunc; }; Column.prototype.getAggFunc = function () { return this.aggFunc; }; Column.prototype.getLeft = function () { return this.left; }; Column.prototype.getOldLeft = function () { return this.oldLeft; }; Column.prototype.getRight = function () { return this.left + this.actualWidth; }; Column.prototype.setLeft = function (left, source) { if (source === void 0) { source = "api"; } this.oldLeft = this.left; if (this.left !== left) { this.left = left; this.eventService.dispatchEvent(this.createColumnEvent(Column.EVENT_LEFT_CHANGED, source)); } }; Column.prototype.isFilterActive = function () { return this.filterActive; }; // additionalEventAttributes is used by provided simple floating filter, so it can add 'floatingFilter=true' to the event Column.prototype.setFilterActive = function (active, source, additionalEventAttributes) { if (source === void 0) { source = "api"; } if (this.filterActive !== active) { this.filterActive = active; this.eventService.dispatchEvent(this.createColumnEvent(Column.EVENT_FILTER_ACTIVE_CHANGED, source)); } var filterChangedEvent = this.createColumnEvent(Column.EVENT_FILTER_CHANGED, source); if (additionalEventAttributes) { mergeDeep(filterChangedEvent, additionalEventAttributes); } this.eventService.dispatchEvent(filterChangedEvent); }; Column.prototype.setPinned = function (pinned) { if (pinned === true || pinned === Constants.PINNED_LEFT) { this.pinned = Constants.PINNED_LEFT; } else if (pinned === Constants.PINNED_RIGHT) { this.pinned = Constants.PINNED_RIGHT; } else { this.pinned = null; } }; Column.prototype.setFirstRightPinned = function (firstRightPinned, source) { if (source === void 0) { source = "api"; } if (this.firstRightPinned !== firstRightPinned) { this.firstRightPinned = firstRightPinned; this.eventService.dispatchEvent(this.createColumnEvent(Column.EVENT_FIRST_RIGHT_PINNED_CHANGED, source)); } }; Column.prototype.setLastLeftPinned = function (lastLeftPinned, source) { if (source === void 0) { source = "api"; } if (this.lastLeftPinned !== lastLeftPinned) { this.lastLeftPinned = lastLeftPinned; this.eventService.dispatchEvent(this.createColumnEvent(Column.EVENT_LAST_LEFT_PINNED_CHANGED, source)); } }; Column.prototype.isFirstRightPinned = function () { return this.firstRightPinned; }; Column.prototype.isLastLeftPinned = function () { return this.lastLeftPinned; }; Column.prototype.isPinned = function () { return this.pinned === Constants.PINNED_LEFT || this.pinned === Constants.PINNED_RIGHT; }; Column.prototype.isPinnedLeft = function () { return this.pinned === Constants.PINNED_LEFT; }; Column.prototype.isPinnedRight = function () { return this.pinned === Constants.PINNED_RIGHT; }; Column.prototype.getPinned = function () { return this.pinned; }; Column.prototype.setVisible = function (visible, source) { if (source === void 0) { source = "api"; } var newValue = visible === true; if (this.visible !== newValue) { this.visible = newValue; this.eventService.dispatchEvent(this.createColumnEvent(Column.EVENT_VISIBLE_CHANGED, source)); } }; Column.prototype.isVisible = function () { return this.visible; }; Column.prototype.getColDef = function () { return this.colDef; }; Column.prototype.getColumnGroupShow = function () { return this.colDef.columnGroupShow; }; Column.prototype.getColId = function () { return this.colId; }; Column.prototype.getId = function () { return this.getColId(); }; Column.prototype.getDefinition = function () { return this.colDef; }; Column.prototype.getActualWidth = function () { return this.actualWidth; }; Column.prototype.createBaseColDefParams = function (rowNode) { var params = { node: rowNode, data: rowNode.data, colDef: this.colDef, column: this, api: this.gridOptionsWrapper.getApi(), columnApi: this.gridOptionsWrapper.getColumnApi(), context: this.gridOptionsWrapper.getContext() }; return params; }; Column.prototype.getColSpan = function (rowNode) { if (missing(this.colDef.colSpan)) { return 1; } var params = this.createBaseColDefParams(rowNode); var colSpan = this.colDef.colSpan(params); // colSpan must be number equal to or greater than 1 return Math.max(colSpan, 1); }; Column.prototype.getRowSpan = function (rowNode) { if (missing(this.colDef.rowSpan)) { return 1; } var params = this.createBaseColDefParams(rowNode); var rowSpan = this.colDef.rowSpan(params); // rowSpan must be number equal to or greater than 1 return Math.max(rowSpan, 1); }; Column.prototype.setActualWidth = function (actualWidth, source, silent) { if (source === void 0) { source = "api"; } if (silent === void 0) { silent = false; } if (this.minWidth != null) { actualWidth = Math.max(actualWidth, this.minWidth); } if (this.maxWidth != null) { actualWidth = Math.min(actualWidth, this.maxWidth); } if (this.actualWidth !== actualWidth) { // disable flex for this column if it was manually resized. this.actualWidth = actualWidth; if (this.flex && source !== 'flex' && source !== 'gridInitializing') { this.flex = null; } if (!silent) { this.fireColumnWidthChangedEvent(source); } } }; Column.prototype.fireColumnWidthChangedEvent = function (source) { this.eventService.dispatchEvent(this.createColumnEvent(Column.EVENT_WIDTH_CHANGED, source)); }; Column.prototype.isGreaterThanMax = function (width) { if (this.maxWidth != null) { return width > this.maxWidth; } return false; }; Column.prototype.getMinWidth = function () { return this.minWidth; }; Column.prototype.getMaxWidth = function () { return this.maxWidth; }; Column.prototype.getFlex = function () { return this.flex || 0; }; // this method should only be used by the columnController to // change flex when required by the setColumnState method. Column.prototype.setFlex = function (flex) { if (this.flex !== flex) { this.flex = flex; } }; Column.prototype.setMinimum = function (source) { if (source === void 0) { source = "api"; } this.setActualWidth(this.minWidth, source); }; Column.prototype.setRowGroupActive = function (rowGroup, source) { if (source === void 0) { source = "api"; } if (this.rowGroupActive !== rowGroup) { this.rowGroupActive = rowGroup; this.eventService.dispatchEvent(this.createColumnEvent(Column.EVENT_ROW_GROUP_CHANGED, source)); } }; Column.prototype.isRowGroupActive = function () { return this.rowGroupActive; }; Column.prototype.setPivotActive = function (pivot, source) { if (source === void 0) { source = "api"; } if (this.pivotActive !== pivot) { this.pivotActive = pivot; this.eventService.dispatchEvent(this.createColumnEvent(Column.EVENT_PIVOT_CHANGED, source)); } }; Column.prototype.isPivotActive = function () { return this.pivotActive; }; Column.prototype.isAnyFunctionActive = function () { return this.isPivotActive() || this.isRowGroupActive() || this.isValueActive(); }; Column.prototype.isAnyFunctionAllowed = function () { return this.isAllowPivot() || this.isAllowRowGroup() || this.isAllowValue(); }; Column.prototype.setValueActive = function (value, source) { if (source === void 0) { source = "api"; } if (this.aggregationActive !== value) { this.aggregationActive = value; this.eventService.dispatchEvent(this.createColumnEvent(Column.EVENT_VALUE_CHANGED, source)); } }; Column.prototype.isValueActive = function () { return this.aggregationActive; }; Column.prototype.isAllowPivot = function () { return this.colDef.enablePivot === true; }; Column.prototype.isAllowValue = function () { return this.colDef.enableValue === true; }; Column.prototype.isAllowRowGroup = function () { return this.colDef.enableRowGroup === true; }; Column.prototype.getMenuTabs = function (defaultValues) { var menuTabs = this.getColDef().menuTabs; if (menuTabs == null) { menuTabs = defaultValues; } return menuTabs; }; // this used to be needed, as previous version of ag-grid had lockPosition as column state, // so couldn't depend on colDef version. Column.prototype.isLockPosition = function () { console.warn('ag-Grid: since v21, col.isLockPosition() should not be used, please use col.getColDef().lockPosition instead.'); return this.colDef ? !!this.colDef.lockPosition : false; }; // this used to be needed, as previous version of ag-grid had lockVisible as column state, // so couldn't depend on colDef version. Column.prototype.isLockVisible = function () { console.warn('ag-Grid: since v21, col.isLockVisible() should not be used, please use col.getColDef().lockVisible instead.'); return this.colDef ? !!this.colDef.lockVisible : false; }; // this used to be needed, as previous version of ag-grid had lockPinned as column state, // so couldn't depend on colDef version. Column.prototype.isLockPinned = function () { console.warn('ag-Grid: since v21, col.isLockPinned() should not be used, please use col.getColDef().lockPinned instead.'); return this.colDef ? !!this.colDef.lockPinned : false; }; // + renderedHeaderCell - for making header cell transparent when moving Column.EVENT_MOVING_CHANGED = 'movingChanged'; // + renderedCell - changing left position Column.EVENT_LEFT_CHANGED = 'leftChanged'; // + renderedCell - changing width Column.EVENT_WIDTH_CHANGED = 'widthChanged'; // + renderedCell - for changing pinned classes Column.EVENT_LAST_LEFT_PINNED_CHANGED = 'lastLeftPinnedChanged'; Column.EVENT_FIRST_RIGHT_PINNED_CHANGED = 'firstRightPinnedChanged'; // + renderedColumn - for changing visibility icon Column.EVENT_VISIBLE_CHANGED = 'visibleChanged'; // + every time the filter changes, used in the floating filters Column.EVENT_FILTER_CHANGED = 'filterChanged'; // + renderedHeaderCell - marks the header with filter icon Column.EVENT_FILTER_ACTIVE_CHANGED = 'filterActiveChanged'; // + renderedHeaderCell - marks the header with sort icon Column.EVENT_SORT_CHANGED = 'sortChanged'; Column.EVENT_MENU_VISIBLE_CHANGED = 'menuVisibleChanged'; // + toolpanel, for gui updates Column.EVENT_ROW_GROUP_CHANGED = 'columnRowGroupChanged'; // + toolpanel, for gui updates Column.EVENT_PIVOT_CHANGED = 'columnPivotChanged'; // + toolpanel, for gui updates Column.EVENT_VALUE_CHANGED = 'columnValueChanged'; __decorate$1([ Autowired('gridOptionsWrapper') ], Column.prototype, "gridOptionsWrapper", void 0); __decorate$1([ Autowired('columnUtils') ], Column.prototype, "columnUtils", void 0); __decorate$1([ Autowired('columnApi') ], Column.prototype, "columnApi", void 0); __decorate$1([ Autowired('gridApi') ], Column.prototype, "gridApi", void 0); __decorate$1([ Autowired('context') ], Column.prototype, "context", void 0); __decorate$1([ PostConstruct ], Column.prototype, "initialise", null); return Column; }()); /** * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components * @version v25.0.0 * @link http://www.ag-grid.com/ * @license MIT */ var __decorate$2 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var ColumnGroup = /** @class */ (function () { function ColumnGroup(originalColumnGroup, groupId, instanceId, pinned) { // depends on the open/closed state of the group, only displaying columns are stored here this.displayedChildren = []; this.localEventService = new EventService(); this.groupId = groupId; this.instanceId = instanceId; this.originalColumnGroup = originalColumnGroup; this.pinned = pinned; } // this is static, a it is used outside of this class ColumnGroup.createUniqueId = function (groupId, instanceId) { return groupId + '_' + instanceId; }; // as the user is adding and removing columns, the groups are recalculated. // this reset clears out all children, ready for children to be added again ColumnGroup.prototype.reset = function () { this.parent = null; this.children = null; this.displayedChildren = null; }; ColumnGroup.prototype.getParent = function () { return this.parent; }; ColumnGroup.prototype.setParent = function (parent) { this.parent = parent; }; ColumnGroup.prototype.getUniqueId = function () { return ColumnGroup.createUniqueId(this.groupId, this.instanceId); }; ColumnGroup.prototype.isEmptyGroup = function () { return this.displayedChildren.length === 0; }; ColumnGroup.prototype.isMoving = function () { var allLeafColumns = this.getOriginalColumnGroup().getLeafColumns(); if (!allLeafColumns || allLeafColumns.length === 0) { return false; } return allLeafColumns.every(function (col) { return col.isMoving(); }); }; ColumnGroup.prototype.checkLeft = function () { // first get all children to setLeft, as it impacts our decision below this.displayedChildren.forEach(function (child) { if (child instanceof ColumnGroup) { child.checkLeft(); } }); // set our left based on first displayed column if (this.displayedChildren.length > 0) { if (this.gridOptionsWrapper.isEnableRtl()) { var lastChild = last(this.displayedChildren); var lastChildLeft = lastChild.getLeft(); this.setLeft(lastChildLeft); } else { var firstChildLeft = this.displayedChildren[0].getLeft(); this.setLeft(firstChildLeft); } } else { // this should never happen, as if we have no displayed columns, then // this groups should not even exist. this.setLeft(null); } }; ColumnGroup.prototype.getLeft = function () { return this.left; }; ColumnGroup.prototype.getOldLeft = function () { return this.oldLeft; }; ColumnGroup.prototype.setLeft = function (left) { this.oldLeft = left; if (this.left !== left) { this.left = left; this.localEventService.dispatchEvent(this.createAgEvent(ColumnGroup.EVENT_LEFT_CHANGED)); } }; ColumnGroup.prototype.getPinned = function () { return this.pinned; }; ColumnGroup.prototype.createAgEvent = function (type) { return { type: type }; }; ColumnGroup.prototype.addEventListener = function (eventType, listener) { this.localEventService.addEventListener(eventType, listener); }; ColumnGroup.prototype.removeEventListener = function (eventType, listener) { this.localEventService.removeEventListener(eventType, listener); }; ColumnGroup.prototype.getGroupId = function () { return this.groupId; }; ColumnGroup.prototype.getInstanceId = function () { return this.instanceId; }; ColumnGroup.prototype.isChildInThisGroupDeepSearch = function (wantedChild) { var result = false; this.children.forEach(function (foundChild) { if (wantedChild === foundChild) { result = true; } if (foundChild instanceof ColumnGroup) { if (foundChild.isChildInThisGroupDeepSearch(wantedChild)) { result = true; } } }); return result; }; ColumnGroup.prototype.getActualWidth = function () { var groupActualWidth = 0; if (this.displayedChildren) { this.displayedChildren.forEach(function (child) { groupActualWidth += child.getActualWidth(); }); } return groupActualWidth; }; ColumnGroup.prototype.isResizable = function () { if (!this.displayedChildren) { return false; } // if at least one child is resizable, then the group is resizable var result = false; this.displayedChildren.forEach(function (child) { if (child.isResizable()) { result = true; } }); return result; }; ColumnGroup.prototype.getMinWidth = function () { var result = 0; this.displayedChildren.forEach(function (groupChild) { result += groupChild.getMinWidth(); }); return result; }; ColumnGroup.prototype.addChild = function (child) { if (!this.children) { this.children = []; } this.children.push(child); }; ColumnGroup.prototype.getDisplayedChildren = function () { return this.displayedChildren; }; ColumnGroup.prototype.getLeafColumns = function () { var result = []; this.addLeafColumns(result); return result; }; ColumnGroup.prototype.getDisplayedLeafColumns = function () { var result = []; this.addDisplayedLeafColumns(result); return result; }; // why two methods here doing the same thing? ColumnGroup.prototype.getDefinition = function () { return this.originalColumnGroup.getColGroupDef(); }; ColumnGroup.prototype.getColGroupDef = function () { return this.originalColumnGroup.getColGroupDef(); }; ColumnGroup.prototype.isPadding = function () { return this.originalColumnGroup.isPadding(); }; ColumnGroup.prototype.isExpandable = function () { return this.originalColumnGroup.isExpandable(); }; ColumnGroup.prototype.isExpanded = function () { return this.originalColumnGroup.isExpanded(); }; ColumnGroup.prototype.setExpanded = function (expanded) { this.originalColumnGroup.setExpanded(expanded); }; ColumnGroup.prototype.addDisplayedLeafColumns = function (leafColumns) { this.displayedChildren.forEach(function (child) { if (child instanceof Column) { leafColumns.push(child); } else if (child instanceof ColumnGroup) { child.addDisplayedLeafColumns(leafColumns); } }); }; ColumnGroup.prototype.addLeafColumns = function (leafColumns) { this.children.forEach(function (child) { if (child instanceof Column) { leafColumns.push(child); } else if (child instanceof ColumnGroup) { child.addLeafColumns(leafColumns); } }); }; ColumnGroup.prototype.getChildren = function () { return this.children; }; ColumnGroup.prototype.getColumnGroupShow = function () { return this.originalColumnGroup.getColumnGroupShow(); }; ColumnGroup.prototype.getOriginalColumnGroup = function () { return this.originalColumnGroup; }; ColumnGroup.prototype.getPaddingLevel = function () { var parent = this.getParent(); if (!this.isPadding() || !parent || !parent.isPadding()) { return 0; } return 1 + parent.getPaddingLevel(); }; ColumnGroup.prototype.calculateDisplayedColumns = function () { var _this = this; // clear out last time we calculated this.displayedChildren = []; var topLevelGroup = this; // find the column group that is controlling expandable. this is relevant when we have padding (empty) // groups, where the expandable is actually the first parent that is not a padding group. if (this.isPadding()) { while (topLevelGroup.getParent() && topLevelGroup.isPadding()) { topLevelGroup = topLevelGroup.getParent(); } } var isExpandable = topLevelGroup.originalColumnGroup.isExpandable(); // it not expandable, everything is visible if (!isExpandable) { this.displayedChildren = this.children; } else { // Add cols based on columnGroupShow // Note - the below also adds padding groups, these are always added because they never have // colDef.columnGroupShow set. this.children.forEach(function (abstractColumn) { var headerGroupShow = abstractColumn.getColumnGroupShow(); switch (headerGroupShow) { case ColumnGroup.HEADER_GROUP_SHOW_OPEN: // when set to open, only show col if group is open if (topLevelGroup.originalColumnGroup.isExpanded()) { _this.displayedChildren.push(abstractColumn); } break; case ColumnGroup.HEADER_GROUP_SHOW_CLOSED: // when set to open, only show col if group is open if (!topLevelGroup.originalColumnGroup.isExpanded()) { _this.displayedChildren.push(abstractColumn); } break; default: // if this abstractColumn is padding, we just want to add it // to the displayedChildren list if it has displayedChildren itself. if (!(abstractColumn instanceof ColumnGroup && abstractColumn.isPadding() && !abstractColumn.displayedChildren.length)) { _this.displayedChildren.push(abstractColumn); } break; } }); } this.localEventService.dispatchEvent(this.createAgEvent(ColumnGroup.EVENT_DISPLAYED_CHILDREN_CHANGED)); }; ColumnGroup.HEADER_GROUP_SHOW_OPEN = 'open'; ColumnGroup.HEADER_GROUP_SHOW_CLOSED = 'closed'; ColumnGroup.HEADER_GROUP_PADDING = 'padding'; ColumnGroup.EVENT_LEFT_CHANGED = 'leftChanged'; ColumnGroup.EVENT_DISPLAYED_CHILDREN_CHANGED = 'displayedChildrenChanged'; __decorate$2([ Autowired('gridOptionsWrapper') ], ColumnGroup.prototype, "gridOptionsWrapper", void 0); return ColumnGroup; }()); /** * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components * @version v25.0.0 * @link http://www.ag-grid.com/ * @license MIT */ var OriginalColumnGroup = /** @class */ (function () { function OriginalColumnGroup(colGroupDef, groupId, padding, level) { this.localEventService = new EventService(); this.expandable = false; this.colGroupDef = colGroupDef; this.groupId = groupId; this.expanded = colGroupDef && !!colGroupDef.openByDefault; this.padding = padding; this.level = level; } OriginalColumnGroup.prototype.setOriginalParent = function (originalParent) { this.originalParent = originalParent; }; OriginalColumnGroup.prototype.getOriginalParent = function () { return this.originalParent; }; OriginalColumnGroup.prototype.getLevel = function () { return this.level; }; OriginalColumnGroup.prototype.isVisible = function () { // return true if at least one child is visible if (this.children) { return this.children.some(function (child) { return child.isVisible(); }); } return false; }; OriginalColumnGroup.prototype.isPadding = function () { return this.padding; }; OriginalColumnGroup.prototype.setExpanded = function (expanded) { this.expanded = expanded === undefined ? false : expanded; var event = { type: OriginalColumnGroup.EVENT_EXPANDED_CHANGED }; this.localEventService.dispatchEvent(event); }; OriginalColumnGroup.prototype.isExpandable = function () { return this.expandable; }; OriginalColumnGroup.prototype.isExpanded = function () { return this.expanded; }; OriginalColumnGroup.prototype.getGroupId = function () { return this.groupId; }; OriginalColumnGroup.prototype.getId = function () { return this.getGroupId(); }; OriginalColumnGroup.prototype.setChildren = function (children) { this.children = children; }; OriginalColumnGroup.prototype.getChildren = function () { return this.children; }; OriginalColumnGroup.prototype.getColGroupDef = function () { return this.colGroupDef; }; OriginalColumnGroup.prototype.getLeafColumns = function () { var result = []; this.addLeafColumns(result); return result; }; OriginalColumnGroup.prototype.addLeafColumns = function (leafColumns) { if (!this.children) { return; } this.children.forEach(function (child) { if (child instanceof Column) { leafColumns.push(child); } else if (child instanceof OriginalColumnGroup) { child.addLeafColumns(leafColumns); } }); }; OriginalColumnGroup.prototype.getColumnGroupShow = function () { return this.padding ? ColumnGroup.HEADER_GROUP_PADDING : this.colGroupDef.columnGroupShow; }; // need to check that this group has at least one col showing when both expanded and contracted. // if not, then we don't allow expanding and contracting on this group OriginalColumnGroup.prototype.setupExpandable = function () { var _this = this; this.setExpandable(); // note - we should be removing this event listener this.getLeafColumns().forEach(function (col) { return col.addEventListener(Column.EVENT_VISIBLE_CHANGED, _this.onColumnVisibilityChanged.bind(_this)); }); }; OriginalColumnGroup.prototype.setExpandable = function () { if (this.isPadding()) { return; } // want to make sure the group doesn't disappear when it's open var atLeastOneShowingWhenOpen = false; // want to make sure the group doesn't disappear when it's closed var atLeastOneShowingWhenClosed = false; // want to make sure the group has something to show / hide var atLeastOneChangeable = false; var children = this.findChildren(); for (var i = 0, j = children.length; i < j; i++) { var abstractColumn = children[i]; if (!abstractColumn.isVisible()) { continue; } // if the abstractColumn is a grid generated group, there will be no colDef var headerGroupShow = abstractColumn.getColumnGroupShow(); if (headerGroupShow === ColumnGroup.HEADER_GROUP_SHOW_OPEN) { atLeastOneShowingWhenOpen = true; atLeastOneChangeable = true; } else if (headerGroupShow === ColumnGroup.HEADER_GROUP_SHOW_CLOSED) { atLeastOneShowingWhenClosed = true; atLeastOneChangeable = true; } else { atLeastOneShowingWhenOpen = true; atLeastOneShowingWhenClosed = true; if (headerGroupShow === ColumnGroup.HEADER_GROUP_PADDING) { var column = abstractColumn; atLeastOneChangeable = atLeastOneChangeable || column.children.some(function (child) { return child.getColumnGroupShow() !== undefined; }); } } } var expandable = atLeastOneShowingWhenOpen && atLeastOneShowingWhenClosed && atLeastOneChangeable; if (this.expandable !== expandable) { this.expandable = expandable; var event_1 = { type: OriginalColumnGroup.EVENT_EXPANDABLE_CHANGED }; this.localEventService.dispatchEvent(event_1); } }; OriginalColumnGroup.prototype.findChildren = function () { var children = this.children; var firstChild = children[0]; if (firstChild && (!firstChild.isPadding || !firstChild.isPadding())) { return children; } while (children.length === 1 && children[0] instanceof OriginalColumnGroup) { children = children[0].children; } return children; }; OriginalColumnGroup.prototype.onColumnVisibilityChanged = function () { this.setExpandable(); }; OriginalColumnGroup.prototype.addEventListener = function (eventType, listener) { this.localEventService.addEventListener(eventType, listener); }; OriginalColumnGroup.prototype.removeEventListener = function (eventType, listener) { this.localEventService.removeEventListener(eventType, listener); }; OriginalColumnGroup.EVENT_EXPANDED_CHANGED = 'expandedChanged'; OriginalColumnGroup.EVENT_EXPANDABLE_CHANGED = 'expandableChanged'; return OriginalColumnGroup; }()); /** * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components * @version v25.0.0 * @link http://www.ag-grid.com/ * @license MIT */ var DefaultColumnTypes = { numericColumn: { headerClass: 'ag-right-aligned-header', cellClass: 'ag-right-aligned-cell' }, rightAligned: { headerClass: 'ag-right-aligned-header', cellClass: 'ag-right-aligned-cell' } }; /** * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components * @version v25.0.0 * @link http://www.ag-grid.com/ * @license MIT */ var AG_GRID_STOP_PROPAGATION = '__ag_Grid_Stop_Propagation'; var PASSIVE_EVENTS = ['touchstart', 'touchend', 'touchmove', 'touchcancel']; var supports = {}; /** * a user once raised an issue - they said that when you opened a popup (eg context menu) * and then clicked on a selection checkbox, the popup wasn't closed. this is because the * popup listens for clicks on the body, however ag-grid WAS stopping propagation on the * checkbox clicks (so the rows didn't pick them up as row selection selection clicks). * to get around this, we have a pattern to stop propagation for the purposes of ag-Grid, * but we still let the event pass back to the body. * @param {Event} event */ function stopPropagationForAgGrid(event) { event[AG_GRID_STOP_PROPAGATION] = true; } function isStopPropagationForAgGrid(event) { return event[AG_GRID_STOP_PROPAGATION] === true; } var isEventSupported = (function () { var tags = { select: 'input', change: 'input', submit: 'form', reset: 'form', error: 'img', load: 'img', abort: 'img' }; var isEventSupported = function (eventName) { if (typeof supports[eventName] === 'boolean') { return supports[eventName]; } var el = document.createElement(tags[eventName] || 'div'); eventName = 'on' + eventName; var isSupported = (eventName in el); if (!isSupported) { el.setAttribute(eventName, 'return;'); isSupported = typeof el[eventName] == 'function'; } el = null; return supports[eventName] = isSupported; }; return isEventSupported; })(); function getCellCompForEvent(gridOptionsWrapper, event) { var sourceElement = getTarget(event); while (sourceElement) { var renderedCell = gridOptionsWrapper.getDomData(sourceElement, 'cellComp'); if (renderedCell) { return renderedCell; } sourceElement = sourceElement.parentElement; } return null; } /** * @deprecated * Adds all type of change listeners to an element, intended to be a text field * @param {HTMLElement} element * @param {EventListener} listener */ function addChangeListener(element, listener) { element.addEventListener('changed', listener); element.addEventListener('paste', listener); element.addEventListener('input', listener); // IE doesn't fire changed for special keys (eg delete, backspace), so need to // listen for this further ones element.addEventListener('keydown', listener); element.addEventListener('keyup', listener); } /** * srcElement is only available in IE. In all other browsers it is target * http://stackoverflow.com/questions/5301643/how-can-i-make-event-srcelement-work-in-firefox-and-what-does-it-mean * @param {Event} event * @returns {Element} */ function getTarget(event) { var eventNoType = event; return eventNoType.target || eventNoType.srcElement; } function isElementInEventPath(element, event) { if (!event || !element) { return false; } return getEventPath(event).indexOf(element) >= 0; } function createEventPath(event) { var res = []; var pointer = getTarget(event); while (pointer) { res.push(pointer); pointer = pointer.parentElement; } return res; } /** * firefox doesn't have event.path set, or any alternative to it, so we hack * it in. this is needed as it's to late to work out the path when the item is * removed from the dom. used by MouseEventService, where it works out if a click * was from the current grid, or a detail grid (master / detail). * @param {Event} event */ function addAgGridEventPath(event) { event.__agGridEventPath = getEventPath(event); } /** * Gets the path for an Event. * https://stackoverflow.com/questions/39245488/event-path-undefined-with-firefox-and-vue-js * https://developer.mozilla.org/en-US/docs/Web/API/Event * @param {Event} event * @returns {EventTarget[]} */ function getEventPath(event) { var eventNoType = event; if (eventNoType.deepPath) { // IE supports deep path return eventNoType.deepPath(); } if (eventNoType.path) { // Chrome supports path return eventNoType.path; } if (eventNoType.composedPath) { // Firefox supports composePath return eventNoType.composedPath(); } if (eventNoType.__agGridEventPath) { // Firefox supports composePath return eventNoType.__agGridEventPath; } // and finally, if none of the above worked, // we create the path ourselves return createEventPath(event); } function addSafePassiveEventListener(frameworkOverrides, eElement, event, listener) { var isPassive = includes(PASSIVE_EVENTS, event); var options = isPassive ? { passive: true } : undefined; // this check is here for certain scenarios where I believe the user must be destroying // the grid somehow but continuing for it to be used if (frameworkOverrides && frameworkOverrides.addEventListener) { frameworkOverrides.addEventListener(eElement, event, listener, options); } } var EventUtils = /*#__PURE__*/Object.freeze({ __proto__: null, stopPropagationForAgGrid: stopPropagationForAgGrid, isStopPropagationForAgGrid: isStopPropagationForAgGrid, isEventSupported: isEventSupported, getCellCompForEvent: getCellCompForEvent, addChangeListener: addChangeListener, getTarget: getTarget, isElementInEventPath: isElementInEventPath, createEventPath: createEventPath, addAgGridEventPath: addAgGridEventPath, getEventPath: getEventPath, addSafePassiveEventListener: addSafePassiveEventListener }); /** * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components * @version v25.0.0 * @link http://www.ag-grid.com/ * @license MIT */ var __decorate$3 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var BeanStub = /** @class */ (function () { function BeanStub() { var _this = this; this.destroyFunctions = []; this.destroyed = false; // for vue 3 - prevents Vue from trying to make this (and obviously any sub classes) from being reactive // prevents vue from creating proxies for created objects and prevents identity related issues this.__v_skip = true; this.getContext = function () { return _this.context; }; this.isAlive = function () { return !_this.destroyed; }; } // this was a test constructor niall built, when active, it prints after 5 seconds all beans/components that are // not destroyed. to use, create a new grid, then api.destroy() before 5 seconds. then anything that gets printed // points to a bean or component that was not properly disposed of. // constructor() { // setTimeout(()=> { // if (this.isAlive()) { // let prototype: any = Object.getPrototypeOf(this); // const constructor: any = prototype.constructor; // const constructorString = constructor.toString(); // const beanName = constructorString.substring(9, constructorString.indexOf("(")); // console.log('is alive ' + beanName); // } // }, 5000); // } // CellComp and GridComp and override this because they get the FrameworkOverrides from the Beans bean BeanStub.prototype.getFrameworkOverrides = function () { return this.frameworkOverrides; }; BeanStub.prototype.destroy = function () { // let prototype: any = Object.getPrototypeOf(this); // const constructor: any = prototype.constructor; // const constructorString = constructor.toString(); // const beanName = constructorString.substring(9, constructorString.indexOf("(")); this.destroyFunctions.forEach(function (func) { return func(); }); this.destroyFunctions.length = 0; this.destroyed = true; this.dispatchEvent({ type: BeanStub.EVENT_DESTROYED }); }; BeanStub.prototype.addEventListener = function (eventType, listener) { if (!this.localEventService) { this.localEventService = new EventService(); } this.localEventService.addEventListener(eventType, listener); }; BeanStub.prototype.removeEventListener = function (eventType, listener) { if (this.localEventService) { this.localEventService.removeEventListener(eventType, listener); } }; BeanStub.prototype.dispatchEventAsync = function (event) { var _this = this; window.setTimeout(function () { return _this.dispatchEvent(event); }, 0); }; BeanStub.prototype.dispatchEvent = function (event) { if (this.localEventService) { this.localEventService.dispatchEvent(event); } }; BeanStub.prototype.addManagedListener = function (object, event, listener) { var _this = this; if (this.destroyed) { return; } if (object instanceof HTMLElement) { addSafePassiveEventListener(this.getFrameworkOverrides(), object, event, listener); } else { object.addEventListener(event, listener); } var destroyFunc = function () { object.removeEventListener(event, listener); _this.destroyFunctions = _this.destroyFunctions.filter(function (fn) { return fn !== destroyFunc; }); return null; }; this.destroyFunctions.push(destroyFunc); return destroyFunc; }; BeanStub.prototype.addDestroyFunc = function (func) { // if we are already destroyed, we execute the func now if (this.isAlive()) { this.destroyFunctions.push(func); } else { func(); } }; BeanStub.prototype.createManagedBean = function (bean, context) { var res = this.createBean(bean, context); this.addDestroyFunc(this.destroyBean.bind(this, bean, context)); return res; }; BeanStub.prototype.createBean = function (bean, context, afterPreCreateCallback) { return (context || this.getContext()).createBean(bean, afterPreCreateCallback); }; BeanStub.prototype.destroyBean = function (bean, context) { return (context || this.getContext()).destroyBean(bean); }; BeanStub.prototype.destroyBeans = function (beans, context) { var _this = this; if (beans) { forEach(beans, function (bean) { return _this.destroyBean(bean, context); }); } return []; }; BeanStub.EVENT_DESTROYED = 'destroyed'; __decorate$3([ Autowired('frameworkOverrides') ], BeanStub.prototype, "frameworkOverrides", void 0); __decorate$3([ Autowired('context') ], BeanStub.prototype, "context", void 0); __decorate$3([ Autowired('eventService') ], BeanStub.prototype, "eventService", void 0); __decorate$3([ Autowired('gridOptionsWrapper') ], BeanStub.prototype, "gridOptionsWrapper", void 0); __decorate$3([ PreDestroy ], BeanStub.prototype, "destroy", null); return BeanStub; }()); /** * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components * @version v25.0.0 * @link http://www.ag-grid.com/ * @license MIT */ var __extends = (undefined && undefined.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __decorate$4 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __param$1 = (undefined && undefined.__param) || function (paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } }; // takes ColDefs and ColGroupDefs and turns them into Columns and OriginalGroups var ColumnFactory = /** @class */ (function (_super) { __extends(ColumnFactory, _super); function ColumnFactory() { return _super !== null && _super.apply(this, arguments) || this; } ColumnFactory.prototype.setBeans = function (loggerFactory) { this.logger = loggerFactory.create('ColumnFactory'); }; ColumnFactory.prototype.createColumnTree = function (defs, primaryColumns, existingColumns) { // column key creator dishes out unique column id's in a deterministic way, // so if we have two grids (that could be master/slave) with same column definitions, // then this ensures the two grids use identical id's. var columnKeyCreator = new ColumnKeyCreator(); if (existingColumns) { var existingKeys = existingColumns.map(function (col) { return col.getId(); }); columnKeyCreator.addExistingKeys(existingKeys); } // we take a copy of the columns as we are going to be removing from them var existingColsCopy = existingColumns ? existingColumns.slice() : null; // create am unbalanced tree that maps the provided definitions var unbalancedTree = this.recursivelyCreateColumns(defs, 0, primaryColumns, existingColsCopy, columnKeyCreator, null); var treeDept = this.findMaxDept(unbalancedTree, 0); this.logger.log('Number of levels for grouped columns is ' + treeDept); var columnTree = this.balanceColumnTree(unbalancedTree, 0, treeDept, columnKeyCreator); var deptFirstCallback = function (child, parent) { if (child instanceof OriginalColumnGroup) { child.setupExpandable(); } // we set the original parents at the end, rather than when we go along, as balancing the tree // adds extra levels into the tree. so we can only set parents when balancing is done. child.setOriginalParent(parent); }; this.columnUtils.depthFirstOriginalTreeSearch(null, columnTree, deptFirstCallback); return { columnTree: columnTree, treeDept: treeDept }; }; ColumnFactory.prototype.createForAutoGroups = function (autoGroupCols, gridBalancedTree) { var _this = this; var autoColBalancedTree = []; autoGroupCols.forEach(function (col) { var fakeTreeItem = _this.createAutoGroupTreeItem(gridBalancedTree, col); autoColBalancedTree.push(fakeTreeItem); }); return autoColBalancedTree; }; ColumnFactory.prototype.createAutoGroupTreeItem = function (balancedColumnTree, column) { var dept = this.findDepth(balancedColumnTree); // at the end, this will be the top of the tree item. var nextChild = column; for (var i = dept - 1; i >= 0; i--) { var autoGroup = new OriginalColumnGroup(null, "FAKE_PATH_" + column.getId() + "}_" + i, true, i); this.context.createBean(autoGroup); autoGroup.setChildren([nextChild]); nextChild.setOriginalParent(autoGroup); nextChild = autoGroup; } // at this point, the nextChild is the top most item in the tree return nextChild; }; ColumnFactory.prototype.findDepth = function (balancedColumnTree) { var dept = 0; var pointer = balancedColumnTree; while (pointer && pointer[0] && pointer[0] instanceof OriginalColumnGroup) { dept++; pointer = pointer[0].getChildren(); } return dept; }; ColumnFactory.prototype.balanceColumnTree = function (unbalancedTree, currentDept, columnDept, columnKeyCreator) { var result = []; // go through each child, for groups, recurse a level deeper, // for columns we need to pad for (var i = 0; i < unbalancedTree.length; i++) { var child = unbalancedTree[i]; if (child instanceof OriginalColumnGroup) { // child is a group, all we do is go to the next level of recursion var originalGroup = child; var newChildren = this.balanceColumnTree(originalGroup.getChildren(), currentDept + 1, columnDept, columnKeyCreator); originalGroup.setChildren(newChildren); result.push(originalGroup); } else { // child is a column - so here we add in the padded column groups if needed var firstPaddedGroup = void 0; var currentPaddedGroup = void 0; // this for loop will NOT run any loops if no padded column groups are needed for (var j = columnDept - 1; j >= currentDept; j--) { var newColId = columnKeyCreator.getUniqueKey(null, null); var colGroupDefMerged = this.createMergedColGroupDef(null); var paddedGroup = new OriginalColumnGroup(colGroupDefMerged, newColId, true, currentDept); this.context.createBean(paddedGroup); if (currentPaddedGroup) { currentPaddedGroup.setChildren([paddedGroup]); } currentPaddedGroup = paddedGroup; if (!firstPaddedGroup) { firstPaddedGroup = currentPaddedGroup; } } // likewise this if statement will not run if no padded groups if (firstPaddedGroup) { result.push(firstPaddedGroup); var hasGroups = unbalancedTree.some(function (child) { return child instanceof OriginalColumnGroup; }); if (hasGroups) { currentPaddedGroup.setChildren([child]); continue; } else { currentPaddedGroup.setChildren(unbalancedTree); break; } } result.push(child); } } return result; }; ColumnFactory.prototype.findMaxDept = function (treeChildren, dept) { var maxDeptThisLevel = dept; for (var i = 0; i < treeChildren.length; i++) { var abstractColumn = treeChildren[i]; if (abstractColumn instanceof OriginalColumnGroup) { var originalGroup = abstractColumn; var newDept = this.findMaxDept(originalGroup.getChildren(), dept + 1); if (maxDeptThisLevel < newDept) { maxDeptThisLevel = newDept; } } } return maxDeptThisLevel; }; ColumnFactory.prototype.recursivelyCreateColumns = function (defs, level, primaryColumns, existingColsCopy, columnKeyCreator, parent) { var _this = this; var result = []; if (!defs) { return result; } defs.forEach(function (def) { var newGroupOrColumn; if (_this.isColumnGroup(def)) { newGroupOrColumn = _this.createColumnGroup(primaryColumns, def, level, existingColsCopy, columnKeyCreator, parent); } else { newGroupOrColumn = _this.createColumn(primaryColumns, def, existingColsCopy, columnKeyCreator, parent); } result.push(newGroupOrColumn); }); return result; }; ColumnFactory.prototype.createColumnGroup = function (primaryColumns, colGroupDef, level, existingColumns, columnKeyCreator, parent) { var colGroupDefMerged = this.createMergedColGroupDef(colGroupDef); var groupId = columnKeyCreator.getUniqueKey(colGroupDefMerged.groupId, null); var originalGroup = new OriginalColumnGroup(colGroupDefMerged, groupId, false, level); this.context.createBean(originalGroup); var children = this.recursivelyCreateColumns(colGroupDefMerged.children, level + 1, primaryColumns, existingColumns, columnKeyCreator, originalGroup); originalGroup.setChildren(children); return originalGroup; }; ColumnFactory.prototype.createMergedColGroupDef = function (colGroupDef) { var colGroupDefMerged = {}; assign(colGroupDefMerged, this.gridOptionsWrapper.getDefaultColGroupDef()); assign(colGroupDefMerged, colGroupDef); this.checkForDeprecatedItems(colGroupDefMerged); return colGroupDefMerged; }; ColumnFactory.prototype.createColumn = function (primaryColumns, colDef, existingColsCopy, columnKeyCreator, parent) { var colDefMerged = this.mergeColDefs(colDef); this.checkForDeprecatedItems(colDefMerged); // see if column already exists var column = this.findExistingColumn(colDef, existingColsCopy); if (!column) { // no existing column, need to create one var colId = columnKeyCreator.getUniqueKey(colDefMerged.colId, colDefMerged.field); column = new Column(colDefMerged, colDef, colId, primaryColumns); this.context.createBean(column); } else { column.setColDef(colDefMerged, colDef); this.applyColumnState(column, colDefMerged); } return column; }; ColumnFactory.prototype.applyColumnState = function (column, colDef) { // flex var flex = attrToNumber(colDef.flex); if (flex !== undefined) { column.setFlex(flex); } // width - we only set width if column is not flexing var noFlexThisCol = column.getFlex() <= 0; if (noFlexThisCol) { // both null and undefined means we skip, as it's not possible to 'clear' width (a column must have a width) var width = attrToNumber(colDef.width); if (width != null) { column.setActualWidth(width); } } // sort - anything but undefined will set sort, thus null or empty string will clear the sort if (colDef.sort !== undefined) { if (colDef.sort == Constants.SORT_ASC || colDef.sort == Constants.SORT_DESC) { column.setSort(colDef.sort); } else { column.setSort(undefined); } } // sorted at - anything but undefined, thus null will clear the sortIndex var sortIndex = attrToNumber(colDef.sortIndex); if (sortIndex !== undefined) { column.setSortIndex(sortIndex); } // hide - anything but undefined, thus null will clear the hide var hide = attrToBoolean(colDef.hide); if (hide !== undefined) { column.setVisible(!hide); } // pinned - anything but undefined, thus null or empty string will remove pinned if (colDef.pinned !== undefined) { column.setPinned(colDef.pinned); } }; ColumnFactory.prototype.findExistingColumn = function (newColDef, existingColsCopy) { var res = find(existingColsCopy, function (existingCol) { var existingColDef = existingCol.getUserProvidedColDef(); if (!existingColDef) { return false; } var newHasId = newColDef.colId != null; var newHasField = newColDef.field != null; if (newHasId) { return existingCol.getId() === newColDef.colId; } if (newHasField) { return existingColDef.field === newColDef.field; } // if no id or field present, then try object equivalence. if (existingColDef === newColDef) { return true; } return false; }); // make sure we remove, so if user provided duplicate id, then we don't have more than // one column instance for colDef with common id if (res) { removeFromArray(existingColsCopy, res); } return res; }; ColumnFactory.prototype.mergeColDefs = function (colDef) { // start with empty merged definition var colDefMerged = {}; // merge properties from default column definitions var defaultColDef = this.gridOptionsWrapper.getDefaultColDef(); mergeDeep(colDefMerged, defaultColDef, true, true); // merge properties from column type properties if (colDef.type || (defaultColDef && defaultColDef.type)) { // if type of both colDef and defaultColDef, then colDef gets preference var columnType = colDef.type ? colDef.type : defaultColDef.type; this.assignColumnTypes(columnType, colDefMerged); } // merge properties from column definitions mergeDeep(colDefMerged, colDef, true, true); return colDefMerged; }; ColumnFactory.prototype.assignColumnTypes = function (type, colDefMerged) { var typeKeys; if (type instanceof Array) { var invalidArray = type.some(function (a) { return typeof a !== 'string'; }); if (invalidArray) { console.warn("ag-grid: if colDef.type is supplied an array it should be of type 'string[]'"); } else { typeKeys = type; } } else if (typeof type === 'string') { typeKeys = type.split(','); } else { console.warn("ag-grid: colDef.type should be of type 'string' | 'string[]'"); return; } // merge user defined with default column types var allColumnTypes = assign({}, DefaultColumnTypes); var userTypes = this.gridOptionsWrapper.getColumnTypes() || {}; iterateObject(userTypes, function (key, value) { if (key in allColumnTypes) { console.warn("ag-Grid: the column type '" + key + "' is a default column type and cannot be overridden."); } else { allColumnTypes[key] = value; } }); typeKeys.forEach(function (t) { var typeColDef = allColumnTypes[t.trim()]; if (typeColDef) { mergeDeep(colDefMerged, typeColDef, true, true); } else { console.warn("ag-grid: colDef.type '" + t + "' does not correspond to defined gridOptions.columnTypes"); } }); }; ColumnFactory.prototype.checkForDeprecatedItems = function (colDef) { if (colDef) { var colDefNoType = colDef; // take out the type, so we can access attributes not defined in the type if (colDefNoType.group !== undefined) { console.warn('ag-grid: colDef.group is invalid, please check documentation on how to do grouping as it changed in version 3'); } if (colDefNoType.headerGroup !== undefined) { console.warn('ag-grid: colDef.headerGroup is invalid, please check documentation on how to do grouping as it changed in version 3'); } if (colDefNoType.headerGroupShow !== undefined) { console.warn('ag-grid: colDef.headerGroupShow is invalid, should be columnGroupShow, please check documentation on how to do grouping as it changed in version 3'); } if (colDefNoType.suppressRowGroup !== undefined) { console.warn('ag-grid: colDef.suppressRowGroup is deprecated, please use colDef.type instead'); } if (colDefNoType.suppressAggregation !== undefined) { console.warn('ag-grid: colDef.suppressAggregation is deprecated, please use colDef.type instead'); } if (colDefNoType.suppressRowGroup || colDefNoType.suppressAggregation) { console.warn('ag-grid: colDef.suppressAggregation and colDef.suppressRowGroup are deprecated, use allowRowGroup, allowPivot and allowValue instead'); } if (colDefNoType.displayName) { console.warn("ag-grid: Found displayName " + colDefNoType.displayName + ", please use headerName instead, displayName is deprecated."); colDefNoType.headerName = colDefNoType.displayName; } } }; // if object has children, we assume it's a group ColumnFactory.prototype.isColumnGroup = function (abstractColDef) { return abstractColDef.children !== undefined; }; __decorate$4([ Autowired('columnUtils') ], ColumnFactory.prototype, "columnUtils", void 0); __decorate$4([ __param$1(0, Qualifier('loggerFactory')) ], ColumnFactory.prototype, "setBeans", null); ColumnFactory = __decorate$4([ Bean('columnFactory') ], ColumnFactory); return ColumnFactory; }(BeanStub)); /** * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components * @version v25.0.0 * @link http://www.ag-grid.com/ * @license MIT */ var Events = /** @class */ (function () { function Events() { } /** Everything has changed with the columns. Either complete new set of columns set, or user called setState() */ /** @deprecated - grid no longer uses this, and setSate() also fires individual events */ Events.EVENT_COLUMN_EVERYTHING_CHANGED = 'columnEverythingChanged'; /** User has set in new columns. */ Events.EVENT_NEW_COLUMNS_LOADED = 'newColumnsLoaded'; /** The pivot mode flag was changed */ Events.EVENT_COLUMN_PIVOT_MODE_CHANGED = 'columnPivotModeChanged'; /** A row group column was added, removed or order changed. */ Events.EVENT_COLUMN_ROW_GROUP_CHANGED = 'columnRowGroupChanged'; /** expandAll / collapseAll was called from the api. */ Events.EVENT_EXPAND_COLLAPSE_ALL = 'expandOrCollapseAll'; /** A pivot column was added, removed or order changed. */ Events.EVENT_COLUMN_PIVOT_CHANGED = 'columnPivotChanged'; /** The list of grid columns has changed. */ Events.EVENT_GRID_COLUMNS_CHANGED = 'gridColumnsChanged'; /** A value column was added, removed or agg function was changed. */ Events.EVENT_COLUMN_VALUE_CHANGED = 'columnValueChanged'; /** A column was moved */ Events.EVENT_COLUMN_MOVED = 'columnMoved'; /** One or more columns was shown / hidden */ Events.EVENT_COLUMN_VISIBLE = 'columnVisible'; /** One or more columns was pinned / unpinned*/ Events.EVENT_COLUMN_PINNED = 'columnPinned'; /** A column group was opened / closed */ Events.EVENT_COLUMN_GROUP_OPENED = 'columnGroupOpened'; /** One or more columns was resized. If just one, the column in the event is set. */ Events.EVENT_COLUMN_RESIZED = 'columnResized'; /** The list of displayed columns has changed, can result from columns open / close, column move, pivot, group, etc */ Events.EVENT_DISPLAYED_COLUMNS_CHANGED = 'displayedColumnsChanged'; /** The list of virtual columns has changed, results from viewport changing */ Events.EVENT_VIRTUAL_COLUMNS_CHANGED = 'virtualColumnsChanged'; /** Async Transactions Executed */ Events.EVENT_ASYNC_TRANSACTIONS_FLUSHED = 'asyncTransactionsFlushed'; /** A row group was opened / closed */ Events.EVENT_ROW_GROUP_OPENED = 'rowGroupOpened'; /** The client has set new data into the grid */ Events.EVENT_ROW_DATA_CHANGED = 'rowDataChanged'; /** The client has updated data for the grid */ Events.EVENT_ROW_DATA_UPDATED = 'rowDataUpdated'; /** The client has set new floating data into the grid */ Events.EVENT_PINNED_ROW_DATA_CHANGED = 'pinnedRowDataChanged'; /** Range selection has changed */ Events.EVENT_RANGE_SELECTION_CHANGED = 'rangeSelectionChanged'; /** Chart was created */ Events.EVENT_CHART_CREATED = 'chartCreated'; /** Chart Range selection has changed */ Events.EVENT_CHART_RANGE_SELECTION_CHANGED = 'chartRangeSelectionChanged'; /** Chart Options have changed */ Events.EVENT_CHART_OPTIONS_CHANGED = 'chartOptionsChanged'; /** Chart was destroyed */ Events.EVENT_CHART_DESTROYED = 'chartDestroyed'; /** For when the tool panel is shown / hidden */ Events.EVENT_TOOL_PANEL_VISIBLE_CHANGED = 'toolPanelVisibleChanged'; /** Model was updated - grid updates the drawn rows when this happens */ Events.EVENT_MODEL_UPDATED = 'modelUpdated'; Events.EVENT_PASTE_START = 'pasteStart'; Events.EVENT_PASTE_END = 'pasteEnd'; Events.EVENT_FILL_START = 'fillStart'; Events.EVENT_FILL_END = 'fillEnd'; Events.EVENT_CELL_CLICKED = 'cellClicked'; Events.EVENT_CELL_DOUBLE_CLICKED = 'cellDoubleClicked'; Events.EVENT_CELL_MOUSE_DOWN = 'cellMouseDown'; Events.EVENT_CELL_CONTEXT_MENU = 'cellContextMenu'; Events.EVENT_CELL_VALUE_CHANGED = 'cellValueChanged'; Events.EVENT_ROW_VALUE_CHANGED = 'rowValueChanged'; Events.EVENT_CELL_FOCUSED = 'cellFocused'; Events.EVENT_ROW_SELECTED = 'rowSelected'; Events.EVENT_SELECTION_CHANGED = 'selectionChanged'; Events.EVENT_CELL_KEY_DOWN = 'cellKeyDown'; Events.EVENT_CELL_KEY_PRESS = 'cellKeyPress'; Events.EVENT_CELL_MOUSE_OVER = 'cellMouseOver'; Events.EVENT_CELL_MOUSE_OUT = 'cellMouseOut'; /** 2 events for filtering. The grid LISTENS for filterChanged and afterFilterChanged */ Events.EVENT_FILTER_CHANGED = 'filterChanged'; /** Filter was change but not applied. Only useful if apply buttons are used in filters. */ Events.EVENT_FILTER_MODIFIED = 'filterModified'; Events.EVENT_FILTER_OPENED = 'filterOpened'; Events.EVENT_SORT_CHANGED = 'sortChanged'; /** A row was removed from the dom, for any reason. Use to clean up resources (if any) used by the row. */ Events.EVENT_VIRTUAL_ROW_REMOVED = 'virtualRowRemoved'; Events.EVENT_ROW_CLICKED = 'rowClicked'; Events.EVENT_ROW_DOUBLE_CLICKED = 'rowDoubleClicked'; /** Gets called once after the grid has finished initialising. */ Events.EVENT_GRID_READY = 'gridReady'; /** Width of height of the main grid div has changed. Grid listens for this and does layout of grid if it's * changed, so always filling the space it was given. */ Events.EVENT_GRID_SIZE_CHANGED = 'gridSizeChanged'; /** The indexes of the rows rendered has changed, eg user has scrolled to a new vertical position. */ Events.EVENT_VIEWPORT_CHANGED = 'viewportChanged'; /* The width of the scrollbar has been calculated */ Events.EVENT_SCROLLBAR_WIDTH_CHANGED = 'scrollbarWidthChanged'; /** Rows were rendered for the first time (ie on async data load). */ Events.EVENT_FIRST_DATA_RENDERED = 'firstDataRendered'; /** A column drag has started, either resizing a column or moving a column. */ Events.EVENT_DRAG_STARTED = 'dragStarted'; /** A column drag has stopped */ Events.EVENT_DRAG_STOPPED = 'dragStopped'; Events.EVENT_CHECKBOX_CHANGED = 'checkboxChanged'; Events.EVENT_ROW_EDITING_STARTED = 'rowEditingStarted'; Events.EVENT_ROW_EDITING_STOPPED = 'rowEditingStopped'; Events.EVENT_CELL_EDITING_STARTED = 'cellEditingStarted'; Events.EVENT_CELL_EDITING_STOPPED = 'cellEditingStopped'; /** Main body of grid has scrolled, either horizontally or vertically */ Events.EVENT_BODY_SCROLL = 'bodyScroll'; Events.EVENT_ANIMATION_QUEUE_EMPTY = 'animationQueueEmpty'; Events.EVENT_HEIGHT_SCALE_CHANGED = 'heightScaleChanged'; /** The displayed page for pagination has changed. For example the data was filtered or sorted, * or the user has moved to a different page. */ Events.EVENT_PAGINATION_CHANGED = 'paginationChanged'; /** Only used by React, Angular 2+, Web Components and VueJS ag-Grid components * (not used if doing plain JavaScript or Angular 1.x). If the grid receives changes due * to bound properties, this event fires after the grid has finished processing the change. */ Events.EVENT_COMPONENT_STATE_CHANGED = 'componentStateChanged'; /** All items from here down are used internally by the grid, not intended for external use. */ // not documented, either experimental, or we just don't want users using an depending on them Events.EVENT_BODY_HEIGHT_CHANGED = 'bodyHeightChanged'; Events.EVENT_DISPLAYED_COLUMNS_WIDTH_CHANGED = 'displayedColumnsWidthChanged'; Events.EVENT_SCROLL_VISIBILITY_CHANGED = 'scrollVisibilityChanged'; Events.EVENT_COLUMN_HOVER_CHANGED = 'columnHoverChanged'; Events.EVENT_FLASH_CELLS = 'flashCells'; Events.EVENT_PAGINATION_PIXEL_OFFSET_CHANGED = 'paginationPixelOffsetChanged'; Events.EVENT_ROW_DRAG_ENTER = 'rowDragEnter'; Events.EVENT_ROW_DRAG_MOVE = 'rowDragMove'; Events.EVENT_ROW_DRAG_LEAVE = 'rowDragLeave'; Events.EVENT_ROW_DRAG_END = 'rowDragEnd'; // primarily for charts Events.EVENT_POPUP_TO_FRONT = 'popupToFront'; // these are used for server side group and agg - only used by CS with Viewport Row Model - intention is // to design these better around server side functions and then release to general public when fully working with // all the row models. Events.EVENT_COLUMN_ROW_GROUP_CHANGE_REQUEST = 'columnRowGroupChangeRequest'; Events.EVENT_COLUMN_PIVOT_CHANGE_REQUEST = 'columnPivotChangeRequest'; Events.EVENT_COLUMN_VALUE_CHANGE_REQUEST = 'columnValueChangeRequest'; Events.EVENT_COLUMN_AGG_FUNC_CHANGE_REQUEST = 'columnAggFuncChangeRequest'; Events.EVENT_KEYBOARD_FOCUS = 'keyboardFocus'; Events.EVENT_MOUSE_FOCUS = 'mouseFocus'; return Events; }()); /** * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components * @version v25.0.0 * @link http://www.ag-grid.com/ * @license MIT */ // class returns unique instance id's for columns. // eg, the following calls (in this order) will result in: // // getInstanceIdForKey('country') => 0 // getInstanceIdForKey('country') => 1 // getInstanceIdForKey('country') => 2 // getInstanceIdForKey('country') => 3 // getInstanceIdForKey('age') => 0 // getInstanceIdForKey('age') => 1 // getInstanceIdForKey('country') => 4 var GroupInstanceIdCreator = /** @class */ (function () { function GroupInstanceIdCreator() { // this map contains keys to numbers, so we remember what the last call was this.existingIds = {}; } GroupInstanceIdCreator.prototype.getInstanceIdForKey = function (key) { var lastResult = this.existingIds[key]; var result; if (typeof lastResult !== 'number') { // first time this key result = 0; } else { result = lastResult + 1; } this.existingIds[key] = result; return result; }; return GroupInstanceIdCreator; }()); /** * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components * @version v25.0.0 * @link http://www.ag-grid.com/ * @license MIT */ var reUnescapedHtml = /[&<>"']/g; /** * HTML Escapes. */ var HTML_ESCAPES = { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }; /** * It encodes any string in UTF-8 format * taken from https://github.com/mathiasbynens/utf8.js * @param {string} s * @returns {string} */ function utf8_encode(s) { var stringFromCharCode = String.fromCharCode; function ucs2decode(string) { var output = []; var counter = 0; var length = string.length; var value; var extra; while (counter < length) { value = string.charCodeAt(counter++); if (value >= 0xD800 && value <= 0xDBFF && counter < length) { // high surrogate, and there is a next character extra = string.charCodeAt(counter++); if ((extra & 0xFC00) == 0xDC00) { // low surrogate output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000); } else { // unmatched surrogate; only append this code unit, in case the next // code unit is the high surrogate of a surrogate pair output.push(value); counter--; } } else { output.push(value); } } return output; } function checkScalarValue(codePoint) { if (codePoint >= 0xD800 && codePoint <= 0xDFFF) { throw Error('Lone surrogate U+' + codePoint.toString(16).toUpperCase() + ' is not a scalar value'); } } function createByte(codePoint, shift) { return stringFromCharCode(((codePoint >> shift) & 0x3F) | 0x80); } function encodeCodePoint(codePoint) { if ((codePoint & 0xFFFFFF80) == 0) { // 1-byte sequence return stringFromCharCode(codePoint); } var symbol = ''; if ((codePoint & 0xFFFFF800) == 0) { // 2-byte sequence symbol = stringFromCharCode(((codePoint >> 6) & 0x1F) | 0xC0); } else if ((codePoint & 0xFFFF0000) == 0) { // 3-byte sequence checkScalarValue(codePoint); symbol = stringFromCharCode(((codePoint >> 12) & 0x0F) | 0xE0); symbol += createByte(codePoint, 6); } else if ((codePoint & 0xFFE00000) == 0) { // 4-byte sequence symbol = stringFromCharCode(((codePoint >> 18) & 0x07) | 0xF0); symbol += createByte(codePoint, 12); symbol += createByte(codePoint, 6); } symbol += stringFromCharCode((codePoint & 0x3F) | 0x80); return symbol; } var codePoints = ucs2decode(s); var length = codePoints.length; var index = -1; var codePoint; var byteString = ''; while (++index < length) { codePoint = codePoints[index]; byteString += encodeCodePoint(codePoint); } return byteString; } /** * Converts a camelCase string into hyphenated string * from https://gist.github.com/youssman/745578062609e8acac9f * @param {string} str * @return {string} */ function camelCaseToHyphen(str) { if (str === null || str === undefined) { return null; } return str.replace(/([A-Z])/g, function (g) { return '-' + g[0].toLowerCase(); }); } /** * Converts a hyphenated string into camelCase string * from https://stackoverflow.com/questions/6660977/convert-hyphens-to-camel-case-camelcase * @param {string} str * @return {string} */ function hyphenToCamelCase(str) { if (str === null || str === undefined) { return null; } return str.replace(/-([a-z])/g, function (g) { return g[1].toUpperCase(); }); } function capitalise(str) { return str[0].toUpperCase() + str.substr(1).toLowerCase(); } function escapeString(toEscape) { return toEscape == null || !toEscape.replace ? toEscape : toEscape.replace(reUnescapedHtml, function (chr) { return HTML_ESCAPES[chr]; }); } /** * Converts a camelCase string into regular text * from: https://stackoverflow.com/questions/15369566/putting-space-in-camel-case-string-using-regular-expression * @param {string} camelCase * @return {string} */ function camelCaseToHumanText(camelCase) { if (!camelCase || camelCase == null) { return null; } var rex = /([A-Z])([A-Z])([a-z])|([a-z])([A-Z])/g; var words = camelCase.replace(rex, '$1$4 $2$3$5').replace('.', ' ').split(' '); return words.map(function (word) { return word.substring(0, 1).toUpperCase() + ((word.length > 1) ? word.substring(1, word.length) : ''); }).join(' '); } function startsWith(str, matchStart) { if (str === matchStart) { return true; } return str != null && str.slice(0, matchStart.length) === matchStart; } var StringUtils = /*#__PURE__*/Object.freeze({ __proto__: null, utf8_encode: utf8_encode, camelCaseToHyphen: camelCaseToHyphen, hyphenToCamelCase: hyphenToCamelCase, capitalise: capitalise, escapeString: escapeString, camelCaseToHumanText: camelCaseToHumanText, startsWith: startsWith }); /** * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components * @version v25.0.0 * @link http://www.ag-grid.com/ * @license MIT */ var __extends$1 = (undefined && undefined.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __decorate$5 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __param$2 = (undefined && undefined.__param) || function (paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } }; var ColumnController = /** @class */ (function (_super) { __extends$1(ColumnController, _super); function ColumnController() { var _this = _super !== null && _super.apply(this, arguments) || this; // header row count, based on user provided columns _this.primaryHeaderRowCount = 0; _this.secondaryHeaderRowCount = 0; _this.secondaryColumnsPresent = false; // header row count, either above, or based on pivoting if we are pivoting _this.gridHeaderRowCount = 0; // these are the lists used by the rowRenderer to render nodes. almost the leaf nodes of the above // displayed trees, however it also takes into account if the groups are open or not. _this.displayedLeftColumns = []; _this.displayedRightColumns = []; _this.displayedCenterColumns = []; // all three lists above combined _this.allDisplayedColumns = []; // same as above, except trimmed down to only columns within the viewport _this.allDisplayedVirtualColumns = []; _this.allDisplayedCenterVirtualColumns = []; _this.rowGroupColumns = []; _this.valueColumns = []; _this.pivotColumns = []; _this.ready = false; _this.autoGroupsNeedBuilding = false; _this.forceRecreateAutoGroups = false; _this.pivotMode = false; _this.bodyWidth = 0; _this.leftWidth = 0; _this.rightWidth = 0; _this.bodyWidthDirty = true; _this.colDefVersion = 0; _this.flexColsCalculatedAtLestOnce = false; return _this; } ColumnController.prototype.init = function () { this.suppressColumnVirtualisation = this.gridOptionsWrapper.isSuppressColumnVirtualisation(); var pivotMode = this.gridOptionsWrapper.isPivotMode(); if (this.isPivotSettingAllowed(pivotMode)) { this.pivotMode = pivotMode; } this.usingTreeData = this.gridOptionsWrapper.isTreeData(); this.addManagedListener(this.gridOptionsWrapper, 'autoGroupColumnDef', this.onAutoGroupColumnDefChanged.bind(this)); }; ColumnController.prototype.onAutoGroupColumnDefChanged = function () { this.autoGroupsNeedBuilding = true; this.forceRecreateAutoGroups = true; this.updateGridColumns(); this.updateDisplayedColumns('gridOptionsChanged'); }; ColumnController.prototype.getColDefVersion = function () { return this.colDefVersion; }; ColumnController.prototype.setColumnDefs = function (columnDefs, source) { var _this = this; if (source === void 0) { source = 'api'; } var colsPreviouslyExisted = !!this.columnDefs; this.colDefVersion++; var raiseEventsFunc = this.compareColumnStatesAndRaiseEvents(source); this.columnDefs = columnDefs; // always invalidate cache on changing columns, as the column id's for the new columns // could overlap with the old id's, so the cache would return old values for new columns. this.valueCache.expire(); // NOTE ================== // we should be destroying the existing columns and groups if they exist, for example, the original column // group adds a listener to the columns, it should be also removing the listeners this.autoGroupsNeedBuilding = true; var oldPrimaryColumns = this.primaryColumns; var balancedTreeResult = this.columnFactory.createColumnTree(columnDefs, true, oldPrimaryColumns); this.primaryColumnTree = balancedTreeResult.columnTree; this.primaryHeaderRowCount = balancedTreeResult.treeDept + 1; this.primaryColumns = this.getColumnsFromTree(this.primaryColumnTree); this.primaryColumnsMap = {}; this.primaryColumns.forEach(function (col) { return _this.primaryColumnsMap[col.getId()] = col; }); this.extractRowGroupColumns(source, oldPrimaryColumns); this.extractPivotColumns(source, oldPrimaryColumns); this.extractValueColumns(source, oldPrimaryColumns); this.ready = true; this.updateGridColumns(); if (colsPreviouslyExisted && this.gridColsArePrimary && this.gridOptionsWrapper.isApplyColumnDefOrder()) { this.orderGridColumnsLikePrimary(); } this.updateDisplayedColumns(source); this.checkDisplayedVirtualColumns(); // this event is not used by ag-Grid, but left here for backwards compatibility, // in case applications use it this.dispatchEverythingChanged(source); raiseEventsFunc(); this.dispatchNewColumnsLoaded(); }; ColumnController.prototype.dispatchNewColumnsLoaded = function () { var newColumnsLoadedEvent = { type: Events.EVENT_NEW_COLUMNS_LOADED, api: this.gridApi, columnApi: this.columnApi }; this.eventService.dispatchEvent(newColumnsLoadedEvent); }; // this event is legacy, no grid code listens to it. instead the grid listens to New Columns Loaded ColumnController.prototype.dispatchEverythingChanged = function (source) { if (source === void 0) { source = 'api'; } var eventEverythingChanged = { type: Events.EVENT_COLUMN_EVERYTHING_CHANGED, api: this.gridApi, columnApi: this.columnApi, source: source }; this.eventService.dispatchEvent(eventEverythingChanged); }; ColumnController.prototype.orderGridColumnsLikePrimary = function () { var _this = this; this.gridColumns.sort(function (colA, colB) { var primaryIndexA = _this.primaryColumns.indexOf(colA); var primaryIndexB = _this.primaryColumns.indexOf(colB); // if both cols are present in primary, then we just return the position, // so position is maintained. var indexAPresent = primaryIndexA >= 0; var indexBPresent = primaryIndexB >= 0; if (indexAPresent && indexBPresent) { return primaryIndexA - primaryIndexB; } if (indexAPresent) { // B is auto group column, so put B first return 1; } if (indexBPresent) { // A is auto group column, so put A first return -1; } // otherwise both A and B are auto-group columns. so we just keep the order // as they were already in. var gridIndexA = _this.gridColumns.indexOf(colA); var gridIndexB = _this.gridColumns.indexOf(colB); return gridIndexA - gridIndexB; }); }; ColumnController.prototype.isAutoRowHeightActive = function () { return this.autoRowHeightColumns && this.autoRowHeightColumns.length > 0; }; ColumnController.prototype.getAllAutoRowHeightCols = function () { return this.autoRowHeightColumns; }; ColumnController.prototype.setVirtualViewportLeftAndRight = function () { if (this.gridOptionsWrapper.isEnableRtl()) { this.viewportLeft = this.bodyWidth - this.scrollPosition - this.scrollWidth; this.viewportRight = this.bodyWidth - this.scrollPosition; } else { this.viewportLeft = this.scrollPosition; this.viewportRight = this.scrollWidth + this.scrollPosition; } }; // used by clipboard service, to know what columns to paste into ColumnController.prototype.getDisplayedColumnsStartingAt = function (column) { var currentColumn = column; var columns = []; while (currentColumn != null) { columns.push(currentColumn); currentColumn = this.getDisplayedColAfter(currentColumn); } return columns; }; // checks what columns are currently displayed due to column virtualisation. fires an event // if the list of columns has changed. // + setColumnWidth(), setVirtualViewportPosition(), setColumnDefs(), sizeColumnsToFit() ColumnController.prototype.checkDisplayedVirtualColumns = function () { // check displayCenterColumnTree exists first, as it won't exist when grid is initialising if (this.displayedCenterColumns == null) { return; } var hashBefore = this.allDisplayedVirtualColumns.map(function (column) { return column.getId(); }).join('#'); this.updateVirtualSets(); var hashAfter = this.allDisplayedVirtualColumns.map(function (column) { return column.getId(); }).join('#'); if (hashBefore !== hashAfter) { var event_1 = { type: Events.EVENT_VIRTUAL_COLUMNS_CHANGED, api: this.gridApi, columnApi: this.columnApi }; this.eventService.dispatchEvent(event_1); } }; ColumnController.prototype.setVirtualViewportPosition = function (scrollWidth, scrollPosition) { if (scrollWidth !== this.scrollWidth || scrollPosition !== this.scrollPosition || this.bodyWidthDirty) { this.scrollWidth = scrollWidth; this.scrollPosition = scrollPosition; // we need to call setVirtualViewportLeftAndRight() at least once after the body width changes, // as the viewport can stay the same, but in RTL, if body width changes, we need to work out the // virtual columns again this.bodyWidthDirty = true; this.setVirtualViewportLeftAndRight(); if (this.ready) { this.checkDisplayedVirtualColumns(); } } }; ColumnController.prototype.isPivotMode = function () { return this.pivotMode; }; ColumnController.prototype.isPivotSettingAllowed = function (pivot) { if (pivot && this.gridOptionsWrapper.isTreeData()) { console.warn("ag-Grid: Pivot mode not available in conjunction Tree Data i.e. 'gridOptions.treeData: true'"); return false; } return true; }; ColumnController.prototype.setPivotMode = function (pivotMode, source) { if (source === void 0) { source = 'api'; } if (pivotMode === this.pivotMode || !this.isPivotSettingAllowed(this.pivotMode)) { return; } this.pivotMode = pivotMode; // we need to update grid columns to cover the scenario where user has groupSuppressAutoColumn=true, as // this means we don't use auto group column UNLESS we are in pivot mode (it's mandatory in pivot mode), // so need to updateGridColumn() to check it autoGroupCol needs to be added / removed this.autoGroupsNeedBuilding = true; this.updateGridColumns(); this.updateDisplayedColumns(source); var event = { type: Events.EVENT_COLUMN_PIVOT_MODE_CHANGED, api: this.gridApi, columnApi: this.columnApi }; this.eventService.dispatchEvent(event); }; ColumnController.prototype.getSecondaryPivotColumn = function (pivotKeys, valueColKey) { if (!this.secondaryColumnsPresent || !this.secondaryColumns) { return null; } var valueColumnToFind = this.getPrimaryColumn(valueColKey); var foundColumn = null; this.secondaryColumns.forEach(function (column) { var thisPivotKeys = column.getColDef().pivotKeys; var pivotValueColumn = column.getColDef().pivotValueColumn; var pivotKeyMatches = areEqual(thisPivotKeys, pivotKeys); var pivotValueMatches = pivotValueColumn === valueColumnToFind; if (pivotKeyMatches && pivotValueMatches) { foundColumn = column; } }); return foundColumn; }; ColumnController.prototype.setBeans = function (loggerFactory) { this.logger = loggerFactory.create('ColumnController'); }; ColumnController.prototype.setFirstRightAndLastLeftPinned = function (source) { var lastLeft; var firstRight; if (this.gridOptionsWrapper.isEnableRtl()) { lastLeft = this.displayedLeftColumns ? this.displayedLeftColumns[0] : null; firstRight = this.displayedRightColumns ? last(this.displayedRightColumns) : null; } else { lastLeft = this.displayedLeftColumns ? last(this.displayedLeftColumns) : null; firstRight = this.displayedRightColumns ? this.displayedRightColumns[0] : null; } this.gridColumns.forEach(function (column) { column.setLastLeftPinned(column === lastLeft, source); column.setFirstRightPinned(column === firstRight, source); }); }; ColumnController.prototype.autoSizeColumns = function (keys, skipHeader, source) { // because of column virtualisation, we can only do this function on columns that are // actually rendered, as non-rendered columns (outside the viewport and not rendered // due to column virtualisation) are not present. this can result in all rendered columns // getting narrowed, which in turn introduces more rendered columns on the RHS which // did not get autosized in the original run, leaving the visible grid with columns on // the LHS sized, but RHS no. so we keep looping through the visible columns until // no more cols are available (rendered) to be resized var _this = this; if (source === void 0) { source = "api"; } // we autosize after animation frames finish in case any cell renderers need to complete first. this can // happen eg if client code is calling api.autoSizeAllColumns() straight after grid is initialised, but grid // hasn't fully drawn out all the cells yet (due to cell renderers in animation frames). this.animationFrameService.flushAllFrames(); // keep track of which cols we have resized in here var columnsAutosized = []; // initialise with anything except 0 so that while loop executes at least once var changesThisTimeAround = -1; if (skipHeader == null) { skipHeader = this.gridOptionsWrapper.isSkipHeaderOnAutoSize(); } while (changesThisTimeAround !== 0) { changesThisTimeAround = 0; this.actionOnGridColumns(keys, function (column) { // if already autosized, skip it if (columnsAutosized.indexOf(column) >= 0) { return false; } // get how wide this col should be var preferredWidth = _this.autoWidthCalculator.getPreferredWidthForColumn(column, skipHeader); // preferredWidth = -1 if this col is not on the screen if (preferredWidth > 0) { var newWidth = _this.normaliseColumnWidth(column, preferredWidth); column.setActualWidth(newWidth, source); columnsAutosized.push(column); changesThisTimeAround++; } return true; }, source); } this.fireColumnResizedEvent(columnsAutosized, true, 'autosizeColumns'); }; ColumnController.prototype.fireColumnResizedEvent = function (columns, finished, source, flexColumns) { if (flexColumns === void 0) { flexColumns = null; } if (columns && columns.length) { var event_2 = { type: Events.EVENT_COLUMN_RESIZED, columns: columns, column: columns.length === 1 ? columns[0] : null, flexColumns: flexColumns, finished: finished, api: this.gridApi, columnApi: this.columnApi, source: source }; this.eventService.dispatchEvent(event_2); } }; ColumnController.prototype.autoSizeColumn = function (key, skipHeader, source) { if (source === void 0) { source = "api"; } if (key) { this.autoSizeColumns([key], skipHeader, source); } }; ColumnController.prototype.autoSizeAllColumns = function (skipHeader, source) { if (source === void 0) { source = "api"; } var allDisplayedColumns = this.getAllDisplayedColumns(); this.autoSizeColumns(allDisplayedColumns, skipHeader, source); }; ColumnController.prototype.getColumnsFromTree = function (rootColumns) { var result = []; var recursiveFindColumns = function (childColumns) { for (var i = 0; i < childColumns.length; i++) { var child = childColumns[i]; if (child instanceof Column) { result.push(child); } else if (child instanceof OriginalColumnGroup) { recursiveFindColumns(child.getChildren()); } } }; recursiveFindColumns(rootColumns); return result; }; ColumnController.prototype.getAllDisplayedColumnGroups = function () { if (this.displayedLeftColumnTree && this.displayedRightColumnTree && this.displayedCentreColumnTree) { return this.displayedLeftColumnTree .concat(this.displayedCentreColumnTree) .concat(this.displayedRightColumnTree); } return null; }; // + columnSelectPanel ColumnController.prototype.getPrimaryColumnTree = function () { return this.primaryColumnTree; }; // + gridPanel -> for resizing the body and setting top margin ColumnController.prototype.getHeaderRowCount = function () { return this.gridHeaderRowCount; }; // + headerRenderer -> setting pinned body width ColumnController.prototype.getLeftDisplayedColumnGroups = function () { return this.displayedLeftColumnTree; }; // + headerRenderer -> setting pinned body width ColumnController.prototype.getRightDisplayedColumnGroups = function () { return this.displayedRightColumnTree; }; // + headerRenderer -> setting pinned body width ColumnController.prototype.getCenterDisplayedColumnGroups = function () { return this.displayedCentreColumnTree; }; ColumnController.prototype.getDisplayedColumnGroups = function (type) { switch (type) { case Constants.PINNED_LEFT: return this.getLeftDisplayedColumnGroups(); case Constants.PINNED_RIGHT: return this.getRightDisplayedColumnGroups(); default: return this.getCenterDisplayedColumnGroups(); } }; // gridPanel -> ensureColumnVisible ColumnController.prototype.isColumnDisplayed = function (column) { return this.getAllDisplayedColumns().indexOf(column) >= 0; }; // + csvCreator ColumnController.prototype.getAllDisplayedColumns = function () { return this.allDisplayedColumns; }; ColumnController.prototype.getAllDisplayedVirtualColumns = function () { return this.allDisplayedVirtualColumns; }; ColumnController.prototype.getDisplayedLeftColumnsForRow = function (rowNode) { if (!this.colSpanActive) { return this.displayedLeftColumns; } return this.getDisplayedColumnsForRow(rowNode, this.displayedLeftColumns); }; ColumnController.prototype.getDisplayedRightColumnsForRow = function (rowNode) { if (!this.colSpanActive) { return this.displayedRightColumns; } return this.getDisplayedColumnsForRow(rowNode, this.displayedRightColumns); }; ColumnController.prototype.getDisplayedColumnsForRow = function (rowNode, displayedColumns, filterCallback, emptySpaceBeforeColumn) { var result = []; var lastConsideredCol = null; var _loop_1 = function (i) { var col = displayedColumns[i]; var maxAllowedColSpan = displayedColumns.length - i; var colSpan = Math.min(col.getColSpan(rowNode), maxAllowedColSpan); var columnsToCheckFilter = [col]; if (colSpan > 1) { var colsToRemove = colSpan - 1; for (var j = 1; j <= colsToRemove; j++) { columnsToCheckFilter.push(displayedColumns[i + j]); } i += colsToRemove; } // see which cols we should take out for column virtualisation var filterPasses; if (filterCallback) { // if user provided a callback, means some columns may not be in the viewport. // the user will NOT provide a callback if we are talking about pinned areas, // as pinned areas have no horizontal scroll and do not virtualise the columns. // if lots of columns, that means column spanning, and we set filterPasses = true // if one or more of the columns spanned pass the filter. filterPasses = false; columnsToCheckFilter.forEach(function (colForFilter) { if (filterCallback(colForFilter)) { filterPasses = true; } }); } else { filterPasses = true; } if (filterPasses) { if (result.length === 0 && lastConsideredCol) { var gapBeforeColumn = emptySpaceBeforeColumn ? emptySpaceBeforeColumn(col) : false; if (gapBeforeColumn) { result.push(lastConsideredCol); } } result.push(col); } lastConsideredCol = col; out_i_1 = i; }; var out_i_1; for (var i = 0; i < displayedColumns.length; i++) { _loop_1(i); i = out_i_1; } return result; }; // + rowRenderer // if we are not column spanning, this just returns back the virtual centre columns, // however if we are column spanning, then different rows can have different virtual // columns, so we have to work out the list for each individual row. ColumnController.prototype.getAllDisplayedCenterVirtualColumnsForRow = function (rowNode) { var _this = this; if (!this.colSpanActive) { return this.allDisplayedCenterVirtualColumns; } var emptySpaceBeforeColumn = function (col) { return col.getLeft() > _this.viewportLeft; }; // if doing column virtualisation, then we filter based on the viewport. var filterCallback = this.suppressColumnVirtualisation ? null : this.isColumnInViewport.bind(this); return this.getDisplayedColumnsForRow(rowNode, this.displayedCenterColumns, filterCallback, emptySpaceBeforeColumn); }; ColumnController.prototype.getAriaColumnIndex = function (col) { return this.getAllGridColumns().indexOf(col) + 1; }; ColumnController.prototype.isColumnInViewport = function (col) { var columnLeft = col.getLeft(); var columnRight = col.getLeft() + col.getActualWidth(); // adding 200 for buffer size, so some cols off viewport are rendered. // this helps horizontal scrolling so user rarely sees white space (unless // they scroll horizontally fast). however we are conservative, as the more // buffer the slower the vertical redraw speed var leftBounds = this.viewportLeft - 200; var rightBounds = this.viewportRight + 200; var columnToMuchLeft = columnLeft < leftBounds && columnRight < leftBounds; var columnToMuchRight = columnLeft > rightBounds && columnRight > rightBounds; return !columnToMuchLeft && !columnToMuchRight; }; // used by: // + angularGrid -> setting pinned body width // note: this should be cached ColumnController.prototype.getPinnedLeftContainerWidth = function () { return this.getWidthOfColsInList(this.displayedLeftColumns); }; // note: this should be cached ColumnController.prototype.getPinnedRightContainerWidth = function () { return this.getWidthOfColsInList(this.displayedRightColumns); }; ColumnController.prototype.updatePrimaryColumnList = function (keys, masterList, actionIsAdd, columnCallback, eventType, source) { var _this = this; if (source === void 0) { source = "api"; } if (!keys || missingOrEmpty(keys)) { return; } var atLeastOne = false; keys.forEach(function (key) { var columnToAdd = _this.getPrimaryColumn(key); if (!columnToAdd) { return; } if (actionIsAdd) { if (masterList.indexOf(columnToAdd) >= 0) { return; } masterList.push(columnToAdd); } else { if (masterList.indexOf(columnToAdd) < 0) { return; } removeFromArray(masterList, columnToAdd); } columnCallback(columnToAdd); atLeastOne = true; }); if (!atLeastOne) { return; } if (this.autoGroupsNeedBuilding) { this.updateGridColumns(); } this.updateDisplayedColumns(source); var event = { type: eventType, columns: masterList, column: masterList.length === 1 ? masterList[0] : null, api: this.gridApi, columnApi: this.columnApi, source: source }; this.eventService.dispatchEvent(event); }; ColumnController.prototype.setRowGroupColumns = function (colKeys, source) { if (source === void 0) { source = "api"; } this.autoGroupsNeedBuilding = true; this.setPrimaryColumnList(colKeys, this.rowGroupColumns, Events.EVENT_COLUMN_ROW_GROUP_CHANGED, this.setRowGroupActive.bind(this), source); }; ColumnController.prototype.setRowGroupActive = function (active, column, source) { if (active === column.isRowGroupActive()) { return; } column.setRowGroupActive(active, source); if (!active && !this.gridOptionsWrapper.isSuppressMakeColumnVisibleAfterUnGroup()) { column.setVisible(true, source); } }; ColumnController.prototype.addRowGroupColumn = function (key, source) { if (source === void 0) { source = "api"; } if (key) { this.addRowGroupColumns([key], source); } }; ColumnController.prototype.addRowGroupColumns = function (keys, source) { if (source === void 0) { source = "api"; } this.autoGroupsNeedBuilding = true; this.updatePrimaryColumnList(keys, this.rowGroupColumns, true, this.setRowGroupActive.bind(this, true), Events.EVENT_COLUMN_ROW_GROUP_CHANGED, source); }; ColumnController.prototype.removeRowGroupColumns = function (keys, source) { if (source === void 0) { source = "api"; } this.autoGroupsNeedBuilding = true; this.updatePrimaryColumnList(keys, this.rowGroupColumns, false, this.setRowGroupActive.bind(this, false), Events.EVENT_COLUMN_ROW_GROUP_CHANGED, source); }; ColumnController.prototype.removeRowGroupColumn = function (key, source) { if (source === void 0) { source = "api"; } if (key) { this.removeRowGroupColumns([key], source); } }; ColumnController.prototype.addPivotColumns = function (keys, source) { if (source === void 0) { source = "api"; } this.updatePrimaryColumnList(keys, this.pivotColumns, true, function (column) { return column.setPivotActive(true, source); }, Events.EVENT_COLUMN_PIVOT_CHANGED, source); }; ColumnController.prototype.setPivotColumns = function (colKeys, source) { if (source === void 0) { source = "api"; } this.setPrimaryColumnList(colKeys, this.pivotColumns, Events.EVENT_COLUMN_PIVOT_CHANGED, function (added, column) { column.setPivotActive(added, source); }, source); }; ColumnController.prototype.addPivotColumn = function (key, source) { if (source === void 0) { source = "api"; } this.addPivotColumns([key], source); }; ColumnController.prototype.removePivotColumns = function (keys, source) { if (source === void 0) { source = "api"; } this.updatePrimaryColumnList(keys, this.pivotColumns, false, function (column) { return column.setPivotActive(false, source); }, Events.EVENT_COLUMN_PIVOT_CHANGED, source); }; ColumnController.prototype.removePivotColumn = function (key, source) { if (source === void 0) { source = "api"; } this.removePivotColumns([key], source); }; ColumnController.prototype.setPrimaryColumnList = function (colKeys, masterList, eventName, columnCallback, source) { var _this = this; masterList.length = 0; if (exists(colKeys)) { colKeys.forEach(function (key) { var column = _this.getPrimaryColumn(key); if (column) { masterList.push(column); } }); } this.primaryColumns.forEach(function (column) { var added = masterList.indexOf(column) >= 0; columnCallback(added, column); }); if (this.autoGroupsNeedBuilding) { this.updateGridColumns(); } this.updateDisplayedColumns(source); var event = { type: eventName, columns: masterList, column: masterList.length === 1 ? masterList[0] : null, api: this.gridApi, columnApi: this.columnApi, source: source }; this.eventService.dispatchEvent(event); }; ColumnController.prototype.setValueColumns = function (colKeys, source) { if (source === void 0) { source = "api"; } this.setPrimaryColumnList(colKeys, this.valueColumns, Events.EVENT_COLUMN_VALUE_CHANGED, this.setValueActive.bind(this), source); }; ColumnController.prototype.setValueActive = function (active, column, source) { if (active === column.isValueActive()) { return; } column.setValueActive(active, source); if (active && !column.getAggFunc()) { var initialAggFunc = this.aggFuncService.getDefaultAggFunc(column); column.setAggFunc(initialAggFunc); } }; ColumnController.prototype.addValueColumns = function (keys, source) { if (source === void 0) { source = "api"; } this.updatePrimaryColumnList(keys, this.valueColumns, true, this.setValueActive.bind(this, true), Events.EVENT_COLUMN_VALUE_CHANGED, source); }; ColumnController.prototype.addValueColumn = function (colKey, source) { if (source === void 0) { source = "api"; } if (colKey) { this.addValueColumns([colKey], source); } }; ColumnController.prototype.removeValueColumn = function (colKey, source) { if (source === void 0) { source = "api"; } this.removeValueColumns([colKey], source); }; ColumnController.prototype.removeValueColumns = function (keys, source) { if (source === void 0) { source = "api"; } this.updatePrimaryColumnList(keys, this.valueColumns, false, this.setValueActive.bind(this, false), Events.EVENT_COLUMN_VALUE_CHANGED, source); }; // returns the width we can set to this col, taking into consideration min and max widths ColumnController.prototype.normaliseColumnWidth = function (column, newWidth) { if (newWidth < column.getMinWidth()) { newWidth = column.getMinWidth(); } if (column.isGreaterThanMax(newWidth)) { newWidth = column.getMaxWidth(); } return newWidth; }; ColumnController.prototype.getPrimaryOrGridColumn = function (key) { var column = this.getPrimaryColumn(key); return column || this.getGridColumn(key); }; ColumnController.prototype.setColumnWidths = function (columnWidths, shiftKey, // @takeFromAdjacent - if user has 'shift' pressed, then pixels are taken from adjacent column finished, // @finished - ends up in the event, tells the user if more events are to come source) { var _this = this; if (source === void 0) { source = "api"; } var sets = []; columnWidths.forEach(function (columnWidth) { var col = _this.getPrimaryOrGridColumn(columnWidth.key); if (!col) { return; } sets.push({ width: columnWidth.newWidth, ratios: [1], columns: [col] }); // if user wants to do shift resize by default, then we invert the shift operation var defaultIsShift = _this.gridOptionsWrapper.getColResizeDefault() === 'shift'; if (defaultIsShift) { shiftKey = !shiftKey; } if (shiftKey) { var otherCol = _this.getDisplayedColAfter(col); if (!otherCol) { return; } var widthDiff = col.getActualWidth() - columnWidth.newWidth; var otherColWidth = otherCol.getActualWidth() + widthDiff; sets.push({ width: otherColWidth, ratios: [1], columns: [otherCol] }); } }); if (sets.length === 0) { return; } this.resizeColumnSets(sets, finished, source); }; ColumnController.prototype.checkMinAndMaxWidthsForSet = function (columnResizeSet) { var columns = columnResizeSet.columns, width = columnResizeSet.width; // every col has a min width, so sum them all up and see if we have enough room // for all the min widths var minWidthAccumulated = 0; var maxWidthAccumulated = 0; var maxWidthActive = true; columns.forEach(function (col) { minWidthAccumulated += col.getMinWidth(); if (col.getMaxWidth() > 0) { maxWidthAccumulated += col.getMaxWidth(); } else { // if at least one columns has no max width, it means the group of columns // then has no max width, as at least one column can take as much width as possible maxWidthActive = false; } }); var minWidthPasses = width >= minWidthAccumulated; var maxWidthPasses = !maxWidthActive || (width <= maxWidthAccumulated); return minWidthPasses && maxWidthPasses; }; // method takes sets of columns and resizes them. either all sets will be resized, or nothing // be resized. this is used for example when user tries to resize a group and holds shift key, // then both the current group (grows), and the adjacent group (shrinks), will get resized, // so that's two sets for this method. ColumnController.prototype.resizeColumnSets = function (resizeSets, finished, source) { var passMinMaxCheck = !resizeSets || resizeSets.every(this.checkMinAndMaxWidthsForSet.bind(this)); if (!passMinMaxCheck) { // even though we are not going to resize beyond min/max size, we still need to raise event when finished if (finished) { var columns = resizeSets && resizeSets.length > 0 ? resizeSets[0].columns : null; this.fireColumnResizedEvent(columns, finished, source); } return; // don't resize! } var changedCols = []; var allResizedCols = []; resizeSets.forEach(function (set) { var width = set.width, columns = set.columns, ratios = set.ratios; // keep track of pixels used, and last column gets the remaining, // to cater for rounding errors, and min width adjustments var newWidths = {}; var finishedCols = {}; columns.forEach(function (col) { return allResizedCols.push(col); }); // the loop below goes through each col. if a col exceeds it's min/max width, // it then gets set to its min/max width and the column is removed marked as 'finished' // and the calculation is done again leaving this column out. take for example columns // {A, width: 50, maxWidth: 100} // {B, width: 50} // {C, width: 50} // and then the set is set to width 600 - on the first pass the grid tries to set each column // to 200. it checks A and sees 200 > 100 and so sets the width to 100. col A is then marked // as 'finished' and the calculation is done again with the remaining cols B and C, which end up // splitting the remaining 500 pixels. var finishedColsGrew = true; var loopCount = 0; var _loop_2 = function () { loopCount++; if (loopCount > 1000) { // this should never happen, but in the future, someone might introduce a bug here, // so we stop the browser from hanging and report bug properly console.error('ag-Grid: infinite loop in resizeColumnSets'); return "break"; } finishedColsGrew = false; var subsetCols = []; var subsetRatioTotal = 0; var pixelsToDistribute = width; columns.forEach(function (col, index) { var thisColFinished = finishedCols[col.getId()]; if (thisColFinished) { pixelsToDistribute -= newWidths[col.getId()]; } else { subsetCols.push(col); var ratioThisCol = ratios[index]; subsetRatioTotal += ratioThisCol; } }); // because we are not using all of the ratios (cols can be missing), // we scale the ratio. if all columns are included, then subsetRatioTotal=1, // and so the ratioScale will be 1. var ratioScale = 1 / subsetRatioTotal; subsetCols.forEach(function (col, index) { var lastCol = index === (subsetCols.length - 1); var colNewWidth; if (lastCol) { colNewWidth = pixelsToDistribute; } else { colNewWidth = Math.round(ratios[index] * width * ratioScale); pixelsToDistribute -= colNewWidth; } if (colNewWidth < col.getMinWidth()) { colNewWidth = col.getMinWidth(); finishedCols[col.getId()] = true; finishedColsGrew = true; } else if (col.getMaxWidth() > 0 && colNewWidth > col.getMaxWidth()) { colNewWidth = col.getMaxWidth(); finishedCols[col.getId()] = true; finishedColsGrew = true; } newWidths[col.getId()] = colNewWidth; }); }; while (finishedColsGrew) { var state_1 = _loop_2(); if (state_1 === "break") break; } columns.forEach(function (col) { var newWidth = newWidths[col.getId()]; if (col.getActualWidth() !== newWidth) { col.setActualWidth(newWidth, source); changedCols.push(col); } }); }); // if no cols changed, then no need to update more or send event. var atLeastOneColChanged = changedCols.length > 0; var flexedCols = this.refreshFlexedColumns({ resizingCols: allResizedCols, skipSetLeft: true }); if (atLeastOneColChanged) { this.setLeftValues(source); this.updateBodyWidths(); this.checkDisplayedVirtualColumns(); } // check for change first, to avoid unnecessary firing of events // however we always fire 'finished' events. this is important // when groups are resized, as if the group is changing slowly, // eg 1 pixel at a time, then each change will fire change events // in all the columns in the group, but only one with get the pixel. var colsForEvent = allResizedCols.concat(flexedCols); if (atLeastOneColChanged || finished) { this.fireColumnResizedEvent(colsForEvent, finished, source, flexedCols); } }; ColumnController.prototype.setColumnAggFunc = function (key, aggFunc, source) { if (source === void 0) { source = "api"; } if (!key) { return; } var column = this.getPrimaryColumn(key); if (!column) { return; } column.setAggFunc(aggFunc); var event = { type: Events.EVENT_COLUMN_VALUE_CHANGED, columns: [column], column: column, api: this.gridApi, columnApi: this.columnApi, source: source }; this.eventService.dispatchEvent(event); }; ColumnController.prototype.moveRowGroupColumn = function (fromIndex, toIndex, source) { if (source === void 0) { source = "api"; } var column = this.rowGroupColumns[fromIndex]; this.rowGroupColumns.splice(fromIndex, 1); this.rowGroupColumns.splice(toIndex, 0, column); var event = { type: Events.EVENT_COLUMN_ROW_GROUP_CHANGED, columns: this.rowGroupColumns, column: this.rowGroupColumns.length === 1 ? this.rowGroupColumns[0] : null, api: this.gridApi, columnApi: this.columnApi, source: source }; this.eventService.dispatchEvent(event); }; ColumnController.prototype.moveColumns = function (columnsToMoveKeys, toIndex, source) { if (source === void 0) { source = "api"; } this.columnAnimationService.start(); if (toIndex > this.gridColumns.length - columnsToMoveKeys.length) { console.warn('ag-Grid: tried to insert columns in invalid location, toIndex = ' + toIndex); console.warn('ag-Grid: remember that you should not count the moving columns when calculating the new index'); return; } // we want to pull all the columns out first and put them into an ordered list var columnsToMove = this.getGridColumns(columnsToMoveKeys); var failedRules = !this.doesMovePassRules(columnsToMove, toIndex); if (failedRules) { return; } moveInArray(this.gridColumns, columnsToMove, toIndex); this.updateDisplayedColumns(source); var event = { type: Events.EVENT_COLUMN_MOVED, columns: columnsToMove, column: columnsToMove.length === 1 ? columnsToMove[0] : null, toIndex: toIndex, api: this.gridApi, columnApi: this.columnApi, source: source }; this.eventService.dispatchEvent(event); this.columnAnimationService.finish(); }; ColumnController.prototype.doesMovePassRules = function (columnsToMove, toIndex) { // make a copy of what the grid columns would look like after the move var proposedColumnOrder = this.gridColumns.slice(); moveInArray(proposedColumnOrder, columnsToMove, toIndex); // then check that the new proposed order of the columns passes all rules if (!this.doesMovePassMarryChildren(proposedColumnOrder)) { return false; } if (!this.doesMovePassLockedPositions(proposedColumnOrder)) { return false; } return true; }; // returns the provided cols sorted in same order as they appear in grid columns. eg if grid columns // contains [a,b,c,d,e] and col passed is [e,a] then the passed cols are sorted into [a,e] ColumnController.prototype.sortColumnsLikeGridColumns = function (cols) { var _this = this; if (!cols || cols.length <= 1) { return; } var notAllColsInGridColumns = cols.filter(function (c) { return _this.gridColumns.indexOf(c) < 0; }).length > 0; if (notAllColsInGridColumns) { return; } cols.sort(function (a, b) { var indexA = _this.gridColumns.indexOf(a); var indexB = _this.gridColumns.indexOf(b); return indexA - indexB; }); }; ColumnController.prototype.doesMovePassLockedPositions = function (proposedColumnOrder) { var foundNonLocked = false; var rulePassed = true; // go though the cols, see if any non-locked appear before any locked proposedColumnOrder.forEach(function (col) { if (col.getColDef().lockPosition) { if (foundNonLocked) { rulePassed = false; } } else { foundNonLocked = true; } }); return rulePassed; }; ColumnController.prototype.doesMovePassMarryChildren = function (allColumnsCopy) { var rulePassed = true; this.columnUtils.depthFirstOriginalTreeSearch(null, this.gridBalancedTree, function (child) { if (!(child instanceof OriginalColumnGroup)) { return; } var columnGroup = child; var marryChildren = columnGroup.getColGroupDef() && columnGroup.getColGroupDef().marryChildren; if (!marryChildren) { return; } var newIndexes = []; columnGroup.getLeafColumns().forEach(function (col) { var newColIndex = allColumnsCopy.indexOf(col); newIndexes.push(newColIndex); }); var maxIndex = Math.max.apply(Math, newIndexes); var minIndex = Math.min.apply(Math, newIndexes); // spread is how far the first column in this group is away from the last column var spread = maxIndex - minIndex; var maxSpread = columnGroup.getLeafColumns().length - 1; // if the columns if (spread > maxSpread) { rulePassed = false; } // console.log(`maxIndex = ${maxIndex}, minIndex = ${minIndex}, spread = ${spread}, maxSpread = ${maxSpread}, fail = ${spread > (count-1)}`) // console.log(allColumnsCopy.map( col => col.getColDef().field).join(',')); }); return rulePassed; }; ColumnController.prototype.moveColumn = function (key, toIndex, source) { if (source === void 0) { source = "api"; } this.moveColumns([key], toIndex, source); }; ColumnController.prototype.moveColumnByIndex = function (fromIndex, toIndex, source) { if (source === void 0) { source = "api"; } var column = this.gridColumns[fromIndex]; this.moveColumn(column, toIndex, source); }; ColumnController.prototype.getColumnDefs = function () { var _this = this; var cols = this.primaryColumns.slice(); if (this.gridColsArePrimary) { cols.sort(function (a, b) { return _this.gridColumns.indexOf(a) - _this.gridColumns.indexOf(b); }); } else if (this.lastPrimaryOrder) { cols.sort(function (a, b) { return _this.lastPrimaryOrder.indexOf(a) - _this.lastPrimaryOrder.indexOf(b); }); } return this.columnDefFactory.buildColumnDefs(cols, this.rowGroupColumns, this.pivotColumns); }; // used by: // + angularGrid -> for setting body width // + rowController -> setting main row widths (when inserting and resizing) // need to cache this ColumnController.prototype.getBodyContainerWidth = function () { return this.bodyWidth; }; ColumnController.prototype.getContainerWidth = function (pinned) { switch (pinned) { case Constants.PINNED_LEFT: return this.leftWidth; case Constants.PINNED_RIGHT: return this.rightWidth; default: return this.bodyWidth; } }; // after setColumnWidth or updateGroupsAndDisplayedColumns ColumnController.prototype.updateBodyWidths = function () { var newBodyWidth = this.getWidthOfColsInList(this.displayedCenterColumns); var newLeftWidth = this.getWidthOfColsInList(this.displayedLeftColumns); var newRightWidth = this.getWidthOfColsInList(this.displayedRightColumns); // this is used by virtual col calculation, for RTL only, as a change to body width can impact displayed // columns, due to RTL inverting the y coordinates this.bodyWidthDirty = this.bodyWidth !== newBodyWidth; var atLeastOneChanged = this.bodyWidth !== newBodyWidth || this.leftWidth !== newLeftWidth || this.rightWidth !== newRightWidth; if (atLeastOneChanged) { this.bodyWidth = newBodyWidth; this.leftWidth = newLeftWidth; this.rightWidth = newRightWidth; // when this fires, it is picked up by the gridPanel, which ends up in // gridPanel calling setWidthAndScrollPosition(), which in turn calls setVirtualViewportPosition() var event_3 = { type: Events.EVENT_DISPLAYED_COLUMNS_WIDTH_CHANGED, api: this.gridApi, columnApi: this.columnApi }; this.eventService.dispatchEvent(event_3); } }; // + rowController ColumnController.prototype.getValueColumns = function () { return this.valueColumns ? this.valueColumns : []; }; // + rowController ColumnController.prototype.getPivotColumns = function () { return this.pivotColumns ? this.pivotColumns : []; }; // + clientSideRowModel ColumnController.prototype.isPivotActive = function () { return this.pivotColumns && this.pivotColumns.length > 0 && this.pivotMode; }; // + toolPanel ColumnController.prototype.getRowGroupColumns = function () { return this.rowGroupColumns ? this.rowGroupColumns : []; }; // + rowController -> while inserting rows ColumnController.prototype.getDisplayedCenterColumns = function () { return this.displayedCenterColumns; }; // + rowController -> while inserting rows ColumnController.prototype.getDisplayedLeftColumns = function () { return this.displayedLeftColumns; }; ColumnController.prototype.getDisplayedRightColumns = function () { return this.displayedRightColumns; }; ColumnController.prototype.getDisplayedColumns = function (type) { switch (type) { case Constants.PINNED_LEFT: return this.getDisplayedLeftColumns(); case Constants.PINNED_RIGHT: return this.getDisplayedRightColumns(); default: return this.getDisplayedCenterColumns(); } }; // used by: // + clientSideRowController -> sorting, building quick filter text // + headerRenderer -> sorting (clearing icon) ColumnController.prototype.getAllPrimaryColumns = function () { return this.primaryColumns ? this.primaryColumns.slice() : null; }; ColumnController.prototype.getSecondaryColumns = function () { return this.secondaryColumns ? this.secondaryColumns.slice() : null; }; ColumnController.prototype.getAllColumnsForQuickFilter = function () { return this.columnsForQuickFilter; }; // + moveColumnController ColumnController.prototype.getAllGridColumns = function () { return this.gridColumns; }; ColumnController.prototype.isEmpty = function () { return missingOrEmpty(this.gridColumns); }; ColumnController.prototype.isRowGroupEmpty = function () { return missingOrEmpty(this.rowGroupColumns); }; ColumnController.prototype.setColumnVisible = function (key, visible, source) { if (source === void 0) { source = "api"; } this.setColumnsVisible([key], visible, source); }; ColumnController.prototype.setColumnsVisible = function (keys, visible, source) { var _this = this; if (source === void 0) { source = "api"; } this.columnAnimationService.start(); this.actionOnGridColumns(keys, function (column) { if (column.isVisible() !== visible) { column.setVisible(visible, source); return true; } return false; }, source, function () { var event = { type: Events.EVENT_COLUMN_VISIBLE, visible: visible, column: null, columns: null, api: _this.gridApi, columnApi: _this.columnApi, source: source }; return event; }); this.columnAnimationService.finish(); }; ColumnController.prototype.setColumnPinned = function (key, pinned, source) { if (source === void 0) { source = "api"; } if (key) { this.setColumnsPinned([key], pinned, source); } }; ColumnController.prototype.setColumnsPinned = function (keys, pinned, source) { var _this = this; if (source === void 0) { source = "api"; } if (this.gridOptionsWrapper.getDomLayout() === 'print') { console.warn("Changing the column pinning status is not allowed with domLayout='print'"); return; } this.columnAnimationService.start(); var actualPinned; if (pinned === true || pinned === Constants.PINNED_LEFT) { actualPinned = Constants.PINNED_LEFT; } else if (pinned === Constants.PINNED_RIGHT) { actualPinned = Constants.PINNED_RIGHT; } else { actualPinned = null; } this.actionOnGridColumns(keys, function (col) { if (col.getPinned() !== actualPinned) { col.setPinned(actualPinned); return true; } return false; }, source, function () { var event = { type: Events.EVENT_COLUMN_PINNED, pinned: actualPinned, column: null, columns: null, api: _this.gridApi, columnApi: _this.columnApi, source: source }; return event; }); this.columnAnimationService.finish(); }; // does an action on a set of columns. provides common functionality for looking up the // columns based on key, getting a list of effected columns, and then updated the event // with either one column (if it was just one col) or a list of columns // used by: autoResize, setVisible, setPinned ColumnController.prototype.actionOnGridColumns = function (// the column keys this action will be on keys, // the action to do - if this returns false, the column was skipped // and won't be included in the event action, // should return back a column event of the right type source, createEvent) { var _this = this; if (missingOrEmpty(keys)) { return; } var updatedColumns = []; keys.forEach(function (key) { var column = _this.getGridColumn(key); if (!column) { return; } // need to check for false with type (ie !== instead of !=) // as not returning anything (undefined) would also be false var resultOfAction = action(column); if (resultOfAction !== false) { updatedColumns.push(column); } }); if (!updatedColumns.length) { return; } this.updateDisplayedColumns(source); if (exists(createEvent) && createEvent) { var event_4 = createEvent(); event_4.columns = updatedColumns; event_4.column = updatedColumns.length === 1 ? updatedColumns[0] : null; this.eventService.dispatchEvent(event_4); } }; ColumnController.prototype.getDisplayedColBefore = function (col) { var allDisplayedColumns = this.getAllDisplayedColumns(); var oldIndex = allDisplayedColumns.indexOf(col); if (oldIndex > 0) { return allDisplayedColumns[oldIndex - 1]; } return null; }; // used by: // + rowRenderer -> for navigation ColumnController.prototype.getDisplayedColAfter = function (col) { var allDisplayedColumns = this.getAllDisplayedColumns(); var oldIndex = allDisplayedColumns.indexOf(col); if (oldIndex < (allDisplayedColumns.length - 1)) { return allDisplayedColumns[oldIndex + 1]; } return null; }; ColumnController.prototype.getDisplayedGroupAfter = function (columnGroup) { return this.getDisplayedGroupAtDirection(columnGroup, 'After'); }; ColumnController.prototype.getDisplayedGroupBefore = function (columnGroup) { return this.getDisplayedGroupAtDirection(columnGroup, 'Before'); }; ColumnController.prototype.getDisplayedGroupAtDirection = function (columnGroup, direction) { // pick the last displayed column in this group var requiredLevel = columnGroup.getOriginalColumnGroup().getLevel() + columnGroup.getPaddingLevel(); var colGroupLeafColumns = columnGroup.getDisplayedLeafColumns(); var col = direction === 'After' ? last(colGroupLeafColumns) : colGroupLeafColumns[0]; var getDisplayColMethod = "getDisplayedCol" + direction; while (true) { // keep moving to the next col, until we get to another group var column = this[getDisplayColMethod](col); if (!column) { return null; } var groupPointer = this.getColumnGroupAtLevel(column, requiredLevel); if (groupPointer !== columnGroup) { return groupPointer; } } }; ColumnController.prototype.getColumnGroupAtLevel = function (column, level) { // get group at same level as the one we are looking for var groupPointer = column.getParent(); var originalGroupLevel; var groupPointerLevel; while (true) { var groupPointerOriginalColumnGroup = groupPointer.getOriginalColumnGroup(); originalGroupLevel = groupPointerOriginalColumnGroup.getLevel(); groupPointerLevel = groupPointer.getPaddingLevel(); if (originalGroupLevel + groupPointerLevel <= level) { break; } groupPointer = groupPointer.getParent(); } return groupPointer; }; ColumnController.prototype.isPinningLeft = function () { return this.displayedLeftColumns.length > 0; }; ColumnController.prototype.isPinningRight = function () { return this.displayedRightColumns.length > 0; }; ColumnController.prototype.getPrimaryAndSecondaryAndAutoColumns = function () { var result = this.primaryColumns ? this.primaryColumns.slice(0) : []; if (this.groupAutoColumns && exists(this.groupAutoColumns)) { this.groupAutoColumns.forEach(function (col) { return result.push(col); }); } if (this.secondaryColumnsPresent && this.secondaryColumns) { this.secondaryColumns.forEach(function (column) { return result.push(column); }); } return result; }; ColumnController.prototype.createStateItemFromColumn = function (column) { var rowGroupIndex = column.isRowGroupActive() ? this.rowGroupColumns.indexOf(column) : null; var pivotIndex = column.isPivotActive() ? this.pivotColumns.indexOf(column) : null; var aggFunc = column.isValueActive() ? column.getAggFunc() : null; var sort = column.getSort() != null ? column.getSort() : null; var sortIndex = column.getSortIndex() != null ? column.getSortIndex() : null; var flex = column.getFlex() != null && column.getFlex() > 0 ? column.getFlex() : null; var res = { colId: column.getColId(), width: column.getActualWidth(), hide: !column.isVisible(), pinned: column.getPinned(), sort: sort, sortIndex: sortIndex, aggFunc: aggFunc, rowGroup: column.isRowGroupActive(), rowGroupIndex: rowGroupIndex, pivot: column.isPivotActive(), pivotIndex: pivotIndex, flex: flex }; return res; }; ColumnController.prototype.getColumnState = function () { if (missing(this.primaryColumns) || !this.isAlive()) { return []; } var primaryColumnState = this.primaryColumns.map(this.createStateItemFromColumn.bind(this)); var groupAutoColumnState = this.groupAutoColumns // if groupAutoCols, then include them ? this.groupAutoColumns.map(this.createStateItemFromColumn.bind(this)) // otherwise no : []; var columnStateList = groupAutoColumnState.concat(primaryColumnState); if (!this.pivotMode) { this.orderColumnStateList(columnStateList); } return columnStateList; }; ColumnController.prototype.orderColumnStateList = function (columnStateList) { var gridColumnIds = this.gridColumns.map(function (column) { return column.getColId(); }); columnStateList.sort(function (itemA, itemB) { var posA = gridColumnIds.indexOf(itemA.colId); var posB = gridColumnIds.indexOf(itemB.colId); return posA - posB; }); }; ColumnController.prototype.resetColumnState = function (suppressEverythingEvent, source) { if (source === void 0) { source = "api"; } // we can't use 'allColumns' as the order might of messed up, so get the primary ordered list var primaryColumns = this.getColumnsFromTree(this.primaryColumnTree); var columnStates = []; // we start at 1000, so if user has mix of rowGroup and group specified, it will work with both. // eg IF user has ColA.rowGroupIndex=0, ColB.rowGroupIndex=1, ColC.rowGroup=true, // THEN result will be ColA.rowGroupIndex=0, ColB.rowGroupIndex=1, ColC.rowGroup=1000 var letRowGroupIndex = 1000; var letPivotIndex = 1000; var colsToProcess = []; if (this.groupAutoColumns) { colsToProcess = colsToProcess.concat(this.groupAutoColumns); } if (primaryColumns) { colsToProcess = colsToProcess.concat(primaryColumns); } colsToProcess.forEach(function (column) { var colDef = column.getColDef(); var sort = colDef.sort != null ? colDef.sort : null; var sortIndex = colDef.sortIndex; var hide = colDef.hide ? true : false; var pinned = colDef.pinned ? colDef.pinned : null; var width = colDef.width; var flex = colDef.flex != null ? colDef.flex : null; var rowGroupIndex = colDef.rowGroupIndex; var rowGroup = colDef.rowGroup; if (rowGroupIndex == null && (rowGroup == null || rowGroup == false)) { rowGroupIndex = null; rowGroup = null; } var pivotIndex = colDef.pivotIndex; var pivot = colDef.pivot; if (pivotIndex == null && (pivot == null || pivot == false)) { pivotIndex = null; pivot = null; } var aggFunc = colDef.aggFunc != null ? colDef.aggFunc : null; var stateItem = { colId: column.getColId(), sort: sort, sortIndex: sortIndex, hide: hide, pinned: pinned, width: width, flex: flex, rowGroup: rowGroup, rowGroupIndex: rowGroupIndex, pivot: pivot, pivotIndex: pivotIndex, aggFunc: aggFunc, }; if (missing(rowGroupIndex) && rowGroup) { stateItem.rowGroupIndex = letRowGroupIndex++; } if (missing(pivotIndex) && pivot) { stateItem.pivotIndex = letPivotIndex++; } columnStates.push(stateItem); }); this.applyColumnState({ state: columnStates, applyOrder: true }, source); }; ColumnController.prototype.applyColumnState = function (params, source) { var _this = this; if (source === void 0) { source = "api"; } if (missingOrEmpty(this.primaryColumns)) { return false; } if (params && params.state && !params.state.forEach) { console.warn('ag-Grid: applyColumnState() - the state attribute should be an array, however an array was not found. Please provide an array of items (one for each col you want to change) for state.'); return; } this.columnAnimationService.start(); var raiseEventsFunc = this.compareColumnStatesAndRaiseEvents(source); this.autoGroupsNeedBuilding = true; // at the end below, this list will have all columns we got no state for var columnsWithNoState = this.primaryColumns.slice(); var success = true; var rowGroupIndexes = {}; var pivotIndexes = {}; var autoGroupColumnStates = []; var previousRowGroupCols = this.rowGroupColumns.slice(); var previousPivotCols = this.pivotColumns.slice(); if (params.state) { params.state.forEach(function (state) { var groupAutoColumnId = Constants.GROUP_AUTO_COLUMN_ID; var colId = state.colId; // auto group columns are re-created so deferring syncing with ColumnState var isAutoGroupColumn = startsWith(colId, groupAutoColumnId); if (isAutoGroupColumn) { autoGroupColumnStates.push(state); return; } var column = _this.getPrimaryColumn(colId); if (!column) { // we don't log the failure, as it's possible the user is applying that has extra // cols in it. for example they could of save while row-grouping (so state includes // auto-group column) and then applied state when not grouping (so the auto-group // column would be in the state but no used). success = false; } else { _this.syncColumnWithStateItem(column, state, params.defaultState, rowGroupIndexes, pivotIndexes, false, source); removeFromArray(columnsWithNoState, column); } }); } // anything left over, we got no data for, so add in the column as non-value, non-rowGroup and hidden columnsWithNoState.forEach(function (col) { _this.syncColumnWithStateItem(col, null, params.defaultState, rowGroupIndexes, pivotIndexes, false, source); }); // sort the lists according to the indexes that were provided var comparator = function (indexes, oldList, colA, colB) { var indexA = indexes[colA.getId()]; var indexB = indexes[colB.getId()]; var aHasIndex = indexA != null; var bHasIndex = indexB != null; if (aHasIndex && bHasIndex) { // both a and b are new cols with index, so sort on index return indexA - indexB; } else if (aHasIndex) { // a has an index, so it should be before a return -1; } else if (bHasIndex) { // b has an index, so it should be before a return 1; } else { var oldIndexA = oldList.indexOf(colA); var oldIndexB = oldList.indexOf(colB); var aHasOldIndex = oldIndexA >= 0; var bHasOldIndex = oldIndexB >= 0; if (aHasOldIndex && bHasOldIndex) { // both a and b are old cols, so sort based on last order return oldIndexA - oldIndexB; } else if (aHasOldIndex) { // a is old, b is new, so b is first return -1; } else if (bHasOldIndex) { // b is old, a is new, a is first return 1; } else { // this bit does matter, means both are new cols but without index return 1; } } }; this.rowGroupColumns.sort(comparator.bind(this, rowGroupIndexes, previousRowGroupCols)); this.pivotColumns.sort(comparator.bind(this, pivotIndexes, previousPivotCols)); this.updateGridColumns(); // sync newly created auto group columns with ColumnState autoGroupColumnStates.forEach(function (stateItem) { var autoCol = _this.getAutoColumn(stateItem.colId); _this.syncColumnWithStateItem(autoCol, stateItem, params.defaultState, null, null, true, source); }); if (this.gridColsArePrimary && params.applyOrder && params.state) { var orderOfColIds_1 = params.state.map(function (stateItem) { return stateItem.colId; }); this.gridColumns.sort(function (colA, colB) { var indexA = orderOfColIds_1.indexOf(colA.getId()); var indexB = orderOfColIds_1.indexOf(colB.getId()); return indexA - indexB; }); // this is already done in updateGridColumns, however we changed the order above (to match the order of the state // columns) so we need to do it again. we could of put logic into the order above to take into account fixed // columns, however if we did then we would have logic for updating fixed columns twice. reusing the logic here // is less sexy for the code here, but it keeps consistency. this.putFixedColumnsFirst(); } this.updateDisplayedColumns(source); this.dispatchEverythingChanged(source); raiseEventsFunc(); this.columnAnimationService.finish(); return success; }; ColumnController.prototype.compareColumnStatesAndRaiseEvents = function (source) { var _this = this; // if no columns to begin with, then it means we are setting columns for the first time, so // there should be no events fired to show differences in columns. var colsPreviouslyExisted = !!this.columnDefs; if (!colsPreviouslyExisted) { return function () { }; } var startState = { rowGroupColumns: this.rowGroupColumns.slice(), pivotColumns: this.pivotColumns.slice(), valueColumns: this.valueColumns.slice() }; var columnStateBefore = this.getColumnState(); var columnStateBeforeMap = {}; columnStateBefore.forEach(function (col) { columnStateBeforeMap[col.colId] = col; }); return function () { if (_this.gridOptionsWrapper.isSuppressColumnStateEvents()) { return; } // raises generic ColumnEvents where all columns are returned rather than what has changed var raiseWhenListsDifferent = function (eventType, colsBefore, colsAfter, idMapper) { var beforeList = colsBefore.map(idMapper).sort(); var afterList = colsAfter.map(idMapper).sort(); var unchanged = areEqual(beforeList, afterList); if (unchanged) { return; } // returning all columns rather than what has changed! var event = { type: eventType, columns: colsAfter, column: colsAfter.length === 1 ? colsAfter[0] : null, api: _this.gridApi, columnApi: _this.columnApi, source: source }; _this.eventService.dispatchEvent(event); }; // determines which columns have changed according to supplied predicate var getChangedColumns = function (changedPredicate) { var changedColumns = []; _this.gridColumns.forEach(function (column) { var colStateBefore = columnStateBeforeMap[column.getColId()]; if (colStateBefore && changedPredicate(colStateBefore, column)) { changedColumns.push(column); } }); return changedColumns; }; var columnIdMapper = function (c) { return c.getColId(); }; raiseWhenListsDifferent(Events.EVENT_COLUMN_ROW_GROUP_CHANGED, startState.rowGroupColumns, _this.rowGroupColumns, columnIdMapper); raiseWhenListsDifferent(Events.EVENT_COLUMN_PIVOT_CHANGED, startState.pivotColumns, _this.pivotColumns, columnIdMapper); raiseWhenListsDifferent(Events.EVENT_COLUMN_VALUE_CHANGED, startState.valueColumns, _this.valueColumns, columnIdMapper); var resizeChangePredicate = function (cs, c) { return cs.width != c.getActualWidth(); }; _this.fireColumnResizedEvent(getChangedColumns(resizeChangePredicate), true, source); var pinnedChangePredicate = function (cs, c) { return cs.pinned != c.getPinned(); }; _this.raiseColumnPinnedEvent(getChangedColumns(pinnedChangePredicate), source); var visibilityChangePredicate = function (cs, c) { return cs.hide == c.isVisible(); }; _this.raiseColumnVisibleEvent(getChangedColumns(visibilityChangePredicate), source); var sortChangePredicate = function (cs, c) { return cs.sort != c.getSort() || cs.sortIndex != c.getSortIndex(); }; if (getChangedColumns(sortChangePredicate).length > 0) { _this.sortController.dispatchSortChangedEvents(); } // special handling for moved column events _this.raiseColumnMovedEvent(columnStateBefore, source); }; }; ColumnController.prototype.raiseColumnPinnedEvent = function (changedColumns, source) { if (!changedColumns.length) { return; } var event = { type: Events.EVENT_COLUMN_PINNED, pinned: null, columns: changedColumns, column: null, api: this.gridApi, columnApi: this.columnApi, source: source }; this.eventService.dispatchEvent(event); }; ColumnController.prototype.raiseColumnVisibleEvent = function (changedColumns, source) { if (!changedColumns.length) { return; } var event = { type: Events.EVENT_COLUMN_VISIBLE, visible: undefined, columns: changedColumns, column: null, api: this.gridApi, columnApi: this.columnApi, source: source }; this.eventService.dispatchEvent(event); }; ColumnController.prototype.raiseColumnMovedEvent = function (colStateBefore, source) { // we are only interested in columns that were both present and visible before and after var _this = this; var colStateAfter = this.getColumnState(); var colStateAfterMapped = {}; colStateAfter.forEach(function (s) { return colStateAfterMapped[s.colId] = s; }); // get id's of cols in both before and after lists var colsIntersectIds = {}; colStateBefore.forEach(function (s) { if (colStateAfterMapped[s.colId]) { colsIntersectIds[s.colId] = true; } }); // filter state lists, so we only have cols that were present before and after var beforeFiltered = filter(colStateBefore, function (c) { return colsIntersectIds[c.colId]; }); var afterFiltered = filter(colStateAfter, function (c) { return colsIntersectIds[c.colId]; }); // see if any cols are in a different location var movedColumns = []; afterFiltered.forEach(function (csAfter, index) { var csBefore = beforeFiltered[index]; if (csBefore.colId !== csAfter.colId) { movedColumns.push(_this.getGridColumn(csBefore.colId)); } }); if (!movedColumns.length) { return; } var event = { type: Events.EVENT_COLUMN_MOVED, columns: movedColumns, column: null, toIndex: undefined, api: this.gridApi, columnApi: this.columnApi, source: source }; this.eventService.dispatchEvent(event); }; ColumnController.prototype.syncColumnWithStateItem = function (column, stateItem, defaultState, rowGroupIndexes, pivotIndexes, autoCol, source) { if (!column) { return; } var getValue = function (key1, key2) { var stateAny = stateItem; var defaultAny = defaultState; if (stateAny && (stateAny[key1] !== undefined || stateAny[key2] !== undefined)) { return { value1: stateAny[key1], value2: stateAny[key2] }; } else if (defaultAny && (defaultAny[key1] !== undefined || defaultAny[key2] !== undefined)) { return { value1: defaultAny[key1], value2: defaultAny[key2] }; } else { return { value1: undefined, value2: undefined }; } }; // following ensures we are left with boolean true or false, eg converts (null, undefined, 0) all to true var hide = getValue('hide').value1; if (hide !== undefined) { column.setVisible(!hide, source); } // sets pinned to 'left' or 'right' var pinned = getValue('pinned').value1; if (pinned !== undefined) { column.setPinned(pinned); } // if width provided and valid, use it, otherwise stick with the old width var minColWidth = this.gridOptionsWrapper.getMinColWidth(); // flex var flex = getValue('flex').value1; if (flex !== undefined) { column.setFlex(flex); } // width - we only set width if column is not flexing var noFlexThisCol = column.getFlex() <= 0; if (noFlexThisCol) { // both null and undefined means we skip, as it's not possible to 'clear' width (a column must have a width) var width = getValue('width').value1; if (width != null) { if (minColWidth && (width >= minColWidth)) { column.setActualWidth(width, source); } } } var sort = getValue('sort').value1; if (sort !== undefined) { if (sort === Constants.SORT_DESC || sort === Constants.SORT_ASC) { column.setSort(sort); } else { column.setSort(undefined); } } var sortIndex = getValue('sortIndex').value1; if (sortIndex !== undefined) { column.setSortIndex(sortIndex); } // we do not do aggFunc, rowGroup or pivot for auto cols, as you can't do these with auto col if (autoCol) { return; } var aggFunc = getValue('aggFunc').value1; if (aggFunc !== undefined) { if (typeof aggFunc === 'string') { column.setAggFunc(aggFunc); if (!column.isValueActive()) { column.setValueActive(true, source); this.valueColumns.push(column); } } else { if (exists(aggFunc)) { console.warn('ag-Grid: stateItem.aggFunc must be a string. if using your own aggregation ' + 'functions, register the functions first before using them in get/set state. This is because it is ' + 'intended for the column state to be stored and retrieved as simple JSON.'); } column.setAggFunc(null); if (column.isValueActive()) { column.setValueActive(false, source); removeFromArray(this.valueColumns, column); } } } var _a = getValue('rowGroup', 'rowGroupIndex'), rowGroup = _a.value1, rowGroupIndex = _a.value2; if (rowGroup !== undefined || rowGroupIndex !== undefined) { if (typeof rowGroupIndex === 'number' || rowGroup) { if (!column.isRowGroupActive()) { column.setRowGroupActive(true, source); this.rowGroupColumns.push(column); } if (typeof rowGroupIndex === 'number') { rowGroupIndexes[column.getId()] = rowGroupIndex; } } else { if (column.isRowGroupActive()) { column.setRowGroupActive(false, source); removeFromArray(this.rowGroupColumns, column); } } } var _b = getValue('pivot', 'pivotIndex'), pivot = _b.value1, pivotIndex = _b.value2; if (pivot !== undefined || pivotIndex !== undefined) { if (typeof pivotIndex === 'number' || pivot) { if (!column.isPivotActive()) { column.setPivotActive(true, source); this.pivotColumns.push(column); } if (typeof pivotIndex === 'number') { pivotIndexes[column.getId()] = pivotIndex; } } else { if (column.isPivotActive()) { column.setPivotActive(false, source); removeFromArray(this.pivotColumns, column); } } } }; ColumnController.prototype.getGridColumns = function (keys) { return this.getColumns(keys, this.getGridColumn.bind(this)); }; ColumnController.prototype.getColumns = function (keys, columnLookupCallback) { var foundColumns = []; if (keys) { keys.forEach(function (key) { var column = columnLookupCallback(key); if (column) { foundColumns.push(column); } }); } return foundColumns; }; // used by growGroupPanel ColumnController.prototype.getColumnWithValidation = function (key) { if (key == null) { return null; } var column = this.getGridColumn(key); if (!column) { console.warn('ag-Grid: could not find column ' + key); } return column; }; ColumnController.prototype.getPrimaryColumn = function (key) { return this.getColumn(key, this.primaryColumns, this.primaryColumnsMap); }; ColumnController.prototype.getGridColumn = function (key) { return this.getColumn(key, this.gridColumns, this.gridColumnsMap); }; ColumnController.prototype.getColumn = function (key, columnList, columnMap) { if (!key) { return null; } // most of the time this method gets called the key is a string, so we put this shortcut in // for performance reasons, to see if we can match for ID (it doesn't do auto columns, that's done below) if (typeof key == 'string' && columnMap[key]) { return columnMap[key]; } for (var i = 0; i < columnList.length; i++) { if (this.columnsMatch(columnList[i], key)) { return columnList[i]; } } return this.getAutoColumn(key); }; ColumnController.prototype.getAutoColumn = function (key) { var _this = this; if (!this.groupAutoColumns || !exists(this.groupAutoColumns) || missing(this.groupAutoColumns)) { return null; } return find(this.groupAutoColumns, function (groupCol) { return _this.columnsMatch(groupCol, key); }); }; ColumnController.prototype.columnsMatch = function (column, key) { var columnMatches = column === key; var colDefMatches = column.getColDef() === key; var idMatches = column.getColId() == key; return columnMatches || colDefMatches || idMatches; }; ColumnController.prototype.getDisplayNameForColumn = function (column, location, includeAggFunc) { if (includeAggFunc === void 0) { includeAggFunc = false; } if (!column) { return null; } var headerName = this.getHeaderName(column.getColDef(), column, null, null, location); if (includeAggFunc) { return this.wrapHeaderNameWithAggFunc(column, headerName); } return headerName; }; ColumnController.prototype.getDisplayNameForOriginalColumnGroup = function (columnGroup, originalColumnGroup, location) { var colGroupDef = originalColumnGroup ? originalColumnGroup.getColGroupDef() : null; if (colGroupDef) { return this.getHeaderName(colGroupDef, null, columnGroup, originalColumnGroup, location); } return null; }; ColumnController.prototype.getDisplayNameForColumnGroup = function (columnGroup, location) { return this.getDisplayNameForOriginalColumnGroup(columnGroup, columnGroup.getOriginalColumnGroup(), location); }; // location is where the column is going to appear, ie who is calling us ColumnController.prototype.getHeaderName = function (colDef, column, columnGroup, originalColumnGroup, location) { var headerValueGetter = colDef.headerValueGetter; if (headerValueGetter) { var params = { colDef: colDef, column: column, columnGroup: columnGroup, originalColumnGroup: originalColumnGroup, location: location, api: this.gridOptionsWrapper.getApi(), context: this.gridOptionsWrapper.getContext() }; if (typeof headerValueGetter === 'function') { // valueGetter is a function, so just call it return headerValueGetter(params); } else if (typeof headerValueGetter === 'string') { // valueGetter is an expression, so execute the expression return this.expressionService.evaluate(headerValueGetter, params); } console.warn('ag-grid: headerValueGetter must be a function or a string'); return ''; } else if (colDef.headerName != null) { return colDef.headerName; } else if (colDef.field) { return camelCaseToHumanText(colDef.field); } return ''; }; /* private getHeaderGroupName(columnGroup: ColumnGroup): string { let colGroupDef = columnGroup.getOriginalColumnGroup().getColGroupDef(); let headerValueGetter = colGroupDef.headerValueGetter; if (headerValueGetter) { let params = { columnGroup: columnGroup, colDef: colGroupDef, api: this.gridOptionsWrapper.getApi(), context: this.gridOptionsWrapper.getContext() }; if (typeof headerValueGetter === 'function') { // valueGetter is a function, so just call it return headerValueGetter(params); } else if (typeof headerValueGetter === 'string') { // valueGetter is an expression, so execute the expression return this.expressionService.evaluate(headerValueGetter, params); } else { console.warn('ag-grid: headerValueGetter must be a function or a string'); return ''; } } else { return colGroupDef.headerName; } } */ ColumnController.prototype.wrapHeaderNameWithAggFunc = function (column, headerName) { if (this.gridOptionsWrapper.isSuppressAggFuncInHeader()) { return headerName; } // only columns with aggregation active can have aggregations var pivotValueColumn = column.getColDef().pivotValueColumn; var pivotActiveOnThisColumn = exists(pivotValueColumn); var aggFunc = null; var aggFuncFound; // otherwise we have a measure that is active, and we are doing aggregation on it if (pivotActiveOnThisColumn) { aggFunc = pivotValueColumn ? pivotValueColumn.getAggFunc() : null; aggFuncFound = true; } else { var measureActive = column.isValueActive(); var aggregationPresent = this.pivotMode || !this.isRowGroupEmpty(); if (measureActive && aggregationPresent) { aggFunc = column.getAggFunc(); aggFuncFound = true; } else { aggFuncFound = false; } } if (aggFuncFound) { var aggFuncString = (typeof aggFunc === 'string') ? aggFunc : 'func'; var localeTextFunc = this.gridOptionsWrapper.getLocaleTextFunc(); var aggFuncStringTranslated = localeTextFunc(aggFuncString, aggFuncString); return aggFuncStringTranslated + "(" + headerName + ")"; } return headerName; }; // returns the group with matching colId and instanceId. If instanceId is missing, // matches only on the colId. ColumnController.prototype.getColumnGroup = function (colId, instanceId) { if (!colId) { return null; } if (colId instanceof ColumnGroup) { return colId; } var allColumnGroups = this.getAllDisplayedColumnGroups(); var checkInstanceId = typeof instanceId === 'number'; var result = null; this.columnUtils.depthFirstAllColumnTreeSearch(allColumnGroups, function (child) { if (child instanceof ColumnGroup) { var columnGroup = child; var matched = void 0; if (checkInstanceId) { matched = colId === columnGroup.getGroupId() && instanceId === columnGroup.getInstanceId(); } else { matched = colId === columnGroup.getGroupId(); } if (matched) { result = columnGroup; } } }); return result; }; ColumnController.prototype.isReady = function () { return this.ready; }; ColumnController.prototype.extractValueColumns = function (source, oldPrimaryColumns) { this.valueColumns = this.extractColumns(oldPrimaryColumns, this.valueColumns, function (col, flag) { return col.setValueActive(flag, source); }, // aggFunc doesn't have index variant, cos order of value cols doesn't matter, so always return null function () { return undefined; }, function () { return undefined; }, // aggFunc is a string, so return it's existence function (colDef) { var aggFunc = colDef.aggFunc; // null or empty string means clear if (aggFunc === null || aggFunc === '') { return null; } else if (aggFunc === undefined) { return undefined; } else { return aggFunc != ''; } }, function (colDef) { // return false if any of the following: null, undefined, empty string return colDef.initialAggFunc != null && colDef.initialAggFunc != ''; }); // all new columns added will have aggFunc missing, so set it to what is in the colDef this.valueColumns.forEach(function (col) { var colDef = col.getColDef(); // if aggFunc provided, we always override, as reactive property if (colDef.aggFunc != null && colDef.aggFunc != '') { col.setAggFunc(colDef.aggFunc); } else { // otherwise we use initialAggFunc only if no agg func set - which happens when new column only if (!col.getAggFunc()) { col.setAggFunc(colDef.initialAggFunc); } } }); }; ColumnController.prototype.extractRowGroupColumns = function (source, oldPrimaryColumns) { this.rowGroupColumns = this.extractColumns(oldPrimaryColumns, this.rowGroupColumns, function (col, flag) { return col.setRowGroupActive(flag, source); }, function (colDef) { return colDef.rowGroupIndex; }, function (colDef) { return colDef.initialRowGroupIndex; }, function (colDef) { return colDef.rowGroup; }, function (colDef) { return colDef.initialRowGroup; }); }; ColumnController.prototype.extractColumns = function (oldPrimaryColumns, previousCols, setFlagFunc, getIndexFunc, getInitialIndexFunc, getValueFunc, getInitialValueFunc) { if (oldPrimaryColumns === void 0) { oldPrimaryColumns = []; } if (previousCols === void 0) { previousCols = []; } var colsWithIndex = []; var colsWithValue = []; // go though all cols. // if value, change // if default only, change only if new this.primaryColumns.forEach(function (col) { var colIsNew = oldPrimaryColumns.indexOf(col) < 0; var colDef = col.getColDef(); var value = attrToBoolean(getValueFunc(colDef)); var initialValue = attrToBoolean(getInitialValueFunc(colDef)); var index = attrToNumber(getIndexFunc(colDef)); var initialIndex = attrToNumber(getInitialIndexFunc(colDef)); var include; if (colIsNew) { // col is new, use values if present, otherwise use default values if present var valuePresent = value !== undefined || index !== undefined; if (valuePresent) { if (value !== undefined) { // if boolean value present, we take it's value, even if 'false' include = value; } else { // otherwise we based on number value. note that 'null' resets, however 'undefined' doesn't // go through this code path (undefined means 'ignore'). include = index >= 0; } } else { include = initialValue == true || initialIndex >= 0; } } else { // col is not new, we ignore the default values, just use the values if provided if (value !== undefined) { // value is never null, as attrToBoolean converts null to false include = value; } else if (index !== undefined) { if (index === null) { include = false; } else { include = index >= 0; } } else { // no values provided, we include if it was included last time include = previousCols.indexOf(col) >= 0; } } if (include) { var useIndex = colIsNew ? (index != null || initialIndex != null) : index != null; if (useIndex) { colsWithIndex.push(col); } else { colsWithValue.push(col); } } }); var getIndexForCol = function (col) { var index = getIndexFunc(col.getColDef()); var defaultIndex = getInitialIndexFunc(col.getColDef()); return index != null ? index : defaultIndex; }; // sort cols with index, and add these first colsWithIndex.sort(function (colA, colB) { var indexA = getIndexForCol(colA); var indexB = getIndexForCol(colB); if (indexA === indexB) { return 0; } else if (indexA < indexB) { return -1; } else { return 1; } }); var res = [].concat(colsWithIndex); // second add columns that were there before and in the same order as they were before, // so we are preserving order of current grouping of columns that simply have rowGroup=true previousCols.forEach(function (col) { if (colsWithValue.indexOf(col) >= 0) { res.push(col); } }); // lastly put in all remaining cols colsWithValue.forEach(function (col) { if (res.indexOf(col) < 0) { res.push(col); } }); // set flag=false for removed cols previousCols.forEach(function (col) { if (res.indexOf(col) < 0) { setFlagFunc(col, false); } }); // set flag=true for newly added cols res.forEach(function (col) { if (previousCols.indexOf(col) < 0) { setFlagFunc(col, true); } }); return res; }; ColumnController.prototype.extractPivotColumns = function (source, oldPrimaryColumns) { this.pivotColumns = this.extractColumns(oldPrimaryColumns, this.pivotColumns, function (col, flag) { return col.setPivotActive(flag, source); }, function (colDef) { return colDef.pivotIndex; }, function (colDef) { return colDef.initialPivotIndex; }, function (colDef) { return colDef.pivot; }, function (colDef) { return colDef.initialPivot; }); }; ColumnController.prototype.resetColumnGroupState = function (source) { if (source === void 0) { source = "api"; } var stateItems = []; this.columnUtils.depthFirstOriginalTreeSearch(null, this.primaryColumnTree, function (child) { if (child instanceof OriginalColumnGroup) { var groupState = { groupId: child.getGroupId(), open: child.getColGroupDef().openByDefault }; stateItems.push(groupState); } }); this.setColumnGroupState(stateItems, source); }; ColumnController.prototype.getColumnGroupState = function () { var columnGroupState = []; this.columnUtils.depthFirstOriginalTreeSearch(null, this.gridBalancedTree, function (node) { if (node instanceof OriginalColumnGroup) { var originalColumnGroup = node; columnGroupState.push({ groupId: originalColumnGroup.getGroupId(), open: originalColumnGroup.isExpanded() }); } }); return columnGroupState; }; ColumnController.prototype.setColumnGroupState = function (stateItems, source) { var _this = this; if (source === void 0) { source = "api"; } this.columnAnimationService.start(); var impactedGroups = []; stateItems.forEach(function (stateItem) { var groupKey = stateItem.groupId; var newValue = stateItem.open; var originalColumnGroup = _this.getOriginalColumnGroup(groupKey); if (!originalColumnGroup) { return; } if (originalColumnGroup.isExpanded() === newValue) { return; } _this.logger.log('columnGroupOpened(' + originalColumnGroup.getGroupId() + ',' + newValue + ')'); originalColumnGroup.setExpanded(newValue); impactedGroups.push(originalColumnGroup); }); this.updateGroupsAndDisplayedColumns(source); this.setFirstRightAndLastLeftPinned(source); impactedGroups.forEach(function (originalColumnGroup) { var event = { type: Events.EVENT_COLUMN_GROUP_OPENED, columnGroup: originalColumnGroup, api: _this.gridApi, columnApi: _this.columnApi }; _this.eventService.dispatchEvent(event); }); this.columnAnimationService.finish(); }; // called by headerRenderer - when a header is opened or closed ColumnController.prototype.setColumnGroupOpened = function (key, newValue, source) { if (source === void 0) { source = "api"; } var keyAsString; if (key instanceof OriginalColumnGroup) { keyAsString = key.getId(); } else { keyAsString = key; } this.setColumnGroupState([{ groupId: keyAsString, open: newValue }], source); }; ColumnController.prototype.getOriginalColumnGroup = function (key) { if (key instanceof OriginalColumnGroup) { return key; } if (typeof key !== 'string') { console.error('ag-Grid: group key must be a string'); } // otherwise, search for the column group by id var res = null; this.columnUtils.depthFirstOriginalTreeSearch(null, this.gridBalancedTree, function (node) { if (node instanceof OriginalColumnGroup) { var originalColumnGroup = node; if (originalColumnGroup.getId() === key) { res = originalColumnGroup; } } }); return res; }; ColumnController.prototype.calculateColumnsForDisplay = function () { var _this = this; var columnsForDisplay; if (this.pivotMode && !this.secondaryColumnsPresent) { // pivot mode is on, but we are not pivoting, so we only // show columns we are aggregating on columnsForDisplay = this.gridColumns.filter(function (column) { var isAutoGroupCol = _this.groupAutoColumns && includes(_this.groupAutoColumns, column); var isValueCol = _this.valueColumns && includes(_this.valueColumns, column); return isAutoGroupCol || isValueCol; }); } else { // otherwise continue as normal. this can be working on the primary // or secondary columns, whatever the gridColumns are set to columnsForDisplay = this.gridColumns.filter(function (column) { // keep col if a) it's auto-group or b) it's visible var isAutoGroupCol = _this.groupAutoColumns && includes(_this.groupAutoColumns, column); return isAutoGroupCol || column.isVisible(); }); } return columnsForDisplay; }; ColumnController.prototype.checkColSpanActiveInCols = function (columns) { var result = false; columns.forEach(function (col) { if (exists(col.getColDef().colSpan)) { result = true; } }); return result; }; ColumnController.prototype.calculateColumnsForGroupDisplay = function () { var _this = this; this.groupDisplayColumns = []; var checkFunc = function (col) { var colDef = col.getColDef(); if (colDef && exists(colDef.showRowGroup)) { _this.groupDisplayColumns.push(col); } }; this.gridColumns.forEach(checkFunc); if (this.groupAutoColumns) { this.groupAutoColumns.forEach(checkFunc); } }; ColumnController.prototype.getGroupDisplayColumns = function () { return this.groupDisplayColumns; }; ColumnController.prototype.updateDisplayedColumns = function (source) { var columnsForDisplay = this.calculateColumnsForDisplay(); this.buildDisplayedTrees(columnsForDisplay); this.calculateColumnsForGroupDisplay(); // also called when group opened/closed this.updateGroupsAndDisplayedColumns(source); // also called when group opened/closed this.setFirstRightAndLastLeftPinned(source); }; ColumnController.prototype.isSecondaryColumnsPresent = function () { return this.secondaryColumnsPresent; }; ColumnController.prototype.setSecondaryColumns = function (colDefs, source) { if (source === void 0) { source = "api"; } var newColsPresent = colDefs && colDefs.length > 0; // if not cols passed, and we had to cols anyway, then do nothing if (!newColsPresent && !this.secondaryColumnsPresent) { return; } if (newColsPresent) { this.processSecondaryColumnDefinitions(colDefs); var balancedTreeResult = this.columnFactory.createColumnTree(colDefs, false); this.secondaryBalancedTree = balancedTreeResult.columnTree; this.secondaryHeaderRowCount = balancedTreeResult.treeDept + 1; this.secondaryColumns = this.getColumnsFromTree(this.secondaryBalancedTree); this.secondaryColumnsPresent = true; } else { this.secondaryBalancedTree = null; this.secondaryHeaderRowCount = -1; this.secondaryColumns = null; this.secondaryColumnsPresent = false; } this.updateGridColumns(); this.updateDisplayedColumns(source); }; ColumnController.prototype.processSecondaryColumnDefinitions = function (colDefs) { var columnCallback = this.gridOptionsWrapper.getProcessSecondaryColDefFunc(); var groupCallback = this.gridOptionsWrapper.getProcessSecondaryColGroupDefFunc(); if (!columnCallback && !groupCallback) { return undefined; } var searchForColDefs = function (colDefs2) { colDefs2.forEach(function (abstractColDef) { var isGroup = exists(abstractColDef.children); if (isGroup) { var colGroupDef = abstractColDef; if (groupCallback) { groupCallback(colGroupDef); } searchForColDefs(colGroupDef.children); } else { var colDef = abstractColDef; if (columnCallback) { columnCallback(colDef); } } }); }; if (colDefs) { searchForColDefs(colDefs); } }; // called from: setColumnState, setColumnDefs, setSecondaryColumns ColumnController.prototype.updateGridColumns = function () { var _this = this; if (this.gridColsArePrimary) { this.lastPrimaryOrder = this.gridColumns; } if (this.secondaryColumns && this.secondaryBalancedTree) { this.gridBalancedTree = this.secondaryBalancedTree.slice(); this.gridHeaderRowCount = this.secondaryHeaderRowCount; this.gridColumns = this.secondaryColumns.slice(); this.gridColsArePrimary = false; } else { this.gridBalancedTree = this.primaryColumnTree.slice(); this.gridHeaderRowCount = this.primaryHeaderRowCount; this.gridColumns = this.primaryColumns.slice(); this.gridColsArePrimary = true; // updateGridColumns gets called after user adds a row group. we want to maintain the order of the columns // when this happens (eg if user moved a column) rather than revert back to the original column order. // likewise if changing in/out of pivot mode, we want to maintain the order of the primary cols this.orderGridColsLikeLastPrimary(); } this.addAutoGroupToGridColumns(); this.autoRowHeightColumns = this.gridColumns.filter(function (col) { return col.getColDef().autoHeight; }); this.putFixedColumnsFirst(); this.setupQuickFilterColumns(); this.clearDisplayedColumns(); this.colSpanActive = this.checkColSpanActiveInCols(this.gridColumns); this.gridColumnsMap = {}; this.gridColumns.forEach(function (col) { return _this.gridColumnsMap[col.getId()] = col; }); var event = { type: Events.EVENT_GRID_COLUMNS_CHANGED, api: this.gridApi, columnApi: this.columnApi }; this.eventService.dispatchEvent(event); }; ColumnController.prototype.orderGridColsLikeLastPrimary = function () { var _this = this; if (missing(this.lastPrimaryOrder)) { return; } // only do the sort if at least one column is accounted for. columns will be not accounted for // if changing from secondary to primary columns var noColsFound = true; this.gridColumns.forEach(function (col) { if (_this.lastPrimaryOrder.indexOf(col) >= 0) { noColsFound = false; } }); if (noColsFound) { return; } // order cols in the same order as before. we need to make sure that all // cols still exists, so filter out any that no longer exist. var oldColsOrdered = this.lastPrimaryOrder.filter(function (col) { return _this.gridColumns.indexOf(col) >= 0; }); var newColsOrdered = this.gridColumns.filter(function (col) { return oldColsOrdered.indexOf(col) < 0; }); // add in the new columns, at the end (if no group), or at the end of the group (if a group) var newGridColumns = oldColsOrdered.slice(); newColsOrdered.forEach(function (newCol) { var parent = newCol.getOriginalParent(); // if no parent, means we are not grouping, so just add the column to the end if (!parent) { newGridColumns.push(newCol); return; } // find the group the column belongs to. if no siblings at the current level (eg col in group on it's // own) then go up one level and look for siblings there. var siblings = []; while (!siblings.length && parent) { var leafCols = parent.getLeafColumns(); leafCols.forEach(function (leafCol) { var presentInNewGriColumns = newGridColumns.indexOf(leafCol) >= 0; var noYetInSiblings = siblings.indexOf(leafCol) < 0; if (presentInNewGriColumns && noYetInSiblings) { siblings.push(leafCol); } }); parent = parent.getOriginalParent(); } // if no siblings exist at any level, this means the col is in a group (or parent groups) on it's own if (!siblings.length) { newGridColumns.push(newCol); return; } // find index of last column in the group var indexes = siblings.map(function (col) { return newGridColumns.indexOf(col); }); var lastIndex = Math.max.apply(Math, indexes); insertIntoArray(newGridColumns, newCol, lastIndex + 1); }); this.gridColumns = newGridColumns; }; ColumnController.prototype.isPrimaryColumnGroupsPresent = function () { return this.primaryHeaderRowCount > 1; }; // if we are using autoGroupCols, then they should be included for quick filter. this covers the // following scenarios: // a) user provides 'field' into autoGroupCol of normal grid, so now because a valid col to filter leafs on // b) using tree data and user depends on autoGroupCol for first col, and we also want to filter on this // (tree data is a bit different, as parent rows can be filtered on, unlike row grouping) ColumnController.prototype.setupQuickFilterColumns = function () { if (this.groupAutoColumns) { this.columnsForQuickFilter = this.primaryColumns.concat(this.groupAutoColumns); } else { this.columnsForQuickFilter = this.primaryColumns; } }; ColumnController.prototype.putFixedColumnsFirst = function () { var locked = this.gridColumns.filter(function (c) { return c.getColDef().lockPosition; }); var unlocked = this.gridColumns.filter(function (c) { return !c.getColDef().lockPosition; }); this.gridColumns = locked.concat(unlocked); }; ColumnController.prototype.addAutoGroupToGridColumns = function () { // add in auto-group here this.createGroupAutoColumnsIfNeeded(); if (missing(this.groupAutoColumns)) { return; } this.gridColumns = this.groupAutoColumns ? this.groupAutoColumns.concat(this.gridColumns) : this.gridColumns; var autoColBalancedTree = this.columnFactory.createForAutoGroups(this.groupAutoColumns, this.gridBalancedTree); this.gridBalancedTree = autoColBalancedTree.concat(this.gridBalancedTree); }; // gets called after we copy down grid columns, to make sure any part of the gui // that tries to draw, eg the header, it will get empty lists of columns rather // than stale columns. for example, the header will received gridColumnsChanged // event, so will try and draw, but it will draw successfully when it acts on the // virtualColumnsChanged event ColumnController.prototype.clearDisplayedColumns = function () { this.displayedLeftColumnTree = []; this.displayedRightColumnTree = []; this.displayedCentreColumnTree = []; this.displayedLeftHeaderRows = {}; this.displayedRightHeaderRows = {}; this.displayedCentreHeaderRows = {}; this.displayedLeftColumns = []; this.displayedRightColumns = []; this.displayedCenterColumns = []; this.allDisplayedColumns = []; this.allDisplayedVirtualColumns = []; }; ColumnController.prototype.updateGroupsAndDisplayedColumns = function (source) { this.updateOpenClosedVisibilityInColumnGroups(); this.updateDisplayedColumnsFromTrees(source); this.refreshFlexedColumns(); this.updateVirtualSets(); this.updateBodyWidths(); // this event is picked up by the gui, headerRenderer and rowRenderer, to recalculate what columns to display var event = { type: Events.EVENT_DISPLAYED_COLUMNS_CHANGED, api: this.gridApi, columnApi: this.columnApi }; this.eventService.dispatchEvent(event); }; ColumnController.prototype.updateDisplayedColumnsFromTrees = function (source) { this.addToDisplayedColumns(this.displayedLeftColumnTree, this.displayedLeftColumns); this.addToDisplayedColumns(this.displayedCentreColumnTree, this.displayedCenterColumns); this.addToDisplayedColumns(this.displayedRightColumnTree, this.displayedRightColumns); this.setupAllDisplayedColumns(); this.setLeftValues(source); }; ColumnController.prototype.setupAllDisplayedColumns = function () { if (this.gridOptionsWrapper.isEnableRtl()) { this.allDisplayedColumns = this.displayedRightColumns .concat(this.displayedCenterColumns) .concat(this.displayedLeftColumns); } else { this.allDisplayedColumns = this.displayedLeftColumns .concat(this.displayedCenterColumns) .concat(this.displayedRightColumns); } }; // sets the left pixel position of each column ColumnController.prototype.setLeftValues = function (source) { this.setLeftValuesOfColumns(source); this.setLeftValuesOfGroups(); }; ColumnController.prototype.setLeftValuesOfColumns = function (source) { var _this = this; // go through each list of displayed columns var allColumns = this.primaryColumns.slice(0); // let totalColumnWidth = this.getWidthOfColsInList() var doingRtl = this.gridOptionsWrapper.isEnableRtl(); [ this.displayedLeftColumns, this.displayedRightColumns, this.displayedCenterColumns ].forEach(function (columns) { if (doingRtl) { // when doing RTL, we start at the top most pixel (ie RHS) and work backwards var left_1 = _this.getWidthOfColsInList(columns); columns.forEach(function (column) { left_1 -= column.getActualWidth(); column.setLeft(left_1, source); }); } else { // otherwise normal LTR, we start at zero var left_2 = 0; columns.forEach(function (column) { column.setLeft(left_2, source); left_2 += column.getActualWidth(); }); } removeAllFromArray(allColumns, columns); }); // items left in allColumns are columns not displayed, so remove the left position. this is // important for the rows, as if a col is made visible, then taken out, then made visible again, // we don't want the animation of the cell floating in from the old position, whatever that was. allColumns.forEach(function (column) { column.setLeft(null, source); }); }; ColumnController.prototype.setLeftValuesOfGroups = function () { // a groups left value is the lest left value of it's children [ this.displayedLeftColumnTree, this.displayedRightColumnTree, this.displayedCentreColumnTree ].forEach(function (columns) { columns.forEach(function (column) { if (column instanceof ColumnGroup) { var columnGroup = column; columnGroup.checkLeft(); } }); }); }; ColumnController.prototype.addToDisplayedColumns = function (displayedColumnTree, displayedColumns) { displayedColumns.length = 0; this.columnUtils.depthFirstDisplayedColumnTreeSearch(displayedColumnTree, function (child) { if (child instanceof Column) { displayedColumns.push(child); } }); }; ColumnController.prototype.updateDisplayedCenterVirtualColumns = function () { if (this.suppressColumnVirtualisation) { // no virtualisation, so don't filter this.allDisplayedCenterVirtualColumns = this.displayedCenterColumns; } else { // filter out what should be visible this.allDisplayedCenterVirtualColumns = this.filterOutColumnsWithinViewport(); } this.allDisplayedVirtualColumns = this.allDisplayedCenterVirtualColumns .concat(this.displayedLeftColumns) .concat(this.displayedRightColumns); // return map of virtual col id's, for easy lookup when building the groups. // the map will be colId=>true, ie col id's mapping to 'true'. var result = {}; this.allDisplayedVirtualColumns.forEach(function (col) { result[col.getId()] = true; }); return result; }; ColumnController.prototype.getVirtualHeaderGroupRow = function (type, dept) { var result; switch (type) { case Constants.PINNED_LEFT: result = this.displayedLeftHeaderRows[dept]; break; case Constants.PINNED_RIGHT: result = this.displayedRightHeaderRows[dept]; break; default: result = this.displayedCentreHeaderRows[dept]; break; } if (missing(result)) { result = []; } return result; }; ColumnController.prototype.updateDisplayedVirtualGroups = function (virtualColIds) { // go through each group, see if any of it's cols are displayed, and if yes, // then this group is included this.displayedLeftHeaderRows = {}; this.displayedRightHeaderRows = {}; this.displayedCentreHeaderRows = {}; var testGroup = function (children, result, dept) { var returnValue = false; for (var i = 0; i < children.length; i++) { // see if this item is within viewport var child = children[i]; var addThisItem = void 0; if (child instanceof Column) { // for column, test if column is included addThisItem = virtualColIds[child.getId()] === true; } else { // if group, base decision on children var columnGroup = child; addThisItem = testGroup(columnGroup.getDisplayedChildren(), result, dept + 1); } if (addThisItem) { returnValue = true; if (!result[dept]) { result[dept] = []; } result[dept].push(child); } } return returnValue; }; testGroup(this.displayedLeftColumnTree, this.displayedLeftHeaderRows, 0); testGroup(this.displayedRightColumnTree, this.displayedRightHeaderRows, 0); testGroup(this.displayedCentreColumnTree, this.displayedCentreHeaderRows, 0); }; ColumnController.prototype.updateVirtualSets = function () { var virtualColIds = this.updateDisplayedCenterVirtualColumns(); this.updateDisplayedVirtualGroups(virtualColIds); }; ColumnController.prototype.filterOutColumnsWithinViewport = function () { return this.displayedCenterColumns.filter(this.isColumnInViewport.bind(this)); }; ColumnController.prototype.refreshFlexedColumns = function (params) { var _this = this; if (params === void 0) { params = {}; } var source = params.source ? params.source : 'flex'; if (params.viewportWidth != null) { this.flexViewportWidth = params.viewportWidth; } if (!this.flexViewportWidth) { return; } // If the grid has left-over space, divide it between flexing columns in proportion to their flex value. // A "flexing column" is one that has a 'flex' value set and is not currently being constrained by its // minWidth or maxWidth rules. var flexAfterDisplayIndex = -1; if (params.resizingCols) { params.resizingCols.forEach(function (col) { var indexOfCol = _this.displayedCenterColumns.indexOf(col); if (flexAfterDisplayIndex < indexOfCol) { flexAfterDisplayIndex = indexOfCol; } }); } var isColFlex = function (col) { var afterResizingCols = _this.displayedCenterColumns.indexOf(col) > flexAfterDisplayIndex; return col.getFlex() && afterResizingCols; }; var knownWidthColumns = this.displayedCenterColumns.filter(function (col) { return !isColFlex(col); }); var flexingColumns = this.displayedCenterColumns.filter(function (col) { return isColFlex(col); }); var changedColumns = []; if (!flexingColumns.length) { return []; } var flexingColumnSizes = []; var spaceForFlexingColumns; outer: while (true) { var totalFlex = flexingColumns.reduce(function (count, col) { return count + col.getFlex(); }, 0); spaceForFlexingColumns = this.flexViewportWidth - this.getWidthOfColsInList(knownWidthColumns); for (var i = 0; i < flexingColumns.length; i++) { var col = flexingColumns[i]; var widthByFlexRule = spaceForFlexingColumns * col.getFlex() / totalFlex; var constrainedWidth = void 0; if (widthByFlexRule < col.getMinWidth()) { constrainedWidth = col.getMinWidth(); } else if (col.getMaxWidth() != null && widthByFlexRule > col.getMaxWidth()) { constrainedWidth = col.getMaxWidth(); } if (constrainedWidth) { // This column is not in fact flexing as it is being constrained to a specific size // so remove it from the list of flexing columns and start again col.setActualWidth(constrainedWidth, source); removeFromArray(flexingColumns, col); changedColumns.push(col); knownWidthColumns.push(col); continue outer; } flexingColumnSizes[i] = Math.round(widthByFlexRule); } break; } var remainingSpace = spaceForFlexingColumns; flexingColumns.forEach(function (col, i) { col.setActualWidth(Math.min(flexingColumnSizes[i], remainingSpace), source); changedColumns.push(col); remainingSpace -= flexingColumnSizes[i]; }); if (!params.skipSetLeft) { this.setLeftValues(source); } if (params.updateBodyWidths) { this.updateBodyWidths(); } if (params.fireResizedEvent) { this.fireColumnResizedEvent(changedColumns, true, source, flexingColumns); } // if the user sets rowData directly into GridOptions, then the row data is set before // grid is attached to the DOM. this means the columns are not flexed, and then the rows // have the wrong height (as they depend on column widths). so once the columns have // been flexed for the first time (only happens once grid is attached to DOM, as dependency // on getting the grid width, which only happens after attached after ResizeObserver fires) // we get get rows to re-calc their heights. if (!this.flexColsCalculatedAtLestOnce) { if (this.gridOptionsWrapper.isRowModelDefault()) { this.rowModel.resetRowHeights(); } this.flexColsCalculatedAtLestOnce = true; } return flexingColumns; }; // called from api ColumnController.prototype.sizeColumnsToFit = function (gridWidth, source, silent) { if (source === void 0) { source = "sizeColumnsToFit"; } // avoid divide by zero var allDisplayedColumns = this.getAllDisplayedColumns(); if (gridWidth <= 0 || !allDisplayedColumns.length) { return; } var colsToSpread = []; var colsToNotSpread = []; allDisplayedColumns.forEach(function (column) { if (column.getColDef().suppressSizeToFit === true) { colsToNotSpread.push(column); } else { colsToSpread.push(column); } }); // make a copy of the cols that are going to be resized var colsToFireEventFor = colsToSpread.slice(0); var finishedResizing = false; var moveToNotSpread = function (column) { removeFromArray(colsToSpread, column); colsToNotSpread.push(column); }; // resetting cols to their original width makes the sizeColumnsToFit more deterministic, // rather than depending on the current size of the columns. most users call sizeColumnsToFit // immediately after grid is created, so will make no difference. however if application is calling // sizeColumnsToFit repeatedly (eg after column group is opened / closed repeatedly) we don't want // the columns to start shrinking / growing over time. // // NOTE: the process below will assign values to `this.actualWidth` of each column without firing events // for this reason we need to manually fire resize events after the resize has been done for each column. colsToSpread.forEach(function (column) { return column.resetActualWidth(source); }); while (!finishedResizing) { finishedResizing = true; var availablePixels = gridWidth - this.getWidthOfColsInList(colsToNotSpread); if (availablePixels <= 0) { // no width, set everything to minimum colsToSpread.forEach(function (column) { column.setMinimum(source); }); } else { var scale = availablePixels / this.getWidthOfColsInList(colsToSpread); // we set the pixels for the last col based on what's left, as otherwise // we could be a pixel or two short or extra because of rounding errors. var pixelsForLastCol = availablePixels; // backwards through loop, as we are removing items as we go for (var i = colsToSpread.length - 1; i >= 0; i--) { var column = colsToSpread[i]; var minWidth = column.getMinWidth(); var maxWidth = column.getMaxWidth(); var newWidth = Math.round(column.getActualWidth() * scale); if (newWidth < minWidth) { newWidth = column.getMinWidth(); moveToNotSpread(column); finishedResizing = false; } else if (column.isGreaterThanMax(newWidth)) { newWidth = maxWidth; moveToNotSpread(column); finishedResizing = false; } else if (i === 0) { // if this is the last column newWidth = pixelsForLastCol; } column.setActualWidth(newWidth, source, true); pixelsForLastCol -= newWidth; } } } // see notes above colsToFireEventFor.forEach(function (col) { col.fireColumnWidthChangedEvent(source); }); this.setLeftValues(source); this.updateBodyWidths(); if (silent) { return; } this.fireColumnResizedEvent(colsToFireEventFor, true, source); }; ColumnController.prototype.buildDisplayedTrees = function (visibleColumns) { var leftVisibleColumns = []; var rightVisibleColumns = []; var centerVisibleColumns = []; visibleColumns.forEach(function (column) { switch (column.getPinned()) { case "left": leftVisibleColumns.push(column); break; case "right": rightVisibleColumns.push(column); break; default: centerVisibleColumns.push(column); break; } }); var groupInstanceIdCreator = new GroupInstanceIdCreator(); this.displayedLeftColumnTree = this.displayedGroupCreator.createDisplayedGroups(leftVisibleColumns, this.gridBalancedTree, groupInstanceIdCreator, Constants.PINNED_LEFT, this.displayedLeftColumnTree); this.displayedRightColumnTree = this.displayedGroupCreator.createDisplayedGroups(rightVisibleColumns, this.gridBalancedTree, groupInstanceIdCreator, Constants.PINNED_RIGHT, this.displayedRightColumnTree); this.displayedCentreColumnTree = this.displayedGroupCreator.createDisplayedGroups(centerVisibleColumns, this.gridBalancedTree, groupInstanceIdCreator, null, this.displayedCentreColumnTree); }; ColumnController.prototype.updateOpenClosedVisibilityInColumnGroups = function () { var allColumnGroups = this.getAllDisplayedColumnGroups(); this.columnUtils.depthFirstAllColumnTreeSearch(allColumnGroups, function (child) { if (child instanceof ColumnGroup) { var columnGroup = child; columnGroup.calculateDisplayedColumns(); } }); }; ColumnController.prototype.getGroupAutoColumns = function () { return this.groupAutoColumns; }; ColumnController.prototype.createGroupAutoColumnsIfNeeded = function () { if (!this.autoGroupsNeedBuilding) { return; } this.autoGroupsNeedBuilding = false; var groupFullWidthRow = this.gridOptionsWrapper.isGroupUseEntireRow(this.pivotMode); // we need to allow suppressing auto-column separately for group and pivot as the normal situation // is CSRM and user provides group column themselves for normal view, but when they go into pivot the // columns are generated by the grid so no opportunity for user to provide group column. so need a way // to suppress auto-col for grouping only, and not pivot. // however if using Viewport RM or SSRM and user is providing the columns, the user may wish full control // of the group column in this instance. var suppressAutoColumn = this.pivotMode ? this.gridOptionsWrapper.isPivotSuppressAutoColumn() : this.gridOptionsWrapper.isGroupSuppressAutoColumn(); var groupingActive = this.rowGroupColumns.length > 0 || this.usingTreeData; var needAutoColumns = groupingActive && !suppressAutoColumn && !groupFullWidthRow; if (needAutoColumns) { var newAutoGroupCols = this.autoGroupColService.createAutoGroupColumns(this.rowGroupColumns); var autoColsDifferent = !this.autoColsEqual(newAutoGroupCols, this.groupAutoColumns); // we force recreate when suppressColumnStateEvents changes, so new group cols pick up the new // definitions. otherwise we could ignore the new cols because they appear to be the same. if (autoColsDifferent || this.forceRecreateAutoGroups) { this.groupAutoColumns = newAutoGroupCols; } } else { this.groupAutoColumns = null; } }; ColumnController.prototype.autoColsEqual = function (colsA, colsB) { return areEqual(colsA, colsB, function (a, b) { return a.getColId() === b.getColId(); }); }; ColumnController.prototype.getWidthOfColsInList = function (columnList) { return columnList.reduce(function (width, col) { return width + col.getActualWidth(); }, 0); }; ColumnController.prototype.getGridBalancedTree = function () { return this.gridBalancedTree; }; ColumnController.prototype.hasFloatingFilters = function () { var defaultColDef = this.gridOptionsWrapper.getDefaultColDef(); return (defaultColDef != null && defaultColDef.floatingFilter === true) || (this.columnDefs != null && this.columnDefs.some(function (c) { return c.floatingFilter === true; })); }; ColumnController.prototype.getFirstDisplayedColumn = function () { var isRtl = this.gridOptionsWrapper.isEnableRtl(); var queryOrder = [ 'getDisplayedLeftColumns', 'getDisplayedCenterColumns', 'getDisplayedRightColumns' ]; if (isRtl) { queryOrder.reverse(); } for (var i = 0; i < queryOrder.length; i++) { var container = this[queryOrder[i]](); if (container.length) { return isRtl ? last(container) : container[0]; } } return null; }; __decorate$5([ Autowired('expressionService') ], ColumnController.prototype, "expressionService", void 0); __decorate$5([ Autowired('columnFactory') ], ColumnController.prototype, "columnFactory", void 0); __decorate$5([ Autowired('displayedGroupCreator') ], ColumnController.prototype, "displayedGroupCreator", void 0); __decorate$5([ Autowired('autoWidthCalculator') ], ColumnController.prototype, "autoWidthCalculator", void 0); __decorate$5([ Autowired('columnUtils') ], ColumnController.prototype, "columnUtils", void 0); __decorate$5([ Autowired('columnAnimationService') ], ColumnController.prototype, "columnAnimationService", void 0); __decorate$5([ Autowired('autoGroupColService') ], ColumnController.prototype, "autoGroupColService", void 0); __decorate$5([ Optional('aggFuncService') ], ColumnController.prototype, "aggFuncService", void 0); __decorate$5([ Optional('valueCache') ], ColumnController.prototype, "valueCache", void 0); __decorate$5([ Optional('animationFrameService') ], ColumnController.prototype, "animationFrameService", void 0); __decorate$5([ Autowired('rowModel') ], ColumnController.prototype, "rowModel", void 0); __decorate$5([ Autowired('columnApi') ], ColumnController.prototype, "columnApi", void 0); __decorate$5([ Autowired('gridApi') ], ColumnController.prototype, "gridApi", void 0); __decorate$5([ Autowired('sortController') ], ColumnController.prototype, "sortController", void 0); __decorate$5([ Autowired('columnDefFactory') ], ColumnController.prototype, "columnDefFactory", void 0); __decorate$5([ PostConstruct ], ColumnController.prototype, "init", null); __decorate$5([ __param$2(0, Qualifier('loggerFactory')) ], ColumnController.prototype, "setBeans", null); ColumnController = __decorate$5([ Bean('columnController') ], ColumnController); return ColumnController; }(BeanStub)); /** * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components * @version v25.0.0 * @link http://www.ag-grid.com/ * @license MIT */ function padStart(value, totalStringSize) { var asString = "" + value; while (asString.length < totalStringSize) { asString = "0" + asString; } return asString; } function createArrayOfNumbers(first, last) { var result = []; for (var i = first; i <= last; i++) { result.push(i); } return result; } /** * Check if a value is numeric * from http://stackoverflow.com/questions/9716468/is-there-any-function-like-isnumeric-in-javascript-to-validate-numbers * @param {any} value * @return {boolean} */ function isNumeric(value) { return value !== '' && !isNaN(parseFloat(value)) && isFinite(value); } function getMaxSafeInteger() { // eslint-disable-next-line return Number.MAX_SAFE_INTEGER || 9007199254740991; } function cleanNumber(value) { if (typeof value === 'string') { value = parseInt(value, 10); } if (typeof value === 'number') { return Math.floor(value); } else { return null; } } function decToHex(number, bytes) { var hex = ''; for (var i = 0; i < bytes; i++) { hex += String.fromCharCode(number & 0xff); number >>>= 8; } return hex; } function formatNumberTwoDecimalPlacesAndCommas(value) { if (typeof value !== 'number') { return ''; } return formatNumberCommas(Math.round(value * 100) / 100); } /** * the native method number.toLocaleString(undefined, {minimumFractionDigits: 0}) * puts in decimal places in IE, so we use this method instead * from: http://blog.tompawlak.org/number-currency-formatting-javascript * @param {number} value * @returns {string} */ function formatNumberCommas(value) { if (typeof value !== 'number') { return ''; } return value.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,"); } function sum(values) { return values == null ? null : values.reduce(function (total, value) { return total + value; }, 0); } var NumberUtils = /*#__PURE__*/Object.freeze({ __proto__: null, padStart: padStart, createArrayOfNumbers: createArrayOfNumbers, isNumeric: isNumeric, getMaxSafeInteger: getMaxSafeInteger, cleanNumber: cleanNumber, decToHex: decToHex, formatNumberTwoDecimalPlacesAndCommas: formatNumberTwoDecimalPlacesAndCommas, formatNumberCommas: formatNumberCommas, sum: sum }); /** * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components * @version v25.0.0 * @link http://www.ag-grid.com/ * @license MIT */ var __extends$2 = (undefined && undefined.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __decorate$6 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; // takes in a list of columns, as specified by the column definitions, and returns column groups var ColumnUtils = /** @class */ (function (_super) { __extends$2(ColumnUtils, _super); function ColumnUtils() { return _super !== null && _super.apply(this, arguments) || this; } ColumnUtils.prototype.calculateColInitialWidth = function (colDef) { var optionsWrapper = this.gridOptionsWrapper; var minColWidth = colDef.minWidth != null ? colDef.minWidth : optionsWrapper.getMinColWidth(); var maxColWidth = colDef.maxWidth != null ? colDef.maxWidth : (optionsWrapper.getMaxColWidth() || getMaxSafeInteger()); var width; var colDefWidth = attrToNumber(colDef.width); var colDefInitialWidth = attrToNumber(colDef.initialWidth); if (colDefWidth != null) { width = colDefWidth; } else if (colDefInitialWidth != null) { width = colDefInitialWidth; } else { width = optionsWrapper.getColWidth(); } return Math.max(Math.min(width, maxColWidth), minColWidth); }; ColumnUtils.prototype.getOriginalPathForColumn = function (column, originalBalancedTree) { var result = []; var found = false; var recursePath = function (balancedColumnTree, dept) { for (var i = 0; i < balancedColumnTree.length; i++) { if (found) { return; } // quit the search, so 'result' is kept with the found result var node = balancedColumnTree[i]; if (node instanceof OriginalColumnGroup) { var nextNode = node; recursePath(nextNode.getChildren(), dept + 1); result[dept] = node; } else if (node === column) { found = true; } } }; recursePath(originalBalancedTree, 0); // we should always find the path, but in case there is a bug somewhere, returning null // will make it fail rather than provide a 'hard to track down' bug return found ? result : null; }; ColumnUtils.prototype.depthFirstOriginalTreeSearch = function (parent, tree, callback) { var _this = this; if (!tree) { return; } tree.forEach(function (child) { if (child instanceof OriginalColumnGroup) { _this.depthFirstOriginalTreeSearch(child, child.getChildren(), callback); } callback(child, parent); }); }; ColumnUtils.prototype.depthFirstAllColumnTreeSearch = function (tree, callback) { var _this = this; if (!tree) { return; } tree.forEach(function (child) { if (child instanceof ColumnGroup) { _this.depthFirstAllColumnTreeSearch(child.getChildren(), callback); } callback(child); }); }; ColumnUtils.prototype.depthFirstDisplayedColumnTreeSearch = function (tree, callback) { var _this = this; if (!tree) { return; } tree.forEach(function (child) { if (child instanceof ColumnGroup) { _this.depthFirstDisplayedColumnTreeSearch(child.getDisplayedChildren(), callback); } callback(child); }); }; ColumnUtils = __decorate$6([ Bean('columnUtils') ], ColumnUtils); return ColumnUtils; }(BeanStub)); /** * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components * @version v25.0.0 * @link http://www.ag-grid.com/ * @license MIT */ var __extends$3 = (undefined && undefined.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __decorate$7 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; // takes in a list of columns, as specified by the column definitions, and returns column groups var DisplayedGroupCreator = /** @class */ (function (_super) { __extends$3(DisplayedGroupCreator, _super); function DisplayedGroupCreator() { return _super !== null && _super.apply(this, arguments) || this; } DisplayedGroupCreator.prototype.createDisplayedGroups = function ( // all displayed columns sorted - this is the columns the grid should show sortedVisibleColumns, // the tree of columns, as provided by the users, used to know what groups columns roll up into balancedColumnTree, // creates unique id's for the group groupInstanceIdCreator, // whether it's left, right or center col pinned, // we try to reuse old groups if we can, to allow gui to do animation oldDisplayedGroups) { var _this = this; var result = []; var previousRealPath; var previousOriginalPath; var oldColumnsMapped = this.mapOldGroupsById(oldDisplayedGroups); // go through each column, then do a bottom up comparison to the previous column, and start // to share groups if they converge at any point. sortedVisibleColumns.forEach(function (currentColumn) { var currentOriginalPath = _this.getOriginalPathForColumn(balancedColumnTree, currentColumn); var currentRealPath = []; var firstColumn = !previousOriginalPath; for (var i = 0; i < currentOriginalPath.length; i++) { if (firstColumn || currentOriginalPath[i] !== previousOriginalPath[i]) { // new group needed var newGroup = _this.createColumnGroup(currentOriginalPath[i], groupInstanceIdCreator, oldColumnsMapped, pinned); currentRealPath[i] = newGroup; // if top level, add to result, otherwise add to parent if (i == 0) { result.push(newGroup); } else { currentRealPath[i - 1].addChild(newGroup); } } else { // reuse old group currentRealPath[i] = previousRealPath[i]; } } var noColumnGroups = currentRealPath.length === 0; if (noColumnGroups) { // if we are not grouping, then the result of the above is an empty // path (no groups), and we just add the column to the root list. result.push(currentColumn); } else { var leafGroup = last(currentRealPath); leafGroup.addChild(currentColumn); } previousRealPath = currentRealPath; previousOriginalPath = currentOriginalPath; }); this.setupParentsIntoColumns(result, null); return result; }; DisplayedGroupCreator.prototype.createColumnGroup = function (originalGroup, groupInstanceIdCreator, oldColumnsMapped, pinned) { var groupId = originalGroup.getGroupId(); var instanceId = groupInstanceIdCreator.getInstanceIdForKey(groupId); var uniqueId = ColumnGroup.createUniqueId(groupId, instanceId); var columnGroup = oldColumnsMapped[uniqueId]; // if the user is setting new colDefs, it is possible that the id's overlap, and we // would have a false match from above. so we double check we are talking about the // same original column group. if (columnGroup && columnGroup.getOriginalColumnGroup() !== originalGroup) { columnGroup = null; } if (exists(columnGroup)) { // clean out the old column group here, as we will be adding children into it again columnGroup.reset(); } else { columnGroup = new ColumnGroup(originalGroup, groupId, instanceId, pinned); this.context.createBean(columnGroup); } return columnGroup; }; // returns back a 2d map of ColumnGroup as follows: groupId -> instanceId -> ColumnGroup DisplayedGroupCreator.prototype.mapOldGroupsById = function (displayedGroups) { var result = {}; var recursive = function (columnsOrGroups) { columnsOrGroups.forEach(function (columnOrGroup) { if (columnOrGroup instanceof ColumnGroup) { var columnGroup = columnOrGroup; result[columnOrGroup.getUniqueId()] = columnGroup; recursive(columnGroup.getChildren()); } }); }; if (displayedGroups) { recursive(displayedGroups); } return result; }; DisplayedGroupCreator.prototype.setupParentsIntoColumns = function (columnsOrGroups, parent) { var _this = this; columnsOrGroups.forEach(function (columnsOrGroup) { columnsOrGroup.setParent(parent); if (columnsOrGroup instanceof ColumnGroup) { var columnGroup = columnsOrGroup; _this.setupParentsIntoColumns(columnGroup.getChildren(), columnGroup); } }); }; DisplayedGroupCreator.prototype.getOriginalPathForColumn = function (balancedColumnTree, column) { var result = []; var found = false; var recursePath = function (balancedColumnTree, dept) { for (var i = 0; i < balancedColumnTree.length; i++) { // quit the search, so 'result' is kept with the found result if (found) { return; } var node = balancedColumnTree[i]; if (node instanceof OriginalColumnGroup) { var nextNode = node; recursePath(nextNode.getChildren(), dept + 1); result[dept] = node; } else if (node === column) { found = true; } } }; recursePath(balancedColumnTree, 0); // it's possible we didn't find a path. this happens if the column is generated // by the grid (auto-group), in that the definition didn't come from the client. in this case, // we create a fake original path. if (found) { return result; } console.warn('could not get path'); return null; }; __decorate$7([ Autowired('columnUtils') ], DisplayedGroupCreator.prototype, "columnUtils", void 0); DisplayedGroupCreator = __decorate$7([ Bean('displayedGroupCreator') ], DisplayedGroupCreator); return DisplayedGroupCreator; }(BeanStub)); /** * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components * @version v25.0.0 * @link http://www.ag-grid.com/ * @license MIT */ var __spreadArrays = (undefined && undefined.__spreadArrays) || function () { for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; for (var r = Array(s), k = 0, i = 0; i < il; i++) for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) r[k] = a[j]; return r; }; /** * These keys are used for validating properties supplied on a gridOptions object, and for code generation. * If you change the properties on the gridOptions interface, you *must* update this file as well to be consistent. */ var PropertyKeys = /** @class */ (function () { function PropertyKeys() { } PropertyKeys.STRING_PROPERTIES = [ 'sortingOrder', 'rowClass', 'rowSelection', 'overlayLoadingTemplate', 'overlayNoRowsTemplate', 'quickFilterText', 'rowModelType', 'editType', 'domLayout', 'clipboardDeliminator', 'rowGroupPanelShow', 'multiSortKey', 'pivotColumnGroupTotals', 'pivotRowTotals', 'pivotPanelShow', 'fillHandleDirection', 'serverSideStoreType' ]; PropertyKeys.OBJECT_PROPERTIES = [ 'components', 'frameworkComponents', 'rowStyle', 'context', 'autoGroupColumnDef', 'localeText', 'icons', 'datasource', 'serverSideDatasource', 'viewportDatasource', 'groupRowRendererParams', 'aggFuncs', 'fullWidthCellRendererParams', 'defaultColGroupDef', 'defaultColDef', 'defaultExportParams', 'columnTypes', 'rowClassRules', 'detailGridOptions', 'detailCellRendererParams', 'loadingCellRendererParams', 'loadingOverlayComponentParams', 'noRowsOverlayComponentParams', 'popupParent', 'colResizeDefault', 'reduxStore', 'statusBar', 'sideBar', 'chartThemeOverrides', 'customChartThemes' ]; PropertyKeys.ARRAY_PROPERTIES = [ 'alignedGrids', 'rowData', 'columnDefs', 'excelStyles', 'pinnedTopRowData', 'pinnedBottomRowData', 'chartThemes' ]; PropertyKeys.NUMBER_PROPERTIES = [ 'rowHeight', 'detailRowHeight', 'rowBuffer', 'colWidth', 'headerHeight', 'groupHeaderHeight', 'floatingFiltersHeight', 'pivotHeaderHeight', 'pivotGroupHeaderHeight', 'groupDefaultExpanded', 'minColWidth', 'maxColWidth', 'viewportRowModelPageSize', 'viewportRowModelBufferSize', 'autoSizePadding', 'maxBlocksInCache', 'maxConcurrentDatasourceRequests', 'tooltipShowDelay', 'cacheOverflowSize', 'paginationPageSize', 'cacheBlockSize', 'infiniteInitialRowCount', 'scrollbarWidth', 'batchUpdateWaitMillis', 'asyncTransactionWaitMillis', 'blockLoadDebounceMillis', 'keepDetailRowsCount', 'undoRedoCellEditingLimit', 'cellFlashDelay', 'cellFadeDelay' ]; PropertyKeys.BOOLEAN_PROPERTIES = [ 'suppressMakeColumnVisibleAfterUnGroup', 'suppressRowClickSelection', 'suppressCellSelection', 'suppressHorizontalScroll', 'alwaysShowVerticalScroll', 'debug', 'enableBrowserTooltips', 'enableCellExpressions', 'angularCompileRows', 'angularCompileFilters', 'groupSuppressAutoColumn', 'groupSelectsChildren', 'groupIncludeFooter', 'groupIncludeTotalFooter', 'groupUseEntireRow', 'groupSuppressBlankHeader', 'suppressMenuHide', 'suppressRowDeselection', 'unSortIcon', 'suppressMultiSort', 'singleClickEdit', 'suppressLoadingOverlay', 'suppressNoRowsOverlay', 'suppressAutoSize', 'skipHeaderOnAutoSize', 'suppressParentsInRowNodes', 'suppressColumnMoveAnimation', 'suppressMovableColumns', 'suppressFieldDotNotation', 'enableRangeSelection', 'enableRangeHandle', 'enableFillHandle', 'suppressClearOnFillReduction', 'deltaSort', 'suppressTouch', 'suppressAsyncEvents', 'allowContextMenuWithControlKey', 'suppressContextMenu', 'rememberGroupStateWhenNewData', 'enableCellChangeFlash', 'suppressDragLeaveHidesColumns', 'suppressMiddleClickScrolls', 'suppressPreventDefaultOnMouseWheel', 'suppressCopyRowsToClipboard', 'copyHeadersToClipboard', 'pivotMode', 'suppressAggFuncInHeader', 'suppressColumnVirtualisation', 'suppressAggAtRootLevel', 'suppressFocusAfterRefresh', 'functionsPassive', 'functionsReadOnly', 'animateRows', 'groupSelectsFiltered', 'groupRemoveSingleChildren', 'groupRemoveLowestSingleChildren', 'enableRtl', 'suppressClickEdit', 'rowDragManaged', 'suppressRowDrag', 'suppressMoveWhenRowDragging', 'enableMultiRowDragging', 'enableGroupEdit', 'embedFullWidthRows', 'deprecatedEmbedFullWidthRows', 'suppressPaginationPanel', 'floatingFilter', 'groupHideOpenParents', 'groupMultiAutoColumn', 'pagination', 'stopEditingWhenGridLosesFocus', 'paginationAutoPageSize', 'suppressScrollOnNewData', 'purgeClosedRowNodes', 'cacheQuickFilter', 'deltaRowDataMode', 'ensureDomOrder', 'accentedSort', 'suppressChangeDetection', 'valueCache', 'valueCacheNeverExpires', 'aggregateOnlyChangedColumns', 'suppressAnimationFrame', 'suppressExcelExport', 'suppressCsvExport', 'treeData', 'masterDetail', 'suppressMultiRangeSelection', 'enterMovesDownAfterEdit', 'enterMovesDown', 'suppressPropertyNamesCheck', 'rowMultiSelectWithClick', 'suppressEnterpriseResetOnNewColumns', 'enableOldSetFilterModel', 'suppressRowHoverHighlight', 'suppressRowTransform', 'suppressClipboardPaste', 'suppressLastEmptyLineOnPaste', 'serverSideSortingAlwaysResets', 'reactNext', 'suppressSetColumnStateEvents', 'suppressColumnStateEvents', 'enableCharts', 'deltaColumnMode', 'suppressMaintainUnsortedOrder', 'enableCellTextSelection', 'suppressBrowserResizeObserver', 'suppressMaxRenderedRowRestriction', 'excludeChildrenWhenTreeDataFiltering', 'tooltipMouseTrack', 'keepDetailRows', 'paginateChildRows', 'preventDefaultOnContextMenu', 'undoRedoCellEditing', 'allowDragFromColumnsToolPanel', 'immutableData', 'immutableColumns', 'pivotSuppressAutoColumn', 'suppressExpandablePivotGroups', 'applyColumnDefOrder', 'debounceVerticalScrollbar', 'detailRowAutoHeight', 'serverSideFilteringAlwaysResets', 'suppressAggFilteredOnly', 'showOpenedGroup', 'suppressClipboardApi' ]; /** You do not need to include event callbacks in this list, as they are generated automatically. */ PropertyKeys.FUNCTION_PROPERTIES = [ 'localeTextFunc', 'groupRowInnerRenderer', 'groupRowInnerRendererFramework', 'dateComponent', 'dateComponentFramework', 'groupRowRenderer', 'groupRowRendererFramework', 'isExternalFilterPresent', 'getRowHeight', 'doesExternalFilterPass', 'getRowClass', 'getRowStyle', 'getRowClassRules', 'traverseNode', 'getContextMenuItems', 'getMainMenuItems', 'processRowPostCreate', 'processCellForClipboard', 'groupRowAggNodes', 'getRowNodeId', 'isFullWidthCell', 'fullWidthCellRenderer', 'fullWidthCellRendererFramework', 'processSecondaryColDef', 'processSecondaryColGroupDef', 'getBusinessKeyForNode', 'sendToClipboard', 'navigateToNextHeader', 'tabToNextHeader', 'navigateToNextCell', 'tabToNextCell', 'getDetailRowData', 'processCellFromClipboard', 'getDocument', 'postProcessPopup', 'getChildCount', 'getDataPath', 'loadingCellRenderer', 'loadingCellRendererFramework', 'loadingOverlayComponent', 'loadingOverlayComponentFramework', 'noRowsOverlayComponent', 'noRowsOverlayComponentFramework', 'detailCellRenderer', 'detailCellRendererFramework', 'defaultGroupSortComparator', 'isRowMaster', 'isRowSelectable', 'postSort', 'processHeaderForClipboard', 'paginationNumberFormatter', 'processDataFromClipboard', 'getServerSideGroupKey', 'isServerSideGroup', 'suppressKeyboardEvent', 'createChartContainer', 'processChartOptions', 'getChartToolbarItems', 'fillOperation', 'isApplyServerSideTransaction', 'getServerSideStoreParams', 'isServerSideGroupOpenByDefault' ]; PropertyKeys.ALL_PROPERTIES = __spreadArrays(PropertyKeys.ARRAY_PROPERTIES, PropertyKeys.OBJECT_PROPERTIES, PropertyKeys.STRING_PROPERTIES, PropertyKeys.NUMBER_PROPERTIES, PropertyKeys.FUNCTION_PROPERTIES, PropertyKeys.BOOLEAN_PROPERTIES); /** * Used when performing property checks. This avoids noise caused when using frameworks, which can add their own * framework-specific properties to colDefs, gridOptions etc. */ PropertyKeys.FRAMEWORK_PROPERTIES = [ '__ob__', '__v_skip', '__metadata__', 'mappedColumnProperties', 'hasChildColumns', 'toColDef', 'createColDefFromGridColumn' ]; return PropertyKeys; }()); /** * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components * @version v25.0.0 * @link http://www.ag-grid.com/ * @license MIT */ var __spreadArrays$1 = (undefined && undefined.__spreadArrays) || function () { for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; for (var r = Array(s), k = 0, i = 0; i < il; i++) for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) r[k] = a[j]; return r; }; var ComponentUtil = /** @class */ (function () { function ComponentUtil() { } ComponentUtil.getEventCallbacks = function () { if (!ComponentUtil.EVENT_CALLBACKS) { ComponentUtil.EVENT_CALLBACKS = ComponentUtil.EVENTS.map(function (event) { return ComponentUtil.getCallbackForEvent(event); }); } return ComponentUtil.EVENT_CALLBACKS; }; ComponentUtil.copyAttributesToGridOptions = function (gridOptions, component, skipEventDeprecationCheck) { // create empty grid options if none were passed if (typeof gridOptions !== 'object') { gridOptions = {}; } // to allow array style lookup in TypeScript, take type away from 'this' and 'gridOptions' var pGridOptions = gridOptions; var keyExists = function (key) { return typeof component[key] !== 'undefined'; }; // add in all the simple properties __spreadArrays$1(ComponentUtil.ARRAY_PROPERTIES, ComponentUtil.STRING_PROPERTIES, ComponentUtil.OBJECT_PROPERTIES, ComponentUtil.FUNCTION_PROPERTIES, ComponentUtil.getEventCallbacks()).filter(keyExists) .forEach(function (key) { return pGridOptions[key] = component[key]; }); ComponentUtil.BOOLEAN_PROPERTIES .filter(keyExists) .forEach(function (key) { return pGridOptions[key] = ComponentUtil.toBoolean(component[key]); }); ComponentUtil.NUMBER_PROPERTIES .filter(keyExists) .forEach(function (key) { return pGridOptions[key] = ComponentUtil.toNumber(component[key]); }); return gridOptions; }; ComponentUtil.getCallbackForEvent = function (eventName) { if (!eventName || eventName.length < 2) { return eventName; } else { return 'on' + eventName[0].toUpperCase() + eventName.substr(1); } }; ComponentUtil.processOnChange = function (changes, gridOptions, api, columnApi) { if (!changes) { return; } // to allow array style lookup in TypeScript, take type away from 'this' and 'gridOptions' var pGridOptions = gridOptions; var keyExists = function (key) { return changes[key]; }; // check if any change for the simple types, and if so, then just copy in the new value __spreadArrays$1(ComponentUtil.ARRAY_PROPERTIES, ComponentUtil.OBJECT_PROPERTIES, ComponentUtil.STRING_PROPERTIES, ComponentUtil.getEventCallbacks()).filter(keyExists) .forEach(function (key) { return pGridOptions[key] = changes[key].currentValue; }); ComponentUtil.BOOLEAN_PROPERTIES .filter(keyExists) .forEach(function (key) { return pGridOptions[key] = ComponentUtil.toBoolean(changes[key].currentValue); }); ComponentUtil.NUMBER_PROPERTIES .filter(keyExists) .forEach(function (key) { return pGridOptions[key] = ComponentUtil.toNumber(changes[key].currentValue); }); if (changes.enableCellTextSelection) { api.setEnableCellTextSelection(ComponentUtil.toBoolean(changes.enableCellTextSelection.currentValue)); } if (changes.quickFilterText) { api.setQuickFilter(changes.quickFilterText.currentValue); } if (changes.rowData) { api.setRowData(changes.rowData.currentValue); } if (changes.pinnedTopRowData) { api.setPinnedTopRowData(changes.pinnedTopRowData.currentValue); } if (changes.pinnedBottomRowData) { api.setPinnedBottomRowData(changes.pinnedBottomRowData.currentValue); } if (changes.autoGroupColumnDef) { api.setAutoGroupColumnDef(changes.autoGroupColumnDef.currentValue, "gridOptionsChanged"); } if (changes.columnDefs) { api.setColumnDefs(changes.columnDefs.currentValue, "gridOptionsChanged"); } if (changes.datasource) { api.setDatasource(changes.datasource.currentValue); } if (changes.headerHeight) { api.setHeaderHeight(ComponentUtil.toNumber(changes.headerHeight.currentValue)); } if (changes.paginationPageSize) { api.paginationSetPageSize(ComponentUtil.toNumber(changes.paginationPageSize.currentValue)); } if (changes.pivotMode) { columnApi.setPivotMode(ComponentUtil.toBoolean(changes.pivotMode.currentValue)); } if (changes.groupRemoveSingleChildren) { api.setGroupRemoveSingleChildren(ComponentUtil.toBoolean(changes.groupRemoveSingleChildren.currentValue)); } if (changes.suppressRowDrag) { api.setSuppressRowDrag(ComponentUtil.toBoolean(changes.suppressRowDrag.currentValue)); } if (changes.suppressMoveWhenRowDragging) { api.setSuppressMoveWhenRowDragging(ComponentUtil.toBoolean(changes.suppressMoveWhenRowDragging.currentValue)); } if (changes.suppressRowClickSelection) { api.setSuppressRowClickSelection(ComponentUtil.toBoolean(changes.suppressRowClickSelection.currentValue)); } if (changes.suppressClipboardPaste) { api.setSuppressClipboardPaste(ComponentUtil.toBoolean(changes.suppressClipboardPaste.currentValue)); } if (changes.sideBar) { api.setSideBar(changes.sideBar.currentValue); } // copy changes into an event for dispatch var event = { type: Events.EVENT_COMPONENT_STATE_CHANGED, api: gridOptions.api, columnApi: gridOptions.columnApi }; iterateObject(changes, function (key, value) { event[key] = value; }); api.dispatchEvent(event); }; ComponentUtil.toBoolean = function (value) { if (typeof value === 'boolean') { return value; } else if (typeof value === 'string') { // for boolean, compare to empty String to allow attributes appearing with // no value to be treated as 'true' return value.toUpperCase() === 'TRUE' || value == ''; } else { return false; } }; ComponentUtil.toNumber = function (value) { if (typeof value === 'number') { return value; } else if (typeof value === 'string') { return Number(value); } else { return undefined; } }; // all the events are populated in here AFTER this class (at the bottom of the file). ComponentUtil.EVENTS = []; ComponentUtil.STRING_PROPERTIES = PropertyKeys.STRING_PROPERTIES; ComponentUtil.OBJECT_PROPERTIES = PropertyKeys.OBJECT_PROPERTIES; ComponentUtil.ARRAY_PROPERTIES = PropertyKeys.ARRAY_PROPERTIES; ComponentUtil.NUMBER_PROPERTIES = PropertyKeys.NUMBER_PROPERTIES; ComponentUtil.BOOLEAN_PROPERTIES = PropertyKeys.BOOLEAN_PROPERTIES; ComponentUtil.FUNCTION_PROPERTIES = PropertyKeys.FUNCTION_PROPERTIES; ComponentUtil.ALL_PROPERTIES = PropertyKeys.ALL_PROPERTIES; return ComponentUtil; }()); ComponentUtil.EVENTS = values(Events); /** * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components * @version v25.0.0 * @link http://www.ag-grid.com/ * @license MIT */ var __spreadArrays$2 = (undefined && undefined.__spreadArrays) || function () { for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; for (var r = Array(s), k = 0, i = 0; i < il; i++) for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) r[k] = a[j]; return r; }; var ColDefUtil = /** @class */ (function () { function ColDefUtil() { } ColDefUtil.STRING_PROPERTIES = [ 'headerName', 'columnGroupShow', 'headerClass', 'toolPanelClass', 'headerValueGetter', 'pivotKeys', 'groupId', 'colId', 'sort', 'initialSort', 'field', 'type', 'tooltipComponent', 'tooltipField', 'headerTooltip', 'cellClass', 'showRowGroup', 'template', 'templateUrl', 'filter', 'initialAggFunc', 'aggFunc', 'cellRenderer', 'cellEditor', 'pinned', 'initialPinned', 'chartDataType' ]; ColDefUtil.OBJECT_PROPERTIES = [ 'headerGroupComponent', 'headerGroupComponentFramework', 'headerGroupComponentParams', 'cellStyle', 'cellRendererParams', 'cellEditorFramework', 'cellEditorParams', 'pinnedRowCellRendererFramework', 'pinnedRowCellRendererParams', 'filterFramework', 'filterParams', 'pivotValueColumn', 'headerComponent', 'headerComponentFramework', 'headerComponentParams', 'floatingFilterComponent', 'floatingFilterComponentParams', 'floatingFilterComponentFramework', 'tooltipComponent', 'tooltipComponentParams', 'tooltipComponentFramework', 'refData', 'columnsMenuParams' ]; ColDefUtil.ARRAY_PROPERTIES = [ 'children', 'sortingOrder', 'allowedAggFuncs', 'menuTabs', 'pivotTotalColumnIds', 'cellClassRules', 'icons' ]; ColDefUtil.NUMBER_PROPERTIES = [ 'sortedAt', 'sortIndex', 'initialSortIndex', 'flex', 'initialFlex', 'width', 'initialWidth', 'minWidth', 'maxWidth', 'rowGroupIndex', 'initialRowGroupIndex', 'pivotIndex', 'initialPivotIndex' ]; ColDefUtil.BOOLEAN_PROPERTIES = [ 'suppressCellFlash', 'suppressColumnsToolPanel', 'suppressFiltersToolPanel', 'openByDefault', 'marryChildren', 'hide', 'initialHide', 'rowGroup', 'initialRowGroup', 'pivot', 'initialPivot', 'checkboxSelection', 'headerCheckboxSelection', 'headerCheckboxSelectionFilteredOnly', 'suppressMenu', 'suppressMovable', 'lockPosition', 'lockVisible', 'lockPinned', 'unSortIcon', 'suppressSizeToFit', 'suppressAutoSize', 'enableRowGroup', 'enablePivot', 'enableValue', 'editable', 'suppressPaste', 'suppressNavigable', 'enableCellChangeFlash', 'rowDrag', 'dndSource', 'autoHeight', 'wrapText', 'sortable', 'resizable', 'singleClickEdit', 'floatingFilter', ]; ColDefUtil.FUNCTION_PROPERTIES = [ 'dndSourceOnRowDrag', 'valueGetter', 'valueSetter', 'filterValueGetter', 'keyCreator', 'cellRenderer', 'cellRendererFramework', 'pinnedRowCellRenderer', 'valueFormatter', 'pinnedRowValueFormatter', 'valueParser', 'comparator', 'equals', 'pivotComparator', 'suppressKeyboardEvent', 'suppressHeaderKeyboardEvent', 'colSpan', 'rowSpan', 'getQuickFilterText', 'newValueHandler', 'onCellValueChanged', 'onCellClicked', 'onCellDoubleClicked', 'onCellContextMenu', 'rowDragText', 'tooltipValueGetter', 'tooltipComponent', 'tooltipComponentFramework', 'cellRendererSelector', 'cellEditorSelector' ]; ColDefUtil.ALL_PROPERTIES = __spreadArrays$2(ColDefUtil.ARRAY_PROPERTIES, ColDefUtil.OBJECT_PROPERTIES, ColDefUtil.STRING_PROPERTIES, ColDefUtil.NUMBER_PROPERTIES, ColDefUtil.FUNCTION_PROPERTIES, ColDefUtil.BOOLEAN_PROPERTIES); // used when doing property checks - this causes noise when using frameworks which can add their own fw specific // properties to colDefs, gridOptions etc ColDefUtil.FRAMEWORK_PROPERTIES = ['__ob__', '__v_skip', '__metadata__', 'mappedColumnProperties', 'hasChildColumns', 'toColDef', 'createColDefFromGridColumn']; return ColDefUtil; }()); /** * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components * @version v25.0.0 * @link http://www.ag-grid.com/ * @license MIT */ var Color = /** @class */ (function () { /** * Every color component should be in the [0, 1] range. * Some easing functions (such as elastic easing) can overshoot the target value by some amount. * So, when animating colors, if the source or target color components are already near * or at the edge of the allowed [0, 1] range, it is possible for the intermediate color * component value to end up outside of that range mid-animation. For this reason the constructor * performs range checking/constraining. * @param r Red component. * @param g Green component. * @param b Blue component. * @param a Alpha (opacity) component. */ function Color(r, g, b, a) { if (a === void 0) { a = 1; } // NaN is treated as 0. this.r = Math.min(1, Math.max(0, r || 0)); this.g = Math.min(1, Math.max(0, g || 0)); this.b = Math.min(1, Math.max(0, b || 0)); this.a = Math.min(1, Math.max(0, a || 0)); } /** * The given string can be in one of the following formats: * - #rgb * - #rrggbb * - rgb(r, g, b) * - rgba(r, g, b, a) * - CSS color name such as 'white', 'orange', 'cyan', etc. * @param str */ Color.fromString = function (str) { // hexadecimal notation if (str.indexOf('#') >= 0) { // there can be some leading whitespace return Color.fromHexString(str); } // color name var hex = Color.nameToHex[str]; if (hex) { return Color.fromHexString(hex); } // rgb(a) notation if (str.indexOf('rgb') >= 0) { return Color.fromRgbaString(str); } throw new Error("Invalid color string: '" + str + "'"); }; // Using separate RegExp for the short hex notation because strings like `#abcd` // are matched as ['#abcd', 'ab', 'c', 'd', undefined] when the `{1,2}` quantifier is used. Color.fromHexString = function (str) { var values = str.match(Color.hexRe); if (values) { var r = parseInt(values[1], 16); var g = parseInt(values[2], 16); var b = parseInt(values[3], 16); var a = values[4] !== undefined ? parseInt(values[4], 16) : 255; return new Color(r / 255, g / 255, b / 255, a / 255); } values = str.match(Color.shortHexRe); if (values) { var r = parseInt(values[1], 16); var g = parseInt(values[2], 16); var b = parseInt(values[3], 16); var a = values[4] !== undefined ? parseInt(values[4], 16) : 15; r += r * 16; g += g * 16; b += b * 16; a += a * 16; return new Color(r / 255, g / 255, b / 255, a / 255); } throw new Error("Malformed hexadecimal color string: '" + str + "'"); }; Color.fromRgbaString = function (str) { var values = str.match(Color.rgbRe); if (values) { return new Color(+values[1] / 255, +values[2] / 255, +values[3] / 255); } values = str.match(Color.rgbaRe); if (values) { return new Color(+values[1] / 255, +values[2] / 255, +values[3] / 255, +values[4]); } throw new Error("Malformed rgb/rgba color string: '" + str + "'"); }; Color.fromArray = function (arr) { if (arr.length === 4) { return new Color(arr[0], arr[1], arr[2], arr[3]); } if (arr.length === 3) { return new Color(arr[0], arr[1], arr[2]); } throw new Error('The given array should contain 3 or 4 color components (numbers).'); }; /** * Creates an instance of the Color class from the given HSB(A) components. * @param h Hue in the [0, 360) range. * @param s Saturation in the [0, 1] range. * @param b Brightness in the [0, 1] range. * @param alpha Opacity in the [0, 1] range. Defaults to 1 (completely opaque). */ Color.fromHSB = function (h, s, b, alpha) { if (alpha === void 0) { alpha = 1; } var rgb = Color.HSBtoRGB(h, s, b); return new Color(rgb[0], rgb[1], rgb[2], alpha); }; Color.padHex = function (str) { // Can't use `padStart(2, '0')` here because of IE. return str.length === 1 ? '0' + str : str; }; Color.prototype.toHexString = function () { var hex = '#' + Color.padHex(Math.round(this.r * 255).toString(16)) + Color.padHex(Math.round(this.g * 255).toString(16)) + Color.padHex(Math.round(this.b * 255).toString(16)); if (this.a < 1) { hex += Color.padHex(Math.round(this.a * 255).toString(16)); } return hex; }; Color.prototype.toRgbaString = function (fractionDigits) { if (fractionDigits === void 0) { fractionDigits = 3; } var components = [ Math.round(this.r * 255), Math.round(this.g * 255), Math.round(this.b * 255) ]; var k = Math.pow(10, fractionDigits); if (this.a !== 1) { components.push(Math.round(this.a * k) / k); return "rgba(" + components.join(', ') + ")"; } return "rgb(" + components.join(', ') + ")"; }; Color.prototype.toString = function () { if (this.a === 1) { return this.toHexString(); } return this.toRgbaString(); }; Color.prototype.toHSB = function () { return Color.RGBtoHSB(this.r, this.g, this.b); }; /** * Converts the given RGB triple to an array of HSB (HSV) components. * The hue component will be `NaN` for achromatic colors. */ Color.RGBtoHSB = function (r, g, b) { var min = Math.min(r, g, b); var max = Math.max(r, g, b); var S = max !== 0 ? (max - min) / max : 0; var H = NaN; // min == max, means all components are the same // and the color is a shade of gray with no hue (H is NaN) if (min !== max) { var delta = max - min; var rc = (max - r) / delta; var gc = (max - g) / delta; var bc = (max - b) / delta; if (r === max) { H = bc - gc; } else if (g === max) { H = 2.0 + rc - bc; } else { H = 4.0 + gc - rc; } H /= 6.0; if (H < 0) { H = H + 1.0; } } return [H * 360, S, max]; }; /** * Converts the given HSB (HSV) triple to an array of RGB components. */ Color.HSBtoRGB = function (H, S, B) { if (isNaN(H)) { H = 0; } H = (((H % 360) + 360) % 360) / 360; // normalize hue to [0, 360] interval, then scale to [0, 1] var r = 0; var g = 0; var b = 0; if (S === 0) { r = g = b = B; } else { var h = (H - Math.floor(H)) * 6; var f = h - Math.floor(h); var p = B * (1 - S); var q = B * (1 - S * f); var t = B * (1 - (S * (1 - f))); switch (h >> 0) { // discard the floating point part of the number case 0: r = B; g = t; b = p; break; case 1: r = q; g = B; b = p; break; case 2: r = p; g = B; b = t; break; case 3: r = p; g = q; b = B; break; case 4: r = t; g = p; b = B; break; case 5: r = B; g = p; b = q; break; } } return [r, g, b]; }; Color.prototype.derive = function (hueShift, saturationFactor, brightnessFactor, opacityFactor) { var hsb = Color.RGBtoHSB(this.r, this.g, this.b); var b = hsb[2]; if (b == 0 && brightnessFactor > 1.0) { b = 0.05; } var h = (((hsb[0] + hueShift) % 360) + 360) % 360; var s = Math.max(Math.min(hsb[1] * saturationFactor, 1.0), 0.0); b = Math.max(Math.min(b * brightnessFactor, 1.0), 0.0); var a = Math.max(Math.min(this.a * opacityFactor, 1.0), 0.0); var rgba = Color.HSBtoRGB(h, s, b); rgba.push(a); return Color.fromArray(rgba); }; Color.prototype.brighter = function () { return this.derive(0, 1.0, 1.0 / 0.7, 1.0); }; Color.prototype.darker = function () { return this.derive(0, 1.0, 0.7, 1.0); }; // See https://drafts.csswg.org/css-color/#hex-notation Color.hexRe = /\s*#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})?\s*$/; Color.shortHexRe = /\s*#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])?\s*$/; Color.rgbRe = /\s*rgb\((\d+),\s*(\d+),\s*(\d+)\)\s*/; Color.rgbaRe = /\s*rgba\((\d+),\s*(\d+),\s*(\d+),\s*([.\d]+)\)\s*/; /** * CSS Color Module Level 4: * https://drafts.csswg.org/css-color/#named-colors */ Color.nameToHex = Object.freeze({ aliceblue: '#F0F8FF', antiquewhite: '#FAEBD7', aqua: '#00FFFF', aquamarine: '#7FFFD4', azure: '#F0FFFF', beige: '#F5F5DC', bisque: '#FFE4C4', black: '#000000', blanchedalmond: '#FFEBCD', blue: '#0000FF', blueviolet: '#8A2BE2', brown: '#A52A2A', burlywood: '#DEB887', cadetblue: '#5F9EA0', chartreuse: '#7FFF00', chocolate: '#D2691E', coral: '#FF7F50', cornflowerblue: '#6495ED', cornsilk: '#FFF8DC', crimson: '#DC143C', cyan: '#00FFFF', darkblue: '#00008B', darkcyan: '#008B8B', darkgoldenrod: '#B8860B', darkgray: '#A9A9A9', darkgreen: '#006400', darkgrey: '#A9A9A9', darkkhaki: '#BDB76B', darkmagenta: '#8B008B', darkolivegreen: '#556B2F', darkorange: '#FF8C00', darkorchid: '#9932CC', darkred: '#8B0000', darksalmon: '#E9967A', darkseagreen: '#8FBC8F', darkslateblue: '#483D8B', darkslategray: '#2F4F4F', darkslategrey: '#2F4F4F', darkturquoise: '#00CED1', darkviolet: '#9400D3', deeppink: '#FF1493', deepskyblue: '#00BFFF', dimgray: '#696969', dimgrey: '#696969', dodgerblue: '#1E90FF', firebrick: '#B22222', floralwhite: '#FFFAF0', forestgreen: '#228B22', fuchsia: '#FF00FF', gainsboro: '#DCDCDC', ghostwhite: '#F8F8FF', gold: '#FFD700', goldenrod: '#DAA520', gray: '#808080', green: '#008000', greenyellow: '#ADFF2F', grey: '#808080', honeydew: '#F0FFF0', hotpink: '#FF69B4', indianred: '#CD5C5C', indigo: '#4B0082', ivory: '#FFFFF0', khaki: '#F0E68C', lavender: '#E6E6FA', lavenderblush: '#FFF0F5', lawngreen: '#7CFC00', lemonchiffon: '#FFFACD', lightblue: '#ADD8E6', lightcoral: '#F08080', lightcyan: '#E0FFFF', lightgoldenrodyellow: '#FAFAD2', lightgray: '#D3D3D3', lightgreen: '#90EE90', lightgrey: '#D3D3D3', lightpink: '#FFB6C1', lightsalmon: '#FFA07A', lightseagreen: '#20B2AA', lightskyblue: '#87CEFA', lightslategray: '#778899', lightslategrey: '#778899', lightsteelblue: '#B0C4DE', lightyellow: '#FFFFE0', lime: '#00FF00', limegreen: '#32CD32', linen: '#FAF0E6', magenta: '#FF00FF', maroon: '#800000', mediumaquamarine: '#66CDAA', mediumblue: '#0000CD', mediumorchid: '#BA55D3', mediumpurple: '#9370DB', mediumseagreen: '#3CB371', mediumslateblue: '#7B68EE', mediumspringgreen: '#00FA9A', mediumturquoise: '#48D1CC', mediumvioletred: '#C71585', midnightblue: '#191970', mintcream: '#F5FFFA', mistyrose: '#FFE4E1', moccasin: '#FFE4B5', navajowhite: '#FFDEAD', navy: '#000080', oldlace: '#FDF5E6', olive: '#808000', olivedrab: '#6B8E23', orange: '#FFA500', orangered: '#FF4500', orchid: '#DA70D6', palegoldenrod: '#EEE8AA', palegreen: '#98FB98', paleturquoise: '#AFEEEE', palevioletred: '#DB7093', papayawhip: '#FFEFD5', peachpuff: '#FFDAB9', peru: '#CD853F', pink: '#FFC0CB', plum: '#DDA0DD', powderblue: '#B0E0E6', purple: '#800080', rebeccapurple: '#663399', red: '#FF0000', rosybrown: '#BC8F8F', royalblue: '#4169E1', saddlebrown: '#8B4513', salmon: '#FA8072', sandybrown: '#F4A460', seagreen: '#2E8B57', seashell: '#FFF5EE', sienna: '#A0522D', silver: '#C0C0C0', skyblue: '#87CEEB', slateblue: '#6A5ACD', slategray: '#708090', slategrey: '#708090', snow: '#FFFAFA', springgreen: '#00FF7F', steelblue: '#4682B4', tan: '#D2B48C', teal: '#008080', thistle: '#D8BFD8', tomato: '#FF6347', turquoise: '#40E0D0', violet: '#EE82EE', wheat: '#F5DEB3', white: '#FFFFFF', whitesmoke: '#F5F5F5', yellow: '#FFFF00', yellowgreen: '#9ACD32' }); return Color; }()); /** * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components * @version v25.0.0 * @link http://www.ag-grid.com/ * @license MIT */ // Based on https://stackoverflow.com/a/14991797 // This will parse a delimited string into an array of arrays. function stringToArray(strData, delimiter) { if (delimiter === void 0) { delimiter = ','; } var data = []; var isNewline = function (char) { return char === '\r' || char === '\n'; }; var insideQuotedField = false; var _loop_1 = function (row, column, position) { var previousChar = strData[position - 1]; var currentChar = strData[position]; var nextChar = strData[position + 1]; var ensureDataExists = function () { if (!data[row]) { // create row if it doesn't exist data[row] = []; } if (!data[row][column]) { // create column if it doesn't exist data[row][column] = ''; } }; ensureDataExists(); if (currentChar === '"') { if (insideQuotedField) { if (nextChar === '"') { // unescape double quote data[row][column] += '"'; position++; } else { // exit quoted field insideQuotedField = false; } return out_row_1 = row, out_column_1 = column, out_position_1 = position, "continue"; } else if (previousChar === undefined || previousChar === delimiter || isNewline(previousChar)) { // enter quoted field insideQuotedField = true; return out_row_1 = row, out_column_1 = column, out_position_1 = position, "continue"; } } if (!insideQuotedField) { if (currentChar === delimiter) { // move to next column column++; ensureDataExists(); return out_row_1 = row, out_column_1 = column, out_position_1 = position, "continue"; } else if (isNewline(currentChar)) { // move to next row column = 0; row++; ensureDataExists(); if (currentChar === '\r' && nextChar === '\n') { // skip over second newline character if it exists position++; } return out_row_1 = row, out_column_1 = column, out_position_1 = position, "continue"; } } // add current character to current column data[row][column] += currentChar; out_row_1 = row; out_column_1 = column; out_position_1 = position; }; var out_row_1, out_column_1, out_position_1; // iterate over each character, keep track of current row and column (of the returned array) for (var row = 0, column = 0, position = 0; position < strData.length; position++) { _loop_1(row, column, position); row = out_row_1; column = out_column_1; position = out_position_1; } return data; } var CsvUtils = /*#__PURE__*/Object.freeze({ __proto__: null, stringToArray: stringToArray }); /** * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components * @version v25.0.0 * @link http://www.ag-grid.com/ * @license MIT */ /** * These variables are lazy loaded, as otherwise they try and get initialised when we are loading * unit tests and we don't have references to window or document in the unit tests * from http://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser */ var isSafari; var isIE; var isEdge; var isChrome; var isFirefox; var isIOS; function isBrowserIE() { if (isIE === undefined) { isIE = /*@cc_on!@*/ !!document.documentMode; // At least IE6 } return isIE; } function isBrowserEdge() { if (isEdge === undefined) { isEdge = !isBrowserIE() && !!window.StyleMedia; } return isEdge; } function isBrowserSafari() { if (isSafari === undefined) { // taken from https://stackoverflow.com/a/23522755/1388233 isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent); } return isSafari; } function isBrowserChrome() { if (isChrome === undefined) { var win = window; isChrome = (!!win.chrome && (!!win.chrome.webstore || !!win.chrome.runtime)) || (/Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor)); } return isChrome; } function isBrowserFirefox() { if (isFirefox === undefined) { var win = window; isFirefox = typeof win.InstallTrigger !== 'undefined'; } return isFirefox; } function isIOSUserAgent() { if (isIOS === undefined) { // taken from https://stackoverflow.com/a/58064481/1388233 isIOS = (/iPad|iPhone|iPod/.test(navigator.platform) || // eslint-disable-next-line (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1)) && !window.MSStream; } return isIOS; } function getTabIndex(el) { if (!el) { return null; } var numberTabIndex = el.tabIndex; var tabIndex = el.getAttribute('tabIndex'); if (isBrowserIE() && numberTabIndex === 0 && tabIndex === null) { var map = { a: true, body: true, button: true, frame: true, iframe: true, img: true, input: true, isindex: true, object: true, select: true, textarea: true }; return map[el.nodeName.toLowerCase()] === true ? '0' : null; } if (numberTabIndex === -1 && (tabIndex === null || (tabIndex === '' && !isBrowserFirefox()))) { return null; } return numberTabIndex.toString(); } function getMaxDivHeight() { if (!document.body) { return -1; } var res = 1000000; // FF reports the height back but still renders blank after ~6M px var testUpTo = navigator.userAgent.toLowerCase().match(/firefox/) ? 6000000 : 1000000000; var div = document.createElement('div'); document.body.appendChild(div); while (true) { var test_1 = res * 2; div.style.height = test_1 + 'px'; if (test_1 > testUpTo || div.clientHeight !== test_1) { break; } else { res = test_1; } } document.body.removeChild(div); return res; } function getScrollbarWidth() { var body = document.body; var div = document.createElement('div'); div.style.width = div.style.height = '100px'; div.style.opacity = '0'; div.style.overflow = 'scroll'; div.style.msOverflowStyle = 'scrollbar'; // needed for WinJS apps div.style.position = 'absolute'; body.appendChild(div); var width = div.offsetWidth - div.clientWidth; // if width is 0 and client width is 0, means the DOM isn't ready if (width === 0 && div.clientWidth === 0) { return null; } // remove divs if (div.parentNode) { div.parentNode.removeChild(div); } return width; } /** @deprecated */ function hasOverflowScrolling() { var prefixes = ['webkit', 'moz', 'o', 'ms']; var div = document.createElement('div'); var body = document.getElementsByTagName('body')[0]; var found = false; var p; body.appendChild(div); div.setAttribute('style', prefixes.map(function (prefix) { return "-" + prefix + "-overflow-scrolling: touch"; }).concat('overflow-scrolling: touch').join(';')); var computedStyle = window.getComputedStyle(div); if (computedStyle.overflowScrolling === 'touch') { found = true; } if (!found) { for (var _i = 0, prefixes_1 = prefixes; _i < prefixes_1.length; _i++) { p = prefixes_1[_i]; if (computedStyle[p + "OverflowScrolling"] === 'touch') { found = true; break; } } } if (div.parentNode) { div.parentNode.removeChild(div); } return found; } /** * Gets the document body width * from: http://stackoverflow.com/questions/1038727/how-to-get-browser-width-using-javascript-code * @returns {number} */ function getBodyWidth() { if (document.body) { return document.body.clientWidth; } if (window.innerHeight) { return window.innerWidth; } if (document.documentElement && document.documentElement.clientWidth) { return document.documentElement.clientWidth; } return -1; } /** * Gets the body height * from: http://stackoverflow.com/questions/1038727/how-to-get-browser-width-using-javascript-code * @returns {number} */ function getBodyHeight() { if (document.body) { return document.body.clientHeight; } if (window.innerHeight) { return window.innerHeight; } if (document.documentElement && document.documentElement.clientHeight) { return document.documentElement.clientHeight; } return -1; } var BrowserUtils = /*#__PURE__*/Object.freeze({ __proto__: null, isBrowserIE: isBrowserIE, isBrowserEdge: isBrowserEdge, isBrowserSafari: isBrowserSafari, isBrowserChrome: isBrowserChrome, isBrowserFirefox: isBrowserFirefox, isIOSUserAgent: isIOSUserAgent, getTabIndex: getTabIndex, getMaxDivHeight: getMaxDivHeight, getScrollbarWidth: getScrollbarWidth, hasOverflowScrolling: hasOverflowScrolling, getBodyWidth: getBodyWidth, getBodyHeight: getBodyHeight }); /** * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components * @version v25.0.0 * @link http://www.ag-grid.com/ * @license MIT */ var rtlNegativeScroll; function addCssClass(element, className) { if (!element || !className || className.length === 0) { return; } if (className.indexOf(' ') >= 0) { className.split(' ').forEach(function (value) { return addCssClass(element, value); }); return; } if (element.classList) { element.classList.add(className); } else if (element.className && element.className.length > 0) { var cssClasses = element.className.split(' '); if (cssClasses.indexOf(className) < 0) { cssClasses.push(className); element.setAttribute('class', cssClasses.join(' ')); } } else { // do not use element.classList = className here, it will cause // a read-only assignment error on some browsers (IE/Edge). element.setAttribute('class', className); } return element; } function removeCssClass(element, className) { if (!element || !className || className.length === 0) { return; } if (className.indexOf(' ') >= 0) { className.split(' ').forEach(function (value) { return removeCssClass(element, value); }); return; } if (element.classList) { element.classList.remove(className); } else if (element.className && element.className.length > 0) { var newClassName = element.className.split(' ').filter(function (c) { return c !== className; }).join(' '); element.setAttribute('class', newClassName); } } function addOrRemoveCssClass(element, className, addOrRemove) { if (addOrRemove) { addCssClass(element, className); } else { removeCssClass(element, className); } } /** * This method adds a class to an element and remove that class from all siblings. * Useful for toggling state. * @param {HTMLElement} element The element to receive the class * @param {string} elementClass The class to be assigned to the element * @param {boolean} otherElementClass The class to be assigned to siblings of the element, but not the element itself */ function radioCssClass(element, elementClass, otherElementClass) { var parent = element.parentElement; var sibling = parent.firstChild; while (sibling) { if (elementClass) { addOrRemoveCssClass(sibling, elementClass, sibling === element); } if (otherElementClass) { addOrRemoveCssClass(sibling, otherElementClass, sibling !== element); } sibling = sibling.nextSibling; } } function containsClass(element, className) { if (element.classList) { // for modern browsers return element.classList.contains(className); } if (element.className) { // for older browsers, check against the string of class names // if only one class, can check for exact match var onlyClass = element.className === className; // if many classes, check for class name, we have to pad with ' ' to stop other // class names that are a substring of this class var contains = element.className.indexOf(' ' + className + ' ') >= 0; // the padding above then breaks when it's the first or last class names var startsWithClass = element.className.indexOf(className + ' ') === 0; var endsWithClass = element.className.lastIndexOf(' ' + className) === (element.className.length - className.length - 1); return onlyClass || contains || startsWithClass || endsWithClass; } // if item is not a node return false; } function isFocusableFormField(element) { var matches = Element.prototype.matches || Element.prototype.msMatchesSelector; var isFocusable = matches.call(element, Constants.INPUT_SELECTOR); var isNotFocusable = matches.call(element, Constants.FOCUSABLE_EXCLUDE); var isElementVisible = isVisible(element); var focusable = isFocusable && !isNotFocusable && isElementVisible; return focusable; } function setDisplayed(element, displayed) { addOrRemoveCssClass(element, 'ag-hidden', !displayed); } function setVisible(element, visible) { addOrRemoveCssClass(element, 'ag-invisible', !visible); } function setDisabled(element, disabled) { var attributeName = 'disabled'; var addOrRemoveDisabledAttribute = disabled ? function (e) { return e.setAttribute(attributeName, ''); } : function (e) { return e.removeAttribute(attributeName); }; addOrRemoveDisabledAttribute(element); nodeListForEach(element.querySelectorAll('input'), function (input) { return addOrRemoveDisabledAttribute(input); }); } function isElementChildOfClass(element, cls, maxNest) { var counter = 0; while (element) { if (containsClass(element, cls)) { return true; } element = element.parentElement; if (maxNest && ++counter > maxNest) { break; } } return false; } function getElementSize(el) { var _a = window.getComputedStyle(el), height = _a.height, width = _a.width, paddingTop = _a.paddingTop, paddingRight = _a.paddingRight, paddingBottom = _a.paddingBottom, paddingLeft = _a.paddingLeft, marginTop = _a.marginTop, marginRight = _a.marginRight, marginBottom = _a.marginBottom, marginLeft = _a.marginLeft, boxSizing = _a.boxSizing; return { height: parseFloat(height), width: parseFloat(width), paddingTop: parseFloat(paddingTop), paddingRight: parseFloat(paddingRight), paddingBottom: parseFloat(paddingBottom), paddingLeft: parseFloat(paddingLeft), marginTop: parseFloat(marginTop), marginRight: parseFloat(marginRight), marginBottom: parseFloat(marginBottom), marginLeft: parseFloat(marginLeft), boxSizing: boxSizing }; } function getInnerHeight(el) { var size = getElementSize(el); if (size.boxSizing === 'border-box') { return size.height - size.paddingTop - size.paddingBottom; } return size.height; } function getInnerWidth(el) { var size = getElementSize(el); if (size.boxSizing === 'border-box') { return size.width - size.paddingLeft - size.paddingRight; } return size.width; } function getAbsoluteHeight(el) { var size = getElementSize(el); var marginRight = size.marginBottom + size.marginTop; return Math.ceil(el.offsetHeight + marginRight); } function getAbsoluteWidth(el) { var size = getElementSize(el); var marginWidth = size.marginLeft + size.marginRight; return Math.ceil(el.offsetWidth + marginWidth); } function isRtlNegativeScroll() { if (typeof rtlNegativeScroll === "boolean") { return rtlNegativeScroll; } var template = document.createElement('div'); template.style.direction = 'rtl'; template.style.width = '1px'; template.style.height = '1px'; template.style.position = 'fixed'; template.style.top = '0px'; template.style.overflow = 'hidden'; template.dir = 'rtl'; template.innerHTML = /* html */ "