UNPKG

ag-grid-community

Version:

Advanced Data Grid / Data Table supporting Javascript / Typescript / React / Angular / Vue

1,250 lines (1,240 loc) 2.43 MB
/** * @ag-grid-community/all-modules - Advanced Data Grid / Data Table supporting Javascript / Typescript / React / Angular / Vue * @version v29.2.0 * @link https://www.ag-grid.com/ * @license MIT */ /** * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / Typescript / React / Angular / Vue * @version v29.2.0 * @link https://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) { if (value == null || value === '') { return null; } return value; } function exists(value, allowEmptyString) { if (allowEmptyString === void 0) { allowEmptyString = false; } return value != null && (value !== '' || allowEmptyString); } function missing(value) { return !exists(value); } function missingOrEmpty(value) { return value == null || value.length === 0; } function toStringOrNull(value) { return value != null && typeof value.toString === 'function' ? 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 (typeof value === 'boolean') { // 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 values(object) { if (object instanceof Set || object instanceof Map) { var arr_1 = []; object.forEach(function (value) { return arr_1.push(value); }); return arr_1; } return Object.values(object); } 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, values: values }); /** * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / Typescript / React / Angular / Vue * @version v29.2.0 * @link https://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 / Typescript / React / Angular / Vue * @version v29.2.0 * @link https://www.ag-grid.com/ * @license MIT */ function iterateObject(object, callback) { if (object == null) { return; } if (Array.isArray(object)) { object.forEach(function (value, index) { return callback("" + index, value); }); } else { Object.keys(object).forEach(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]; } properties.forEach(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) { Object.keys(obj).forEach(function (key) { return allValues[key] = null; }); }); return Object.keys(allValues); } function getAllValuesInObject(obj) { if (!obj) { return []; } var anyObject = Object; if (typeof anyObject.values === 'function') { return anyObject.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 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; // Create empty objects keys.forEach(function (key, i) { if (!objectToUpdate[key]) { objectToUpdate[key] = {}; } if (i < keys.length - 1) { objectToUpdate = objectToUpdate[key]; } }); objectToUpdate[keys[keys.length - 1]] = value; } 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 destroyed.\n Please don't call grid API functions on destroyed grids - as a matter of fact you shouldn't\n be keeping the API reference, your application has a memory leak! Remove the API reference\n when 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, missingOrEmptyObject: missingOrEmptyObject, get: get, set: set, getValueUsingField: getValueUsingField, removeAllReferences: removeAllReferences, isNonNullObject: isNonNullObject }); /** * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / Typescript / React / Angular / Vue * @version v29.2.0 * @link https://www.ag-grid.com/ * @license MIT */ 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; } function isFunction(val) { return !!(val && val.constructor && val.call && val.apply); } function executeInAWhile(funcs) { executeAfter(funcs, 400); } var executeNextVMTurnFuncs = []; var executeNextVMTurnPending = false; function executeNextVMTurn(func) { executeNextVMTurnFuncs.push(func); if (executeNextVMTurnPending) { return; } executeNextVMTurnPending = true; window.setTimeout(function () { var funcsCopy = executeNextVMTurnFuncs.slice(); executeNextVMTurnFuncs.length = 0; executeNextVMTurnPending = false; funcsCopy.forEach(function (func) { return func(); }); }, 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); } } /** * @param {Function} func The function to be debounced * @param {number} delay The time in ms to debounce * @return {Function} The debounced function */ function debounce(func, delay) { 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]; } var context = this; window.clearTimeout(timeout); // Set the new timeout timeout = window.setTimeout(function () { func.apply(context, args); }, delay); }; } /** * @param {Function} func The function to be throttled * @param {number} wait The time in ms to throttle * @return {Function} The throttled function */ function throttle(func, wait) { var previousCall = 0; return function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } var context = this; var currentCall = new Date().getTime(); if (currentCall - previousCall < wait) { return; } previousCall = currentCall; func.apply(context, args); }; } function waitUntil(condition, callback, timeout, timeoutMessage) { if (timeout === void 0) { timeout = 100; } var timeStamp = new Date().getTime(); var interval = null; var executed = false; var internalCallback = function () { var reachedTimeout = ((new Date().getTime()) - timeStamp) > timeout; if (condition() || reachedTimeout) { callback(); executed = true; if (interval != null) { window.clearInterval(interval); interval = null; } if (reachedTimeout && timeoutMessage) { console.warn(timeoutMessage); } } }; internalCallback(); if (!executed) { interval = window.setInterval(internalCallback, 10); } } 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 noop = function () { return; }; var FunctionUtils = /*#__PURE__*/Object.freeze({ __proto__: null, doOnce: doOnce, getFunctionName: getFunctionName, isFunction: isFunction, executeInAWhile: executeInAWhile, executeNextVMTurn: executeNextVMTurn, executeAfter: executeAfter, debounce: debounce, throttle: throttle, waitUntil: waitUntil, compose: compose, callIfPresent: callIfPresent, noop: noop }); /** * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / Typescript / React / Angular / Vue * @version v29.2.0 * @link https://www.ag-grid.com/ * @license MIT */ var __read$v = (undefined && undefined.__read) || function (o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; var i = m.call(o), r, ar = [], e; try { while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } catch (error) { e = { error: error }; } finally { try { if (r && !r.done && (m = i["return"])) m.call(i); } finally { if (e) throw e.error; } } return ar; }; var __spread$o = (undefined && undefined.__spread) || function () { for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read$v(arguments[i])); return ar; }; 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 = new (beanEntry.bean.bind.apply(beanEntry.bean, __spread$o([null], 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 (BeanClass) { var metaData = BeanClass.__agBeanMetaData; if (!metaData) { var beanName = void 0; if (BeanClass.prototype.constructor) { beanName = getFunctionName(BeanClass.prototype.constructor); } else { beanName = "" + BeanClass; } console.error("Context item " + beanName + " is not a bean"); return; } var beanEntry = { bean: BeanClass, 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; }()); function PreConstruct(target, methodName, descriptor) { var props = getOrCreateProps$1(target.constructor); if (!props.preConstructMethods) { props.preConstructMethods = []; } props.preConstructMethods.push(methodName); } function PostConstruct(target, methodName, descriptor) { var props = getOrCreateProps$1(target.constructor); if (!props.postConstructMethods) { props.postConstructMethods = []; } props.postConstructMethods.push(methodName); } function PreDestroy(target, methodName, descriptor) { var props = getOrCreateProps$1(target.constructor); if (!props.preDestroyMethods) { props.preDestroyMethods = []; } props.preDestroyMethods.push(methodName); } function Bean(beanName) { return function (classConstructor) { var props = getOrCreateProps$1(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$1(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$1(constructor); methodName = methodOrAttributeName; } else { props = getOrCreateProps$1(constructor); methodName = "agConstructor"; } if (!props.autowireMethods) { props.autowireMethods = {}; } if (!props.autowireMethods[methodName]) { props.autowireMethods[methodName] = {}; } props.autowireMethods[methodName][index] = name; } }; } function getOrCreateProps$1(target) { if (!target.hasOwnProperty("__agBeanMetaData")) { target.__agBeanMetaData = {}; } return target.__agBeanMetaData; } /** * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / Typescript / React / Angular / Vue * @version v29.2.0 * @link https://www.ag-grid.com/ * @license MIT */ var __decorate$2z = (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$a = (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, gridOptionsService, frameworkOverrides, globalEventListener) { if (globalEventListener === void 0) { globalEventListener = null; } this.frameworkOverrides = frameworkOverrides; this.gridOptionsService = gridOptionsService; if (globalEventListener) { var async = gridOptionsService.useAsyncEvents(); this.addGlobalListener(globalEventListener, async); } }; EventService.prototype.getListeners = function (eventType, async, autoCreateListenerCollection) { var listenerMap = async ? this.allAsyncListeners : this.allSyncListeners; var listeners = listenerMap.get(eventType); // Note: 'autoCreateListenerCollection' should only be 'true' if a listener is about to be added. For instance // getListeners() is also called during event dispatch even though no listeners are added. This measure protects // against 'memory bloat' as empty collections will prevent the RowNode's event service from being removed after // the RowComp is destroyed, see noRegisteredListenersExist() below. if (!listeners && autoCreateListenerCollection) { listeners = new Set(); listenerMap.set(eventType, listeners); } return listeners; }; EventService.prototype.noRegisteredListenersExist = function () { return this.allSyncListeners.size === 0 && this.allAsyncListeners.size === 0 && this.globalSyncListeners.size === 0 && this.globalAsyncListeners.size === 0; }; EventService.prototype.addEventListener = function (eventType, listener, async) { if (async === void 0) { async = false; } this.getListeners(eventType, async, true).add(listener); }; EventService.prototype.removeEventListener = function (eventType, listener, async) { if (async === void 0) { async = false; } var listeners = this.getListeners(eventType, async, false); if (!listeners) { return; } listeners.delete(listener); if (listeners.size === 0) { var listenerMap = async ? this.allAsyncListeners : this.allSyncListeners; listenerMap.delete(eventType); } }; 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) { var agEvent = event; if (this.gridOptionsService) { // Apply common properties to all dispatched events if this event service has had its beans set with gridOptionsService. // Note there are multiple instances of EventService that are used local to components which do not set gridOptionsService. var _a = this.gridOptionsService, api = _a.api, columnApi = _a.columnApi, context = _a.context; agEvent.api = api; agEvent.columnApi = columnApi; agEvent.context = context; } this.dispatchToListeners(agEvent, true); this.dispatchToListeners(agEvent, false); this.firedEvents[agEvent.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; if (async && 'event' in event) { var browserEvent = event.event; if (browserEvent instanceof Event) { // AG-7893 - Persist composedPath() so that its result can still be accessed by the user asynchronously. // Within an async event handler if they call composedPath() on the event it will always return an empty []. event.eventPath = browserEvent.composedPath(); } } var processEventListeners = function (listeners) { return listeners.forEach(function (listener) { if (async) { _this.dispatchAsync(function () { return listener(event); }); } else { listener(event); } }); }; var listeners = this.getListeners(eventType, async, false); if (listeners) { processEventListeners(listeners); } 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); }, true); }); } else { _this.frameworkOverrides.dispatchEvent(eventType, function () { return listener(eventType, event); }, true); } }); }; // 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$2z([ __param$a(0, Qualifier('loggerFactory')), __param$a(1, Qualifier('gridOptionsService')), __param$a(2, Qualifier('frameworkOverrides')), __param$a(3, Qualifier('globalEventListener')) ], EventService.prototype, "setBeans", null); EventService = __decorate$2z([ Bean('eventService') ], EventService); return EventService; }()); /** * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / Typescript / React / Angular / Vue * @version v29.2.0 * @link https://www.ag-grid.com/ * @license MIT */ var ModuleNames; (function (ModuleNames) { ModuleNames["CommunityCoreModule"] = "@ag-grid-community/core"; // 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"; // enterprise core - users don't need to import on this, but other enterprise modules do ModuleNames["EnterpriseCoreModule"] = "@ag-grid-enterprise/core"; // enterprise modules ModuleNames["RowGroupingModule"] = "@ag-grid-enterprise/row-grouping"; ModuleNames["ColumnsToolPanelModule"] = "@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["SparklinesModule"] = "@ag-grid-enterprise/sparklines"; // 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"; // 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", })(ModuleNames || (ModuleNames = {})); /** * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / Typescript / React / Angular / Vue * @version v29.2.0 * @link https://www.ag-grid.com/ * @license MIT */ var __read$u = (undefined && undefined.__read) || function (o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; var i = m.call(o), r, ar = [], e; try { while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } catch (error) { e = { error: error }; } finally { try { if (r && !r.done && (m = i["return"])) m.call(i); } finally { if (e) throw e.error; } } return ar; }; var ModuleRegistry = /** @class */ (function () { function ModuleRegistry() { } ModuleRegistry.register = function (module, moduleBased) { if (moduleBased === void 0) { moduleBased = true; } ModuleRegistry.runVersionChecks(module); ModuleRegistry.modulesMap[module.moduleName] = module; ModuleRegistry.setModuleBased(moduleBased); }; ModuleRegistry.runVersionChecks = function (module) { if (!ModuleRegistry.currentModuleVersion) { ModuleRegistry.currentModuleVersion = module.version; } if (!module.version) { console.error("AG Grid: You are using incompatible versions of AG Grid modules. Major and minor versions should always match across modules. '" + module.moduleName + "' is incompatible. Please update all modules to the same version."); } else if (module.version !== ModuleRegistry.currentModuleVersion) { console.error("AG Grid: You are using incompatible versions of AG Grid modules. Major and minor versions should always match across modules. '" + module.moduleName + "' is version " + module.version + " but the other modules are version " + this.currentModuleVersion + ". Please update all modules to the same version."); } if (module.validate) { var result = module.validate(); if (!result.isValid) { var errorResult = result; console.error("AG Grid: " + errorResult.message); } } }; ModuleRegistry.setModuleBased = function (moduleBased) { 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/javascript-grid/packages-modules/ for more information.'); }, 'ModulePackageCheck'); } } }; /** * INTERNAL - Set if files are being served from a single UMD bundle to provide accurate enterprise upgrade steps. */ ModuleRegistry.setIsBundled = function () { ModuleRegistry.isBundled = true; }; // noinspection JSUnusedGlobalSymbols ModuleRegistry.registerModules = function (modules, moduleBased) { if (moduleBased === void 0) { moduleBased = true; } ModuleRegistry.setModuleBased(moduleBased); if (!modules) { return; } modules.forEach(function (module) { return ModuleRegistry.register(module, moduleBased); }); }; ModuleRegistry.assertRegistered = function (moduleName, reason) { var _a; if (this.isRegistered(moduleName)) { return true; } var warningKey = reason + moduleName; var warningMessage; if (ModuleRegistry.isBundled) { { warningMessage = "AG Grid: unable to use " + reason + " as 'ag-grid-enterprise' has not been loaded. Check you are using the Enterprise bundle:\n \n <script src=\"https://cdn.jsdelivr.net/npm/ag-grid-enterprise@AG_GRID_VERSION/dist/ag-grid-enterprise.min.js\"></script>\n \nFor more info see: https://ag-grid.com/javascript-data-grid/getting-started/#getting-started-with-ag-grid-enterprise"; } } else if (ModuleRegistry.moduleBased || ModuleRegistry.moduleBased === undefined) { var modName = (_a = Object.entries(ModuleNames).find(function (_a) { var _b = __read$u(_a, 2); _b[0]; var v = _b[1]; return v === moduleName; })) === null || _a === void 0 ? void 0 : _a[0]; warning