UNPKG

ag-grid-community

Version:

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

1,595 lines (1,583 loc) 1.87 MB
// packages/ag-grid-community/src/localEventService.ts var LocalEventService = class { constructor() { this.allSyncListeners = /* @__PURE__ */ new Map(); this.allAsyncListeners = /* @__PURE__ */ new Map(); this.globalSyncListeners = /* @__PURE__ */ new Set(); this.globalAsyncListeners = /* @__PURE__ */ 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 = {}; } setFrameworkOverrides(frameworkOverrides) { this.frameworkOverrides = frameworkOverrides; } getListeners(eventType, async, autoCreateListenerCollection) { const listenerMap = async ? this.allAsyncListeners : this.allSyncListeners; let listeners = listenerMap.get(eventType); if (!listeners && autoCreateListenerCollection) { listeners = /* @__PURE__ */ new Set(); listenerMap.set(eventType, listeners); } return listeners; } noRegisteredListenersExist() { return this.allSyncListeners.size === 0 && this.allAsyncListeners.size === 0 && this.globalSyncListeners.size === 0 && this.globalAsyncListeners.size === 0; } addEventListener(eventType, listener, async = false) { this.getListeners(eventType, async, true).add(listener); } removeEventListener(eventType, listener, async = false) { const listeners = this.getListeners(eventType, async, false); if (!listeners) { return; } listeners.delete(listener); if (listeners.size === 0) { (async ? this.allAsyncListeners : this.allSyncListeners).delete(eventType); } } addGlobalListener(listener, async = false) { this.getGlobalListeners(async).add(listener); } removeGlobalListener(listener, async = false) { this.getGlobalListeners(async).delete(listener); } dispatchEvent(event) { const agEvent = event; this.dispatchToListeners(agEvent, true); this.dispatchToListeners(agEvent, false); this.firedEvents[agEvent.type] = true; } dispatchEventOnce(event) { if (!this.firedEvents[event.type]) { this.dispatchEvent(event); } } dispatchToListeners(event, async) { const eventType = event.type; if (async && "event" in event) { const browserEvent = event.event; if (browserEvent instanceof Event) { event.eventPath = browserEvent.composedPath(); } } const { frameworkOverrides } = this; const runCallback = (func) => { const callback = frameworkOverrides ? () => frameworkOverrides.wrapIncoming(func) : func; if (async) { this.dispatchAsync(callback); } else { callback(); } }; const originalListeners = this.getListeners(eventType, async, false); if ((originalListeners?.size ?? 0) > 0) { const listeners = new Set(originalListeners); for (const listener of listeners) { if (!originalListeners?.has(listener)) { continue; } runCallback(() => listener(event)); } } const globalListenersSrc = this.getGlobalListeners(async); if (globalListenersSrc.size > 0) { const globalListeners = new Set(globalListenersSrc); for (const listener of globalListeners) { runCallback(() => listener(eventType, event)); } } } getGlobalListeners(async) { return async ? this.globalAsyncListeners : this.globalSyncListeners; } // 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. dispatchAsync(func) { this.asyncFunctionsQueue.push(func); if (!this.scheduled) { const flush = () => { window.setTimeout(this.flushAsyncQueue.bind(this), 0); }; this.frameworkOverrides ? this.frameworkOverrides.wrapIncoming(flush) : flush(); this.scheduled = true; } } // this happens in the next VM turn only, and empties the queue of events flushAsyncQueue() { this.scheduled = false; const queueCopy = this.asyncFunctionsQueue.slice(); this.asyncFunctionsQueue = []; queueCopy.forEach((func) => func()); } }; // packages/ag-grid-community/src/misc/locale/localeUtils.ts function defaultLocaleTextFunc(_key, defaultValue) { return defaultValue; } function _getLocaleTextFunc(localeSvc) { return localeSvc?.getLocaleTextFunc() ?? defaultLocaleTextFunc; } // packages/ag-grid-community/src/utils/aria.ts function _toggleAriaAttribute(element, attribute, value) { if (value == null || typeof value === "string" && value == "") { _removeAriaAttribute(element, attribute); } else { _setAriaAttribute(element, attribute, value); } } function _setAriaAttribute(element, attribute, value) { element.setAttribute(_ariaAttributeName(attribute), value.toString()); } function _removeAriaAttribute(element, attribute) { element.removeAttribute(_ariaAttributeName(attribute)); } function _ariaAttributeName(attribute) { return `aria-${attribute}`; } function _setAriaRole(element, role) { if (role) { element.setAttribute("role", role); } else { element.removeAttribute("role"); } } function _getAriaSortState(sortDirection) { let sort; if (sortDirection === "asc") { sort = "ascending"; } else if (sortDirection === "desc") { sort = "descending"; } else if (sortDirection === "mixed") { sort = "other"; } else { sort = "none"; } return sort; } function _getAriaPosInSet(element) { return parseInt(element.getAttribute("aria-posinset"), 10); } function _getAriaLabel(element) { return element.getAttribute("aria-label"); } function _setAriaLabel(element, label) { _toggleAriaAttribute(element, "label", label); } function _setAriaLabelledBy(element, labelledBy) { _toggleAriaAttribute(element, "labelledby", labelledBy); } function _setAriaDescribedBy(element, describedby) { _toggleAriaAttribute(element, "describedby", describedby); } function _setAriaLive(element, live) { _toggleAriaAttribute(element, "live", live); } function _setAriaAtomic(element, atomic) { _toggleAriaAttribute(element, "atomic", atomic); } function _setAriaRelevant(element, relevant) { _toggleAriaAttribute(element, "relevant", relevant); } function _setAriaLevel(element, level) { _toggleAriaAttribute(element, "level", level); } function _setAriaDisabled(element, disabled) { _toggleAriaAttribute(element, "disabled", disabled); } function _setAriaHidden(element, hidden) { _toggleAriaAttribute(element, "hidden", hidden); } function _setAriaActiveDescendant(element, descendantId) { _toggleAriaAttribute(element, "activedescendant", descendantId); } function _setAriaExpanded(element, expanded) { _setAriaAttribute(element, "expanded", expanded); } function _removeAriaExpanded(element) { _removeAriaAttribute(element, "expanded"); } function _setAriaSetSize(element, setsize) { _setAriaAttribute(element, "setsize", setsize); } function _setAriaPosInSet(element, position) { _setAriaAttribute(element, "posinset", position); } function _setAriaMultiSelectable(element, multiSelectable) { _setAriaAttribute(element, "multiselectable", multiSelectable); } function _setAriaRowCount(element, rowCount) { _setAriaAttribute(element, "rowcount", rowCount); } function _setAriaRowIndex(element, rowIndex) { _setAriaAttribute(element, "rowindex", rowIndex); } function _setAriaRowSpan(element, spanCount) { _setAriaAttribute(element, "rowspan", spanCount); } function _setAriaColCount(element, colCount) { _setAriaAttribute(element, "colcount", colCount); } function _setAriaColIndex(element, colIndex) { _setAriaAttribute(element, "colindex", colIndex); } function _setAriaColSpan(element, colSpan) { _setAriaAttribute(element, "colspan", colSpan); } function _setAriaSort(element, sort) { _setAriaAttribute(element, "sort", sort); } function _removeAriaSort(element) { _removeAriaAttribute(element, "sort"); } function _setAriaSelected(element, selected) { _toggleAriaAttribute(element, "selected", selected); } function _setAriaChecked(element, checked) { _setAriaAttribute(element, "checked", checked === void 0 ? "mixed" : checked); } function _setAriaControls(controllerElement, controlledElement) { _toggleAriaAttribute(controllerElement, "controls", controlledElement.id); _setAriaLabelledBy(controlledElement, controllerElement.id); } function _setAriaHasPopup(element, hasPopup) { _toggleAriaAttribute(element, "haspopup", hasPopup === false ? null : hasPopup); } function _getAriaCheckboxStateName(translate, state) { return state === void 0 ? translate("ariaIndeterminate", "indeterminate") : state === true ? translate("ariaChecked", "checked") : translate("ariaUnchecked", "unchecked"); } // packages/ag-grid-community/src/utils/browser.ts var isSafari; var isFirefox; var isMacOs; var isIOS; var invisibleScrollbar; var browserScrollbarWidth; var maxDivHeight; function _isBrowserSafari() { if (isSafari === void 0) { isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent); } return isSafari; } function _isBrowserFirefox() { if (isFirefox === void 0) { isFirefox = /(firefox)/i.test(navigator.userAgent); } return isFirefox; } function _isMacOsUserAgent() { if (isMacOs === void 0) { isMacOs = /(Mac|iPhone|iPod|iPad)/i.test(navigator.platform); } return isMacOs; } function _isIOSUserAgent() { if (isIOS === void 0) { isIOS = /iPad|iPhone|iPod/.test(navigator.platform) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1; } return isIOS; } function _getTabIndex(el) { if (!el) { return null; } const numberTabIndex = el.tabIndex; const tabIndex = el.getAttribute("tabIndex"); if (numberTabIndex === -1 && (tabIndex === null || tabIndex === "" && !_isBrowserFirefox())) { return null; } return numberTabIndex.toString(); } function _getMaxDivHeight() { if (maxDivHeight !== void 0) { return maxDivHeight; } if (!document.body) { return -1; } let res = 1e6; const testUpTo = _isBrowserFirefox() ? 6e6 : 1e9; const div = document.createElement("div"); document.body.appendChild(div); while (true) { const test = res * 2; div.style.height = test + "px"; if (test > testUpTo || div.clientHeight !== test) { break; } else { res = test; } } document.body.removeChild(div); maxDivHeight = res; return res; } function _getScrollbarWidth() { if (browserScrollbarWidth == null) { initScrollbarWidthAndVisibility(); } return browserScrollbarWidth; } function initScrollbarWidthAndVisibility() { const body = document.body; const div = document.createElement("div"); div.style.width = div.style.height = "100px"; div.style.opacity = "0"; div.style.overflow = "scroll"; div.style.msOverflowStyle = "scrollbar"; div.style.position = "absolute"; body.appendChild(div); let width = div.offsetWidth - div.clientWidth; if (width === 0 && div.clientWidth === 0) { width = null; } if (div.parentNode) { div.parentNode.removeChild(div); } if (width != null) { browserScrollbarWidth = width; invisibleScrollbar = width === 0; } } function _isInvisibleScrollbar() { if (invisibleScrollbar == null) { initScrollbarWidthAndVisibility(); } return invisibleScrollbar; } // packages/ag-grid-community/src/utils/dom.ts function _radioCssClass(element, elementClass, otherElementClass) { const parent = element.parentElement; let sibling = parent && parent.firstChild; while (sibling) { if (elementClass) { sibling.classList.toggle(elementClass, sibling === element); } if (otherElementClass) { sibling.classList.toggle(otherElementClass, sibling !== element); } sibling = sibling.nextSibling; } } var FOCUSABLE_SELECTOR = "[tabindex], input, select, button, textarea, [href]"; var FOCUSABLE_EXCLUDE = "[disabled], .ag-disabled:not(.ag-button), .ag-disabled *"; function _isFocusableFormField(element) { const matches = Element.prototype.matches || Element.prototype.msMatchesSelector; const inputSelector = "input, select, button, textarea"; const isFocusable = matches.call(element, inputSelector); const isNotFocusable = matches.call(element, FOCUSABLE_EXCLUDE); const isElementVisible = _isVisible(element); const focusable = isFocusable && !isNotFocusable && isElementVisible; return focusable; } function _setDisplayed(element, displayed, options = {}) { const { skipAriaHidden } = options; element.classList.toggle("ag-hidden", !displayed); if (!skipAriaHidden) { _setAriaHidden(element, !displayed); } } function _setVisible(element, visible, options = {}) { const { skipAriaHidden } = options; element.classList.toggle("ag-invisible", !visible); if (!skipAriaHidden) { _setAriaHidden(element, !visible); } } function _setDisabled(element, disabled) { const attributeName = "disabled"; const addOrRemoveDisabledAttribute = disabled ? (e) => e.setAttribute(attributeName, "") : (e) => e.removeAttribute(attributeName); addOrRemoveDisabledAttribute(element); const inputs = element.querySelectorAll("input") ?? []; for (const input of inputs) { addOrRemoveDisabledAttribute(input); } } function _isElementChildOfClass(element, cls, maxNest) { let counter = 0; while (element) { if (element.classList.contains(cls)) { return true; } element = element.parentElement; if (typeof maxNest == "number") { if (++counter > maxNest) { break; } } else if (element === maxNest) { break; } } return false; } function _getElementSize(el) { const { height, width, borderTopWidth, borderRightWidth, borderBottomWidth, borderLeftWidth, paddingTop, paddingRight, paddingBottom, paddingLeft, marginTop, marginRight, marginBottom, marginLeft, boxSizing } = window.getComputedStyle(el); return { height: parseFloat(height || "0"), width: parseFloat(width || "0"), borderTopWidth: parseFloat(borderTopWidth || "0"), borderRightWidth: parseFloat(borderRightWidth || "0"), borderBottomWidth: parseFloat(borderBottomWidth || "0"), borderLeftWidth: parseFloat(borderLeftWidth || "0"), paddingTop: parseFloat(paddingTop || "0"), paddingRight: parseFloat(paddingRight || "0"), paddingBottom: parseFloat(paddingBottom || "0"), paddingLeft: parseFloat(paddingLeft || "0"), marginTop: parseFloat(marginTop || "0"), marginRight: parseFloat(marginRight || "0"), marginBottom: parseFloat(marginBottom || "0"), marginLeft: parseFloat(marginLeft || "0"), boxSizing }; } function _getInnerHeight(el) { const size = _getElementSize(el); if (size.boxSizing === "border-box") { return size.height - size.paddingTop - size.paddingBottom; } return size.height; } function _getInnerWidth(el) { const size = _getElementSize(el); if (size.boxSizing === "border-box") { return size.width - size.paddingLeft - size.paddingRight; } return size.width; } function _getAbsoluteHeight(el) { const { height, marginBottom, marginTop } = _getElementSize(el); return Math.floor(height + marginBottom + marginTop); } function _getAbsoluteWidth(el) { const { width, marginLeft, marginRight } = _getElementSize(el); return Math.floor(width + marginLeft + marginRight); } function _getElementRectWithOffset(el) { const offsetElementRect = el.getBoundingClientRect(); const { borderTopWidth, borderLeftWidth, borderRightWidth, borderBottomWidth } = _getElementSize(el); return { top: offsetElementRect.top + (borderTopWidth || 0), left: offsetElementRect.left + (borderLeftWidth || 0), right: offsetElementRect.right + (borderRightWidth || 0), bottom: offsetElementRect.bottom + (borderBottomWidth || 0) }; } function _getScrollLeft(element, rtl) { let scrollLeft = element.scrollLeft; if (rtl) { scrollLeft = Math.abs(scrollLeft); } return scrollLeft; } function _setScrollLeft(element, value, rtl) { if (rtl) { value *= -1; } element.scrollLeft = value; } function _clearElement(el) { while (el && el.firstChild) { el.removeChild(el.firstChild); } } function _removeFromParent(node) { if (node && node.parentNode) { node.parentNode.removeChild(node); } } function _isInDOM(element) { return !!element.offsetParent; } function _isVisible(element) { const el = element; if (el.checkVisibility) { return el.checkVisibility({ checkVisibilityCSS: true }); } const isHidden = !_isInDOM(element) || window.getComputedStyle(element).visibility !== "visible"; return !isHidden; } function _loadTemplate(template) { const tempDiv = document.createElement("div"); tempDiv.innerHTML = (template || "").trim(); return tempDiv.firstChild; } function _ensureDomOrder(eContainer, eChild, eChildBefore) { if (eChildBefore && eChildBefore.nextSibling === eChild) { return; } if (!eContainer.firstChild) { eContainer.appendChild(eChild); } else if (eChildBefore) { if (eChildBefore.nextSibling) { eContainer.insertBefore(eChild, eChildBefore.nextSibling); } else { eContainer.appendChild(eChild); } } else if (eContainer.firstChild && eContainer.firstChild !== eChild) { eContainer.insertAdjacentElement("afterbegin", eChild); } } function _setDomChildOrder(eContainer, orderedChildren) { for (let i = 0; i < orderedChildren.length; i++) { const correctCellAtIndex = orderedChildren[i]; const actualCellAtIndex = eContainer.children[i]; if (actualCellAtIndex !== correctCellAtIndex) { eContainer.insertBefore(correctCellAtIndex, actualCellAtIndex); } } } function _camelCaseToHyphenated(camelCase) { return camelCase.replace(/[A-Z]/g, (s) => `-${s.toLocaleLowerCase()}`); } function _addStylesToElement(eElement, styles) { if (!styles) { return; } for (const key of Object.keys(styles)) { const value = styles[key]; if (!key || !key.length || value == null) { continue; } const parsedKey = _camelCaseToHyphenated(key); const valueAsString = value.toString(); const parsedValue = valueAsString.replace(/\s*!important/g, ""); const priority = parsedValue.length != valueAsString.length ? "important" : void 0; eElement.style.setProperty(parsedKey, parsedValue, priority); } } function _isHorizontalScrollShowing(element) { return element.clientWidth < element.scrollWidth; } function _isVerticalScrollShowing(element) { return element.clientHeight < element.scrollHeight; } function _setElementWidth(element, width) { if (width === "flex") { element.style.removeProperty("width"); element.style.removeProperty("minWidth"); element.style.removeProperty("maxWidth"); element.style.flex = "1 1 auto"; } else { _setFixedWidth(element, width); } } function _setFixedWidth(element, width) { width = _formatSize(width); element.style.width = width; element.style.maxWidth = width; element.style.minWidth = width; } function _setFixedHeight(element, height) { height = _formatSize(height); element.style.height = height; element.style.maxHeight = height; element.style.minHeight = height; } function _formatSize(size) { return typeof size === "number" ? `${size}px` : size; } function _isNodeOrElement(o) { return o instanceof Node || o instanceof HTMLElement; } function _addOrRemoveAttribute(element, name, value) { if (value == null || value === "") { element.removeAttribute(name); } else { element.setAttribute(name, value.toString()); } } function _observeResize(beans, element, callback) { const win = _getWindow(beans); const ResizeObserverImpl = win.ResizeObserver; const resizeObserver = ResizeObserverImpl ? new ResizeObserverImpl(callback) : null; resizeObserver?.observe(element); return () => resizeObserver?.disconnect(); } function _getTextSelectionRanges(beans) { const rootNode = _getRootNode(beans); const selection = "getSelection" in rootNode ? rootNode.getSelection() : null; const ranges = []; for (let i = 0; i < (selection?.rangeCount ?? 0); i++) { const range = selection?.getRangeAt(i); if (range) { ranges.push(range); } } return { selection, ranges }; } function _preserveRangesWhile(beans, fn) { const enableCellTextSelection = beans.gos.get("enableCellTextSelection"); if (!enableCellTextSelection) { return fn(); } if (!_isBrowserFirefox() && !_isBrowserSafari()) { return fn(); } const { selection, ranges } = _getTextSelectionRanges(beans); fn(); selection?.removeAllRanges(); for (const range of ranges) { selection?.addRange(range); } } function _requestAnimationFrame(beans, callback) { const win = _getWindow(beans); if (win.requestAnimationFrame) { win.requestAnimationFrame(callback); } else if (win.webkitRequestAnimationFrame) { win.webkitRequestAnimationFrame(callback); } else { win.setTimeout(callback, 0); } } var DataRefAttribute = "data-ref"; var whitespaceNode; function getWhitespaceNode() { whitespaceNode ?? (whitespaceNode = document.createTextNode(" ")); return whitespaceNode.cloneNode(); } function _createElement(params) { const { attrs, children, cls, ref, role, tag } = params; const element = document.createElement(tag); if (cls) { element.className = cls; } if (ref) { element.setAttribute(DataRefAttribute, ref); } if (role) { element.setAttribute("role", role); } if (attrs) { for (const key of Object.keys(attrs)) { element.setAttribute(key, attrs[key]); } } if (children) { if (typeof children === "string") { element.textContent = children; } else { let addFirstWhitespace = true; for (const child of children) { if (child) { if (typeof child === "string") { element.appendChild(document.createTextNode(child)); addFirstWhitespace = false; } else { if (addFirstWhitespace) { element.appendChild(getWhitespaceNode()); addFirstWhitespace = false; } element.append(_createElement(child)); element.appendChild(getWhitespaceNode()); } } } } } return element; } // packages/ag-grid-community/src/utils/function.ts var doOnceFlags = {}; function _doOnce(func, key) { if (doOnceFlags[key]) { return; } func(); doOnceFlags[key] = true; } function _logIfDebug(gos, message, ...args) { if (gos.get("debug")) { console.log("AG Grid: " + message, ...args); } } function _warnOnce(msg, ...args) { _doOnce(() => console.warn("AG Grid: " + msg, ...args), msg + args?.join("")); } function _errorOnce(msg, ...args) { _doOnce(() => console.error("AG Grid: " + msg, ...args), msg + args?.join("")); } var batchedCallsSetTimeout = { pending: false, funcs: [] }; var batchedCallsRaf = { pending: false, funcs: [] }; function _batchCall(func, mode = "setTimeout", beans) { const batch = mode === "raf" ? batchedCallsRaf : batchedCallsSetTimeout; batch.funcs.push(func); if (batch.pending) { return; } batch.pending = true; const runBatch = () => { const funcsCopy = batch.funcs.slice(); batch.funcs.length = 0; batch.pending = false; funcsCopy.forEach((func2) => func2()); }; if (mode === "raf") { _requestAnimationFrame(beans, runBatch); } else { window.setTimeout(runBatch, 0); } } function _debounce(bean, func, delay) { let timeout; return function(...args) { const context = this; window.clearTimeout(timeout); timeout = window.setTimeout(function() { if (bean.isAlive()) { func.apply(context, args); } }, delay); }; } function _throttle(func, wait) { let previousCall = 0; return function(...args) { const context = this; const currentCall = Date.now(); if (currentCall - previousCall < wait) { return; } previousCall = currentCall; func.apply(context, args); }; } function _waitUntil(condition, callback, timeout = 100, timeoutMessage) { const timeStamp = Date.now(); let interval = null; let executed = false; const internalCallback = () => { const reachedTimeout = Date.now() - timeStamp > timeout; if (condition() || reachedTimeout) { callback(); executed = true; if (interval != null) { window.clearInterval(interval); interval = null; } if (reachedTimeout && timeoutMessage) { _warnOnce(timeoutMessage); } } }; internalCallback(); if (!executed) { interval = window.setInterval(internalCallback, 10); } } // packages/ag-grid-community/src/utils/generic.ts function _makeNull(value) { if (value == null || value === "") { return null; } return value; } function _exists(value) { return value != null && value !== ""; } function _missing(value) { return !_exists(value); } function _toStringOrNull(value) { return value != null && typeof value.toString === "function" ? value.toString() : null; } function _jsonEquals(val1, val2) { const val1Json = val1 ? JSON.stringify(val1) : null; const val2Json = val2 ? JSON.stringify(val2) : null; return val1Json === val2Json; } function _defaultComparator(valueA, valueB, accentedCompare = false) { const valueAMissing = valueA == null; const valueBMissing = valueB == null; 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 { return valueA.localeCompare(valueB); } catch (e) { return doQuickCompare(valueA, valueB); } } // packages/ag-grid-community/src/baseUrl.ts var BASE_URL = "https://www.ag-grid.com"; // packages/ag-grid-community/src/version.ts var VERSION = "33.3.0"; // packages/ag-grid-community/src/validation/logging.ts var MAX_URL_LENGTH = 2e3; var MIN_PARAM_LENGTH = 100; var VERSION_PARAM_NAME = "_version_"; var validation = null; var suppressAllLogging = false; var baseDocLink = `${BASE_URL}/javascript-data-grid`; function provideValidationServiceLogger(logger) { validation = logger; } function setValidationDocLink(docLink) { baseDocLink = docLink; } function getErrorParts(id, args, defaultMessage) { return validation?.getConsoleMessage(id, args) ?? [minifiedLog(id, args, defaultMessage)]; } function getMsgOrDefault(logger, id, args, defaultMessage) { if (suppressAllLogging) return; logger(`error #${id}`, ...getErrorParts(id, args, defaultMessage)); } function stringifyObject(inputObj) { if (!inputObj) return String(inputObj); const object = {}; for (const prop of Object.keys(inputObj)) { if (typeof inputObj[prop] !== "object" && typeof inputObj[prop] !== "function") { object[prop] = inputObj[prop]; } } return JSON.stringify(object); } function stringifyValue(value) { let output = value; if (value instanceof Error) { output = value.toString(); } else if (typeof value === "object") { output = stringifyObject(value); } return output; } function toStringWithNullUndefined(str) { return str === void 0 ? "undefined" : str === null ? "null" : str; } function getParamsUrl(baseUrl, params) { return `${baseUrl}?${params.toString()}`; } function truncateUrl(baseUrl, params, maxLength) { const sortedParams = Array.from(params.entries()).sort((a, b) => b[1].length - a[1].length); let url = getParamsUrl(baseUrl, params); for (const [key, value] of sortedParams) { if (key === VERSION_PARAM_NAME) { continue; } const excessLength = url.length - maxLength; if (excessLength <= 0) { break; } const ellipse = "..."; const truncateAmount = excessLength + ellipse.length; const truncatedValue = value.length - truncateAmount > MIN_PARAM_LENGTH ? value.slice(0, value.length - truncateAmount) + ellipse : value.slice(0, MIN_PARAM_LENGTH) + ellipse; params.set(key, truncatedValue); url = getParamsUrl(baseUrl, params); } return url; } function getErrorLink(errorNum, args) { const params = new URLSearchParams(); params.append(VERSION_PARAM_NAME, VERSION); if (args) { for (const key of Object.keys(args)) { params.append(key, stringifyValue(args[key])); } } const baseUrl = `${baseDocLink}/errors/${errorNum}`; const url = getParamsUrl(baseUrl, params); return url.length <= MAX_URL_LENGTH ? url : truncateUrl(baseUrl, params, MAX_URL_LENGTH); } var minifiedLog = (errorNum, args, defaultMessage) => { const errorLink = getErrorLink(errorNum, args); return `${defaultMessage ? defaultMessage + " \n" : ""}Visit ${errorLink}${defaultMessage ? "" : " \n Alternatively register the ValidationModule to see the full message in the console."}`; }; function _warn(...args) { getMsgOrDefault(_warnOnce, args[0], args[1]); } function _error(...args) { getMsgOrDefault(_errorOnce, args[0], args[1]); } function _logPreInitErr(id, args, defaultMessage) { getMsgOrDefault(_errorOnce, id, args, defaultMessage); } function getErrMsg(defaultMessage, args) { const id = args[0]; return `error #${id} ` + getErrorParts(id, args[1], defaultMessage).join(" "); } function _errMsg(...args) { return getErrMsg(void 0, args); } function _preInitErrMsg(...args) { return getErrMsg("\n", args); } // packages/ag-grid-community/src/gridOptionsUtils.ts function isRowModelType(gos, rowModelType) { return gos.get("rowModelType") === rowModelType; } function _isClientSideRowModel(gos, rowModel) { return isRowModelType(gos, "clientSide"); } function _isServerSideRowModel(gos, rowModel) { return isRowModelType(gos, "serverSide"); } function _isDomLayout(gos, domLayout) { return gos.get("domLayout") === domLayout; } function _isRowSelection(gos) { return _getRowSelectionMode(gos) !== void 0; } function _isGetRowHeightFunction(gos) { return typeof gos.get("getRowHeight") === "function"; } function _shouldMaintainColumnOrder(gos, isPivotColumns) { if (isPivotColumns) { return !gos.get("enableStrictPivotColumnOrder"); } return gos.get("maintainColumnOrder"); } function _getRowHeightForNode(beans, rowNode, allowEstimate = false, defaultRowHeight) { const { gos, environment } = beans; if (defaultRowHeight == null) { defaultRowHeight = environment.getDefaultRowHeight(); } if (_isGetRowHeightFunction(gos)) { if (allowEstimate) { return { height: defaultRowHeight, estimated: true }; } const params = { node: rowNode, data: rowNode.data }; const height = gos.getCallback("getRowHeight")(params); if (isNumeric(height)) { if (height === 0) { _warn(23); } return { height: Math.max(1, height), estimated: false }; } } if (rowNode.detail && gos.get("masterDetail")) { return getMasterDetailRowHeight(gos); } const gridOptionsRowHeight = gos.get("rowHeight"); const rowHeight = gridOptionsRowHeight && isNumeric(gridOptionsRowHeight) ? gridOptionsRowHeight : defaultRowHeight; return { height: rowHeight, estimated: false }; } function getMasterDetailRowHeight(gos) { if (gos.get("detailRowAutoHeight")) { return { height: 1, estimated: false }; } const defaultRowHeight = gos.get("detailRowHeight"); if (isNumeric(defaultRowHeight)) { return { height: defaultRowHeight, estimated: false }; } return { height: 300, estimated: false }; } function _getRowHeightAsNumber(beans) { const { environment, gos } = beans; const gridOptionsRowHeight = gos.get("rowHeight"); if (!gridOptionsRowHeight || _missing(gridOptionsRowHeight)) { return environment.getDefaultRowHeight(); } const rowHeight = environment.refreshRowHeightVariable(); if (rowHeight !== -1) { return rowHeight; } _warn(24); return environment.getDefaultRowHeight(); } function isNumeric(value) { return !isNaN(value) && typeof value === "number" && isFinite(value); } function _getDomData(gos, element, key) { const domData = element[gos.getDomDataKey()]; return domData ? domData[key] : void 0; } function _setDomData(gos, element, key, value) { const domDataKey = gos.getDomDataKey(); let domData = element[domDataKey]; if (_missing(domData)) { domData = {}; element[domDataKey] = domData; } domData[key] = value; } function _getDocument(beans) { const { gos, eGridDiv } = beans; let result = null; const gridOptionsGetDocument = gos.get("getDocument"); if (gridOptionsGetDocument && _exists(gridOptionsGetDocument)) { result = gridOptionsGetDocument(); } else if (eGridDiv) { result = eGridDiv.ownerDocument; } if (result && _exists(result)) { return result; } return document; } function _getWindow(beans) { const eDocument = _getDocument(beans); return eDocument.defaultView || window; } function _getRootNode(beans) { return beans.eGridDiv.getRootNode(); } function _getActiveDomElement(beans) { return _getRootNode(beans).activeElement; } function _getPageBody(beans) { let rootNode = null; let targetEl = null; try { rootNode = _getDocument(beans).fullscreenElement; } catch (e) { } finally { if (!rootNode) { rootNode = _getRootNode(beans); } const body = rootNode.querySelector("body"); if (body) { targetEl = body; } else if (rootNode instanceof ShadowRoot) { targetEl = rootNode; } else if (rootNode instanceof Document) { targetEl = rootNode?.documentElement; } else { targetEl = rootNode; } } return targetEl; } function _getBodyWidth(beans) { const body = _getPageBody(beans); return body?.clientWidth ?? (window.innerHeight || -1); } function _getBodyHeight(beans) { const body = _getPageBody(beans); return body?.clientHeight ?? (window.innerHeight || -1); } function _anchorElementToMouseMoveEvent(element, mouseMoveEvent, beans) { const eRect = element.getBoundingClientRect(); const height = eRect.height; const browserWidth = _getBodyWidth(beans) - 2; const browserHeight = _getBodyHeight(beans) - 2; const offsetParent = element.offsetParent; if (!offsetParent) { return; } const offsetParentSize = _getElementRectWithOffset(element.offsetParent); const { clientY, clientX } = mouseMoveEvent; let top = clientY - offsetParentSize.top - height / 2; let left = clientX - offsetParentSize.left - 10; const eDocument = _getDocument(beans); const win = eDocument.defaultView || window; const windowScrollY = win.pageYOffset || eDocument.documentElement.scrollTop; const windowScrollX = win.pageXOffset || eDocument.documentElement.scrollLeft; if (browserWidth > 0 && left + element.clientWidth > browserWidth + windowScrollX) { left = browserWidth + windowScrollX - element.clientWidth; } if (left < 0) { left = 0; } if (browserHeight > 0 && top + element.clientHeight > browserHeight + windowScrollY) { top = browserHeight + windowScrollY - element.clientHeight; } if (top < 0) { top = 0; } element.style.left = `${left}px`; element.style.top = `${top}px`; } function _isNothingFocused(beans) { const activeEl = _getActiveDomElement(beans); return activeEl === null || activeEl === _getDocument(beans).body; } function _isAnimateRows(gos) { if (gos.get("ensureDomOrder")) { return false; } return gos.get("animateRows"); } function _isGroupRowsSticky(gos) { if (gos.get("paginateChildRows") || gos.get("groupHideOpenParents") || _isDomLayout(gos, "print")) { return false; } return true; } function _isColumnsSortingCoupledToGroup(gos) { const autoGroupColumnDef = gos.get("autoGroupColumnDef"); return !autoGroupColumnDef?.comparator && !gos.get("treeData"); } function _getGroupAggFiltering(gos) { const userValue = gos.get("groupAggFiltering"); if (typeof userValue === "function") { return gos.getCallback("groupAggFiltering"); } if (userValue === true) { return () => true; } return void 0; } function _getGrandTotalRow(gos) { return gos.get("grandTotalRow"); } function _getGroupTotalRowCallback(gos) { const userValue = gos.get("groupTotalRow"); if (typeof userValue === "function") { return gos.getCallback("groupTotalRow"); } return () => userValue ?? void 0; } function _isGroupMultiAutoColumn(gos) { const isHideOpenParents = !!gos.get("groupHideOpenParents"); if (isHideOpenParents) { return true; } return gos.get("groupDisplayType") === "multipleColumns"; } function _isGroupUseEntireRow(gos, pivotMode) { if (pivotMode) { return false; } return gos.get("groupDisplayType") === "groupRows"; } function _isFullWidthGroupRow(gos, node, pivotMode) { return !!node.group && !node.footer && _isGroupUseEntireRow(gos, pivotMode); } function _getRowIdCallback(gos) { const getRowId = gos.getCallback("getRowId"); if (getRowId === void 0) { return getRowId; } return (params) => { let id = getRowId(params); if (typeof id !== "string") { _doOnce(() => _warn(25, { id }), "getRowIdString"); id = String(id); } return id; }; } function _canSkipShowingRowGroup(gos, node) { const isSkippingGroups = gos.get("groupHideParentOfSingleChild"); if (isSkippingGroups === true) { return true; } if (isSkippingGroups === "leafGroupsOnly" && node.leafGroup) { return true; } if (gos.get("groupRemoveSingleChildren")) { return true; } if (gos.get("groupRemoveLowestSingleChildren") && node.leafGroup) { return true; } return false; } function _getMaxConcurrentDatasourceRequests(gos) { const res = gos.get("maxConcurrentDatasourceRequests"); return res > 0 ? res : void 0; } function _shouldUpdateColVisibilityAfterGroup(gos, isGrouped) { const preventVisibilityChanges = gos.get("suppressGroupChangesColumnVisibility"); if (preventVisibilityChanges === true) { return false; } if (isGrouped && preventVisibilityChanges === "suppressHideOnGroup") { return false; } if (!isGrouped && preventVisibilityChanges === "suppressShowOnUngroup") { return false; } const legacySuppressOnGroup = gos.get("suppressRowGroupHidesColumns"); if (isGrouped && legacySuppressOnGroup === true) { return false; } const legacySuppressOnUngroup = gos.get("suppressMakeColumnVisibleAfterUnGroup"); if (!isGrouped && legacySuppressOnUngroup === true) { return false; } return true; } function _getCheckboxes(selection) { return selection?.checkboxes ?? true; } function _getHeaderCheckbox(selection) { return selection?.mode === "multiRow" && (selection.headerCheckbox ?? true); } function _getCheckboxLocation(rowSelection) { if (typeof rowSelection !== "object") { return void 0; } return rowSelection.checkboxLocation ?? "selectionColumn"; } function _getHideDisabledCheckboxes(selection) { return selection?.hideDisabledCheckboxes ?? false; } function _isUsingNewRowSelectionAPI(gos) { const rowSelection = gos.get("rowSelection"); return typeof rowSelection !== "string"; } function _isUsingNewCellSelectionAPI(gos) { return gos.get("cellSelection") !== void 0; } function _getSuppressMultiRanges(gos) { const selection = gos.get("cellSelection"); const useNewAPI = selection !== void 0; if (!useNewAPI) { return gos.get("suppressMultiRangeSelection"); } return typeof selection !== "boolean" ? selection?.suppressMultiRanges ?? false : false; } function _isCellSelectionEnabled(gos) { const selection = gos.get("cellSelection"); const useNewAPI = selection !== void 0; return useNewAPI ? !!selection : gos.get("enableRangeSelection"); } function _getFillHandle(gos) { const selection = gos.get("cellSelection"); const useNewAPI = selection !== void 0; if (!useNewAPI) { return { mode: "fill", setFillValue: gos.get("fillOperation"), direction: gos.get("fillHandleDirection"), suppressClearOnFillReduction: gos.get("suppressClearOnFillReduction") }; } return typeof selection !== "boolean" && selection.handle?.mode === "fill" ? selection.handle : void 0; } function _getEnableClickSelection(gos) { const selection = gos.get("rowSelection") ?? "single"; if (typeof selection === "string") { const suppressRowClickSelection = gos.get("suppressRowClickSelection"); const suppressRowDeselection = gos.get("suppressRowDeselection"); if (suppressRowClickSelection && suppressRowDeselection) { return false; } else if (suppressRowClickSelection) { return "enableDeselection"; } else if (suppressRowDeselection) { return "enableSelection"; } else { return true; } } return selection.mode === "singleRow" || selection.mode === "multiRow" ? selection.enableClickSelection ?? false : false; } function _getEnableSelection(gos) { const enableClickSelection = _getEnableClickSelection(gos); return enableClickSelection === true || enableClickSelection === "enableSelection"; } function _getEnableDeselection(gos) { const enableClickSelection = _getEnableClickSelection(gos); return enableClickSelection === true || enableClickSelection === "enableDeselection"; } function _getIsRowSelectable(gos) { const selection = gos.get("rowSelection"); if (typeof selection === "string") { return gos.get("isRowSelectable"); } return selection?.isRowSelectable; } function _getRowSelectionMode(arg) { const selection = "beanName" in arg && arg.beanName === "gos" ? arg.get("rowSelection") : arg.rowSelection; if (typeof selection === "string") { switch (selection) { case "multiple": return "multiRow"; case "single": return "singleRow"; default: return; } } switch (selection?.mode) { case "multiRow": case "singleRow": return selection.mode; default: return; } } function _isMultiRowSelection(arg) { const mode = _getRowSelectionMode(arg); return mode === "multiRow"; } function _getEnableSelectionWithoutKeys(gos) { const selection = gos.get("rowSelection"); if (typeof selection === "string") { return gos.get("rowMultiSelectWithClick"); } return selection?.enableSelectionWithoutKeys ?? false; } function _getGroupSelection(gos) { const selection = gos.get("rowSelection"); if (typeof selection === "string") { const groupSelectsChildren = gos.get("groupSelectsChildren"); const groupSelectsFiltered = gos.get("groupSelectsFiltered"); if (groupSelectsChildren && groupSelectsFiltered) { return "filteredDescendants"; } else if (groupSelectsChildren) { return "descendants"; } else { return "self"; } } return selection?.mode === "multiRow" ? selection.groupSelects : void 0; } function _getSelectAll(gos, defaultValue = true) { const rowSelection = gos.get("rowSelection"); if (typeof rowSelection !== "object") { return defaultValue ? "all" : void 0; } return rowSelection.mode === "multiRow" ? rowSelection.selectAll : "all"; } function _getGroupSelectsDescendants(gos) { const groupSelection = _getGroupSelection(gos); return groupSelection === "descendants" || groupSelection === "filteredDescendants"; } function _getMasterSelects(gos) { const rowSelection = gos.get("rowSelection"); return typeof rowSelection === "object" && rowSelection.masterSelects || "self"; } function _isSetFilterByDefault(gos) { return gos.isModuleRegistered("SetFilter") && !gos.get("suppressSetFilterByDefault"); } function _isLegacyMenuEnabled(gos) { return gos.get("columnMenu") === "legacy"; } function _isColumnMenuAnchoringEnabled(gos) { return !_isLegacyMenuEnabled(gos); } function _getCallbackForEvent(eventName) { if (!eventName || eventName.length < 2) { return eventName; } return "on" + eventName[0].toUpperCase() + eventName.substring(1); } function _combineAttributesAndGridOptions(gridOptions, component, gridOptionsKeys) { if (typeof gridOptions !== "object") { gridOptions = {}; } const mergedOptions = { ...gridOptions }; gridOptionsKeys.forEach((key) => { const value = component[key]; if (typeof value !== "undefined") { mergedOptions[key] = value; } }); return mergedOptions; } function _processOnChange(changes, api) { if (!changes) { return; } const gridChanges = {}; let hasChanges = false; Object.keys(changes).forEach((key) => { gridChanges[key] = changes[key]; hasChanges = true; }); if (!hasChanges) { return; } const internalUpdateEvent = { type: "gridOptionsChanged", options: gridChanges }; api.dispatchEvent(internalUpdateEvent); const event = { type: "componentStateChanged", ...gridChanges }; api.dispatchEvent(event); } function _addGridCommonParams(gos, params) { return gos.addGridCommonParams(params); } function _getGroupingApproach(gos) { if (gos.get("treeData")) { if (gos.get("treeDataParentIdField")) { return "treeSelfRef"; } if (gos.get("treeDataChildrenField")) { return "treeNested"; } return "treePath"; } return "group"; } // packages/ag-grid-community/src/utils/event.ts var AG_GRID_STOP_PROPAGATION = "__ag_Grid_Stop_Propagation"; var PASSIVE_EVENTS = ["touchstart", "touchend", "touchmove", "touchcancel", "scroll"]; var NON_PASSIVE_EVENTS = ["wheel"]; var supports = {}; function _stopPropagationForAgGrid(event) { event[AG_GRID_STOP_PROPAGATION] = true; } function _isStopPropagationForAgGrid(event) { return event[AG_GRID_STOP_PROPAGATION] === true; } var _isEventSupported = /* @__PURE__ */ (() => { const tags = { select: "input", change: "input", submit: "form", reset: "form", error: "img", load: "img", abort: "img" }; const eventChecker = (eventName) => { if (typeof supports[eventName] === "boolean") { return supports[eventName]; } const el = document.createElement(tags[eventName] || "div"); eventName = "on" + eventName; return supports[eventName] = eventName in el; }; return eventChecker; })(); function _getCtrlForEventTarget(gos, eventTarget, type) { let sourceElement = eventTarget; while (sourceElement) { const renderedComp = _getDomData(gos, sourceElement, type); if (renderedComp) { return renderedComp; } sourceElement = sourceElement.parentElement; } return null; } function _isElementInEventPath(element, event) { if (!event || !element) { return false; } return _getEventPath(event).indexOf(element) >= 0; } function _createEventPath(event) { const res = []; let pointer = event.target; while (pointer) { res.push(pointer); pointer = pointer.parentElement; } return res; } function _getEventPath(event) { const eventNoType = event; if (eventNoType.path) { return eventNoType.path; } if (eventNoType.composedPath) { return eventNoType.composedPath(); } return _createEventPath(eventNoType); } function _addSafePassiveEventListener(frameworkOverrides, eElement, event, listener) { const passive = getPassiveStateForEvent(event); let options; if (passive != null) { options = { passive }; } if (frameworkOverrides && frameworkOverrides.addEventListener) { frameworkOverrides.addEventListener(eElement, event, listener, options); } } var getPassiveStateForEvent = (event) => { const isPassive = PASSIVE_EVENTS.includes(event); const isNonPassive = NON_PASSIVE_EVENTS.includes(event); if (isPassive) { return true; } if (isNonPassive) { return false; } }; // packages/ag-grid-community/src/context/beanStub.ts var BeanStub = class { constructor() { // not named context to allow children to use 'context' as a variable name 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.propertyListenerId = 0; // Enable multiple grid properties to be updated together by the user but only trigger shared logic once. // Closely related to logic in GridOptionsUtils.ts _processOnChange this.lastChangeSetIdLookup = {}; this.isAlive = () => !this.destroyed; } preWireBeans(beans) { this.beans = beans; this.stubContext = beans.context; this.eventSvc = beans.eventSvc; this.gos = beans.gos; } // 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); // } destroy() { const { destroyFunctions } = this; for (let i = 0; i < destroyFunctions.length; i++) { destroyFunctions[i](); } destroyFunctions.length = 0; this.destroyed = true; this.dispatchLocalEvent({ type: "destroyed" }); } // The typing of AgEventListener<an