@deephaven/js-plugin-ag-grid
Version:
Deephaven AG Grid plugin
1,539 lines • 2.2 MB
JavaScript
"use strict";
var __defProp = Object.defineProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
var _a;
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const plugin = require("@deephaven/plugin");
const icons = require("@deephaven/icons");
const React12 = require("react");
const components = require("@deephaven/components");
const jsapiBootstrap = require("@deephaven/jsapi-bootstrap");
const Log = require("@deephaven/log");
const reactRedux = require("react-redux");
const ReactDOM = require("react-dom");
var _documentCurrentScript = typeof document !== "undefined" ? document.currentScript : null;
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;
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) {
const listenerMap = async ? this.allAsyncListeners : this.allSyncListeners;
listenerMap.delete(eventType);
}
}
addGlobalListener(listener, async = false) {
(async ? this.globalAsyncListeners : this.globalSyncListeners).add(listener);
}
removeGlobalListener(listener, async = false) {
(async ? this.globalAsyncListeners : this.globalSyncListeners).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 processEventListeners = (listeners2, originalListeners2) => listeners2.forEach((listener) => {
if (!originalListeners2.has(listener)) {
return;
}
const callback = this.frameworkOverrides ? () => this.frameworkOverrides.wrapIncoming(() => listener(event)) : () => listener(event);
if (async) {
this.dispatchAsync(callback);
} else {
callback();
}
});
const originalListeners = this.getListeners(eventType, async, false) ?? /* @__PURE__ */ new Set();
const listeners = new Set(originalListeners);
if (listeners.size > 0) {
processEventListeners(listeners, originalListeners);
}
const globalListeners = new Set(
async ? this.globalAsyncListeners : this.globalSyncListeners
);
globalListeners.forEach((listener) => {
const callback = this.frameworkOverrides ? () => this.frameworkOverrides.wrapIncoming(() => listener(eventType, event)) : () => listener(eventType, event);
if (async) {
this.dispatchAsync(callback);
} else {
callback();
}
});
}
// 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());
}
};
var ModuleNames = /* @__PURE__ */ ((ModuleNames2) => {
ModuleNames2["CommunityCoreModule"] = "@ag-grid-community/core";
ModuleNames2["InfiniteRowModelModule"] = "@ag-grid-community/infinite-row-model";
ModuleNames2["ClientSideRowModelModule"] = "@ag-grid-community/client-side-row-model";
ModuleNames2["CsvExportModule"] = "@ag-grid-community/csv-export";
ModuleNames2["EnterpriseCoreModule"] = "@ag-grid-enterprise/core";
ModuleNames2["RowGroupingModule"] = "@ag-grid-enterprise/row-grouping";
ModuleNames2["ColumnsToolPanelModule"] = "@ag-grid-enterprise/column-tool-panel";
ModuleNames2["FiltersToolPanelModule"] = "@ag-grid-enterprise/filter-tool-panel";
ModuleNames2["MenuModule"] = "@ag-grid-enterprise/menu";
ModuleNames2["SetFilterModule"] = "@ag-grid-enterprise/set-filter";
ModuleNames2["MultiFilterModule"] = "@ag-grid-enterprise/multi-filter";
ModuleNames2["StatusBarModule"] = "@ag-grid-enterprise/status-bar";
ModuleNames2["SideBarModule"] = "@ag-grid-enterprise/side-bar";
ModuleNames2["RangeSelectionModule"] = "@ag-grid-enterprise/range-selection";
ModuleNames2["MasterDetailModule"] = "@ag-grid-enterprise/master-detail";
ModuleNames2["RichSelectModule"] = "@ag-grid-enterprise/rich-select";
ModuleNames2["GridChartsModule"] = "@ag-grid-enterprise/charts";
ModuleNames2["ViewportRowModelModule"] = "@ag-grid-enterprise/viewport-row-model";
ModuleNames2["ServerSideRowModelModule"] = "@ag-grid-enterprise/server-side-row-model";
ModuleNames2["ExcelExportModule"] = "@ag-grid-enterprise/excel-export";
ModuleNames2["ClipboardModule"] = "@ag-grid-enterprise/clipboard";
ModuleNames2["SparklinesModule"] = "@ag-grid-enterprise/sparklines";
ModuleNames2["AdvancedFilterModule"] = "@ag-grid-enterprise/advanced-filter";
ModuleNames2["AngularModule"] = "@ag-grid-community/angular";
ModuleNames2["ReactModule"] = "@ag-grid-community/react";
ModuleNames2["VueModule"] = "@ag-grid-community/vue";
return ModuleNames2;
})(ModuleNames || {});
var doOnceFlags = {};
function _doOnce(func, key) {
if (doOnceFlags[key]) {
return;
}
func();
doOnceFlags[key] = true;
}
function _log(message, ...args) {
console.log("AG Grid: " + message, ...args);
}
function _warnOnce(msg, ...args) {
_doOnce(() => console.warn("AG Grid: " + msg, ...args), msg + (args == null ? void 0 : args.join("")));
}
function _errorOnce(msg, ...args) {
_doOnce(() => console.error("AG Grid: " + msg, ...args), msg + (args == null ? void 0 : args.join("")));
}
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(() => {
const funcsCopy = executeNextVMTurnFuncs.slice();
executeNextVMTurnFuncs.length = 0;
executeNextVMTurnPending = false;
funcsCopy.forEach((func2) => func2());
}, 0);
}
function _executeAfter(funcs, milliseconds = 0) {
if (funcs.length > 0) {
window.setTimeout(() => funcs.forEach((func) => func()), milliseconds);
}
}
function _debounce(func, delay) {
let timeout;
return function(...args) {
const context = this;
window.clearTimeout(timeout);
timeout = window.setTimeout(function() {
func.apply(context, args);
}, delay);
};
}
function _throttle(func, wait) {
let previousCall = 0;
return function(...args) {
const context = this;
const currentCall = (/* @__PURE__ */ new Date()).getTime();
if (currentCall - previousCall < wait) {
return;
}
previousCall = currentCall;
func.apply(context, args);
};
}
function _waitUntil(condition, callback, timeout = 100, timeoutMessage) {
const timeStamp = (/* @__PURE__ */ new Date()).getTime();
let interval = null;
let executed = false;
const internalCallback = () => {
const reachedTimeout = (/* @__PURE__ */ new Date()).getTime() - timeStamp > timeout;
if (condition() || reachedTimeout) {
callback();
executed = true;
if (interval != null) {
window.clearInterval(interval);
interval = null;
}
}
};
internalCallback();
if (!executed) {
interval = window.setInterval(internalCallback, 10);
}
}
function _makeNull(value) {
if (value == null || value === "") {
return null;
}
return value;
}
function _exists(value, 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;
}
function _attrToNumber(value) {
if (value === void 0) {
return;
}
if (value === null || value === "") {
return null;
}
if (typeof value === "number") {
return isNaN(value) ? void 0 : value;
}
const valueParsed = parseInt(value, 10);
return isNaN(valueParsed) ? void 0 : valueParsed;
}
function _attrToBoolean(value) {
if (value === void 0) {
return;
}
if (value === null || value === "") {
return false;
}
return toBoolean(value);
}
function toBoolean(value) {
if (typeof value === "boolean") {
return value;
}
if (typeof value === "string") {
return value.toUpperCase() === "TRUE" || value == "";
}
return false;
}
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);
}
}
function _values(object) {
if (object instanceof Set || object instanceof Map) {
const arr = [];
object.forEach((value) => arr.push(value));
return arr;
}
return Object.values(object);
}
function isRowModelType(gos, rowModelType) {
return gos.get("rowModelType") === rowModelType;
}
function _isClientSideRowModel(gos) {
return isRowModelType(gos, "clientSide");
}
function _isServerSideRowModel(gos) {
return isRowModelType(gos, "serverSide");
}
function _isDomLayout(gos, domLayout) {
return gos.get("domLayout") === domLayout;
}
function _isRowSelection(gos) {
return _getRowSelectionMode(gos) !== void 0;
}
function _useAsyncEvents(gos) {
return !gos.get("suppressAsyncEvents");
}
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(gos, rowNode, allowEstimate = false, defaultRowHeight) {
if (defaultRowHeight == null) {
defaultRowHeight = gos.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) {
_warnOnce(
"The return of `getRowHeight` cannot be zero. If the intention is to hide rows, use a filter instead."
);
}
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(gos) {
const { environment } = gos;
const gridOptionsRowHeight = gos.get("rowHeight");
if (!gridOptionsRowHeight || _missing(gridOptionsRowHeight)) {
return environment.getDefaultRowHeight();
}
const rowHeight = environment.refreshRowHeightVariable();
if (rowHeight !== -1) {
return rowHeight;
}
_warnOnce("row height must be a number if not using standard row model");
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(gos) {
let result = null;
const gridOptionsGetDocument = gos.get("getDocument");
if (gridOptionsGetDocument && _exists(gridOptionsGetDocument)) {
result = gridOptionsGetDocument();
} else if (gos.eGridDiv) {
result = gos.eGridDiv.ownerDocument;
}
if (result && _exists(result)) {
return result;
}
return document;
}
function _getWindow(gos) {
const eDocument = _getDocument(gos);
return eDocument.defaultView || window;
}
function _getRootNode(gos) {
return gos.eGridDiv.getRootNode();
}
function _getActiveDomElement(gos) {
return _getRootNode(gos).activeElement;
}
function _isNothingFocused(gos) {
const eDocument = _getDocument(gos);
const activeEl = _getActiveDomElement(gos);
return activeEl === null || activeEl === eDocument.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 == null ? void 0 : 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) {
const userValue = gos.get("grandTotalRow");
if (userValue) {
return userValue;
}
const legacyValue = gos.get("groupIncludeTotalFooter");
if (legacyValue) {
return "bottom";
}
return void 0;
}
function _isGroupMultiAutoColumn(gos) {
if (gos.exists("groupDisplayType")) {
return gos.get("groupDisplayType") === "multipleColumns";
}
return gos.get("groupHideOpenParents");
}
function _isGroupUseEntireRow(gos, pivotMode) {
if (pivotMode) {
return false;
}
return gos.get("groupDisplayType") === "groupRows";
}
function _getRowIdCallback(gos) {
const getRowId = gos.getCallback("getRowId");
if (getRowId === void 0) {
return getRowId;
}
return (params) => {
let id = getRowId(params);
if (typeof id !== "string") {
_warnOnce(`The getRowId callback must return a string. The ID `, id, ` is being cast to a string.`);
id = String(id);
}
return id;
};
}
function _getCheckboxes(selection) {
return (selection == null ? void 0 : selection.checkboxes) ?? true;
}
function _getHeaderCheckbox(selection) {
return (selection == null ? void 0 : selection.mode) === "multiRow" && (selection.headerCheckbox ?? true);
}
function _getHideDisabledCheckboxes(selection) {
return (selection == null ? void 0 : 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 == null ? void 0 : selection.suppressMultiRanges) ?? false : false;
}
function _isCellSelectionEnabled(gos) {
const selection = gos.get("cellSelection");
const useNewAPI = selection !== void 0;
return useNewAPI ? !!selection : gos.get("enableRangeSelection");
}
function _isRangeHandleEnabled(gos) {
var _a2;
const selection = gos.get("cellSelection");
const useNewAPI = selection !== void 0;
if (!useNewAPI) {
return gos.get("enableRangeHandle");
}
return typeof selection !== "boolean" ? ((_a2 = selection.handle) == null ? void 0 : _a2.mode) === "range" : false;
}
function _isFillHandleEnabled(gos) {
var _a2;
const selection = gos.get("cellSelection");
const useNewAPI = selection !== void 0;
if (!useNewAPI) {
return gos.get("enableFillHandle");
}
return typeof selection !== "boolean" ? ((_a2 = selection.handle) == null ? void 0 : _a2.mode) === "fill" : false;
}
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 == null ? void 0 : selection.isRowSelectable;
}
function _getRowSelectionMode(gos) {
const selection = gos.get("rowSelection");
if (typeof selection === "string") {
switch (selection) {
case "multiple":
return "multiRow";
case "single":
return "singleRow";
default:
return;
}
}
return selection == null ? void 0 : selection.mode;
}
function _isMultiRowSelection(gos) {
const mode = _getRowSelectionMode(gos);
return mode === "multiRow";
}
function _getEnableSelectionWithoutKeys(gos) {
const selection = gos.get("rowSelection");
if (typeof selection === "string") {
return gos.get("rowMultiSelectWithClick");
}
return (selection == null ? void 0 : 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 == null ? void 0 : selection.mode) === "multiRow" ? selection.groupSelects : void 0;
}
function _getGroupSelectsDescendants(gos) {
const groupSelection = _getGroupSelection(gos);
return groupSelection === "descendants" || groupSelection === "filteredDescendants";
}
function _isSetFilterByDefault(gos) {
return gos.isModuleRegistered(
"@ag-grid-enterprise/set-filter"
/* SetFilterModule */
) && !gos.get("suppressSetFilterByDefault");
}
function _existsAndNotEmpty(value) {
return value != null && value.length > 0;
}
function _last(arr) {
if (!arr || !arr.length) {
return;
}
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 && a.every((value, index) => comparator ? comparator(value, b[index]) : b[index] === value);
}
function _sortNumerically(array) {
return array.sort((a, b) => a - b);
}
function _removeFromUnorderedArray(array, object) {
const index = array.indexOf(object);
if (index >= 0) {
array[index] = array[array.length - 1];
array.pop();
}
}
function _removeFromArray(array, object) {
const index = array.indexOf(object);
if (index >= 0) {
array.splice(index, 1);
}
}
function _removeAllFromUnorderedArray(array, toRemove) {
for (let i = 0; i < toRemove.length; i++) {
_removeFromUnorderedArray(array, toRemove[i]);
}
}
function _removeAllFromArray(array, toRemove) {
for (let i = 0; i < toRemove.length; i++) {
_removeFromArray(array, toRemove[i]);
}
}
function _insertIntoArray(array, object, toIndex) {
array.splice(toIndex, 0, object);
}
function _insertArrayIntoArray(dest, src, toIndex) {
if (dest == null || src == null) {
return;
}
for (let i = src.length - 1; i >= 0; i--) {
const item = src[i];
_insertIntoArray(dest, item, toIndex);
}
}
function _moveInArray(array, objectsToMove, toIndex) {
_removeAllFromArray(array, objectsToMove);
objectsToMove.slice().reverse().forEach((obj) => _insertIntoArray(array, obj, toIndex));
}
function _includes(array, value) {
return array.indexOf(value) > -1;
}
function _flatten(arrayOfArrays) {
return (arrayOfArrays == null ? void 0 : arrayOfArrays.flatMap((t) => t)) ?? [];
}
function _pushAll(target, source) {
if (source == null || target == null) {
return;
}
source.forEach((value) => target.push(value));
}
var AG_GRID_STOP_PROPAGATION = "__ag_Grid_Stop_Propagation";
var PASSIVE_EVENTS = ["touchstart", "touchend", "touchmove", "touchcancel", "scroll"];
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 isPassive = _includes(PASSIVE_EVENTS, event);
const options = isPassive ? { passive: true } : void 0;
if (frameworkOverrides && frameworkOverrides.addEventListener) {
frameworkOverrides.addEventListener(eElement, event, listener, options);
}
}
var BeanStub = class {
constructor() {
this.destroyFunctions = [];
this.destroyed = false;
this.__v_skip = true;
this.propertyListenerId = 0;
this.lastChangeSetIdLookup = {};
this.isAlive = () => !this.destroyed;
}
preWireBeans(beans) {
this.frameworkOverrides = beans.frameworkOverrides;
this.stubContext = beans.context;
this.eventService = beans.eventService;
this.gos = beans.gos;
this.localeService = beans.localeService;
}
// 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
getFrameworkOverrides() {
return this.frameworkOverrides;
}
destroy() {
for (let i = 0; i < this.destroyFunctions.length; i++) {
this.destroyFunctions[i]();
}
this.destroyFunctions.length = 0;
this.destroyed = true;
this.dispatchLocalEvent({ type: "destroyed" });
}
// The typing of AgEventListener<any, any, any> is not ideal, but it's the best we can do at the moment to enable
// eventService to have the best typing at the expense of BeanStub local events
/** Add a local event listener against this BeanStub */
addEventListener(eventType, listener, async) {
if (!this.localEventService) {
this.localEventService = new LocalEventService();
}
this.localEventService.addEventListener(eventType, listener, async);
}
/** Remove a local event listener from this BeanStub */
removeEventListener(eventType, listener, async) {
if (this.localEventService) {
this.localEventService.removeEventListener(eventType, listener, async);
}
}
dispatchLocalEvent(event) {
if (this.localEventService) {
this.localEventService.dispatchEvent(event);
}
}
addManagedElementListeners(object, handlers) {
return this._setupListeners(object, handlers);
}
addManagedEventListeners(handlers) {
return this._setupListeners(this.eventService, handlers);
}
addManagedListeners(object, handlers) {
return this._setupListeners(object, handlers);
}
_setupListeners(object, handlers) {
const destroyFuncs = [];
for (const k in handlers) {
const handler = handlers[k];
if (handler) {
destroyFuncs.push(this._setupListener(object, k, handler));
}
}
return destroyFuncs;
}
_setupListener(object, event, listener) {
if (this.destroyed) {
return () => null;
}
if (object instanceof HTMLElement) {
_addSafePassiveEventListener(this.getFrameworkOverrides(), object, event, listener);
} else {
object.addEventListener(event, listener);
}
const destroyFunc = () => {
object.removeEventListener(event, listener);
return null;
};
this.destroyFunctions.push(destroyFunc);
return () => {
destroyFunc();
this.destroyFunctions = this.destroyFunctions.filter((fn) => fn !== destroyFunc);
return null;
};
}
/**
* Setup a managed property listener for the given GridOption property.
* However, stores the destroy function in the beanStub so that if this bean
* is a component the destroy function will be called when the component is destroyed
* as opposed to being cleaned up only when the GridOptionsService is destroyed.
*/
setupGridOptionListener(event, listener) {
this.gos.addPropertyEventListener(event, listener);
const destroyFunc = () => {
this.gos.removePropertyEventListener(event, listener);
return null;
};
this.destroyFunctions.push(destroyFunc);
return () => {
destroyFunc();
this.destroyFunctions = this.destroyFunctions.filter((fn) => fn !== destroyFunc);
return null;
};
}
/**
* Setup a managed property listener for the given GridOption property.
* @param event GridOption property to listen to changes for.
* @param listener Listener to run when property value changes
*/
addManagedPropertyListener(event, listener) {
if (this.destroyed) {
return () => null;
}
return this.setupGridOptionListener(event, listener);
}
/**
* Setup managed property listeners for the given set of GridOption properties.
* The listener will be run if any of the property changes but will only run once if
* multiple of the properties change within the same framework lifecycle event.
* Works on the basis that GridOptionsService updates all properties *before* any property change events are fired.
* @param events Array of GridOption properties to listen for changes too.
* @param listener Shared listener to run if any of the properties change
*/
addManagedPropertyListeners(events, listener) {
if (this.destroyed) {
return;
}
const eventsKey = events.join("-") + this.propertyListenerId++;
const wrappedListener = (event) => {
if (event.changeSet) {
if (event.changeSet && event.changeSet.id === this.lastChangeSetIdLookup[eventsKey]) {
return;
}
this.lastChangeSetIdLookup[eventsKey] = event.changeSet.id;
}
const propertiesChangeEvent = {
type: "gridPropertyChanged",
changeSet: event.changeSet,
source: event.source
};
listener(propertiesChangeEvent);
};
events.forEach((event) => this.setupGridOptionListener(event, wrappedListener));
}
addDestroyFunc(func) {
if (this.isAlive()) {
this.destroyFunctions.push(func);
} else {
func();
}
}
createManagedBean(bean, context) {
const res = this.createBean(bean, context);
this.addDestroyFunc(this.destroyBean.bind(this, bean, context));
return res;
}
createBean(bean, context, afterPreCreateCallback) {
return (context || this.stubContext).createBean(bean, afterPreCreateCallback);
}
/**
* Destroys a bean and returns undefined to support destruction and clean up in a single line.
* this.dateComp = this.context.destroyBean(this.dateComp);
*/
destroyBean(bean, context) {
return (context || this.stubContext).destroyBean(bean);
}
/**
* Destroys an array of beans and returns an empty array to support destruction and clean up in a single line.
* this.dateComps = this.context.destroyBeans(this.dateComps);
*/
destroyBeans(beans, context) {
return (context || this.stubContext).destroyBeans(beans);
}
};
function isProvidedColumnGroup(col) {
return col instanceof AgProvidedColumnGroup;
}
var AgProvidedColumnGroup = class extends BeanStub {
constructor(colGroupDef, groupId, padding, level) {
super();
this.isColumn = false;
this.expandable = false;
this.instanceId = getNextColInstanceId();
this.expandableListenerRemoveCallback = null;
this.colGroupDef = colGroupDef;
this.groupId = groupId;
this.expanded = !!colGroupDef && !!colGroupDef.openByDefault;
this.padding = padding;
this.level = level;
}
destroy() {
if (this.expandableListenerRemoveCallback) {
this.reset(null, void 0);
}
super.destroy();
}
reset(colGroupDef, level) {
this.colGroupDef = colGroupDef;
this.level = level;
this.originalParent = null;
if (this.expandableListenerRemoveCallback) {
this.expandableListenerRemoveCallback();
}
this.children = void 0;
this.expandable = void 0;
}
getInstanceId() {
return this.instanceId;
}
setOriginalParent(originalParent) {
this.originalParent = originalParent;
}
getOriginalParent() {
return this.originalParent;
}
getLevel() {
return this.level;
}
isVisible() {
if (this.children) {
return this.children.some((child) => child.isVisible());
}
return false;
}
isPadding() {
return this.padding;
}
setExpanded(expanded) {
this.expanded = expanded === void 0 ? false : expanded;
this.dispatchLocalEvent({ type: "expandedChanged" });
}
isExpandable() {
return this.expandable;
}
isExpanded() {
return this.expanded;
}
getGroupId() {
return this.groupId;
}
getId() {
return this.getGroupId();
}
setChildren(children) {
this.children = children;
}
getChildren() {
return this.children;
}
getColGroupDef() {
return this.colGroupDef;
}
getLeafColumns() {
const result = [];
this.addLeafColumns(result);
return result;
}
addLeafColumns(leafColumns) {
if (!this.children) {
return;
}
this.children.forEach((child) => {
if (isColumn(child)) {
leafColumns.push(child);
} else if (isProvidedColumnGroup(child)) {
child.addLeafColumns(leafColumns);
}
});
}
getColumnGroupShow() {
const colGroupDef = this.colGroupDef;
if (!colGroupDef) {
return;
}
return 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
setupExpandable() {
this.setExpandable();
if (this.expandableListenerRemoveCallback) {
this.expandableListenerRemoveCallback();
}
const listener = this.onColumnVisibilityChanged.bind(this);
this.getLeafColumns().forEach((col) => col.addEventListener("visibleChanged", listener));
this.expandableListenerRemoveCallback = () => {
this.getLeafColumns().forEach((col) => col.removeEventListener("visibleChanged", listener));
this.expandableListenerRemoveCallback = null;
};
}
setExpandable() {
if (this.isPadding()) {
return;
}
let atLeastOneShowingWhenOpen = false;
let atLeastOneShowingWhenClosed = false;
let atLeastOneChangeable = false;
const children = this.findChildrenRemovingPadding();
for (let i = 0, j = children.length; i < j; i++) {
const abstractColumn = children[i];
if (!abstractColumn.isVisible()) {
continue;
}
const headerGroupShow = abstractColumn.getColumnGroupShow();
if (headerGroupShow === "open") {
atLeastOneShowingWhenOpen = true;
atLeastOneChangeable = true;
} else if (headerGroupShow === "closed") {
atLeastOneShowingWhenClosed = true;
atLeastOneChangeable = true;
} else {
atLeastOneShowingWhenOpen = true;
atLeastOneShowingWhenClosed = true;
}
}
const expandable = atLeastOneShowingWhenOpen && atLeastOneShowingWhenClosed && atLeastOneChangeable;
if (this.expandable !== expandable) {
this.expandable = expandable;
this.dispatchLocalEvent({ type: "expandableChanged" });
}
}
findChildrenRemovingPadding() {
const res = [];
const process = (items) => {
items.forEach((item) => {
const skipBecausePadding = isProvidedColumnGroup(item) && item.isPadding();
if (skipBecausePadding) {
process(item.children);
} else {
res.push(item);
}
});
};
process(this.children);
return res;
}
onColumnVisibilityChanged() {
this.setExpandable();
}
};
var CONTROLS_COLUMN_ID_PREFIX = "ag-Grid-ControlsColumn";
var ControlsColService = class extends BeanStub {
constructor() {
super(...arguments);
this.beanName = "controlsColService";
}
createControlsCols() {
const { gos } = this;
const so = gos.get("rowSelection");
if (!so || typeof so !== "object") {
return [];
}
const checkboxes = _getCheckboxes(so);
const headerCheckbox = _getHeaderCheckbox(so);
if (checkboxes || headerCheckbox) {
const selectionColumnDef = gos.get("selectionColumnDef");
const enableRTL = gos.get("enableRtl");
const colDef = {
// overridable properties
maxWidth: 50,
resizable: false,
suppressHeaderMenuButton: true,
sortable: false,
suppressMovable: true,
lockPosition: enableRTL ? "right" : "left",
comparator(valueA, valueB, nodeA, nodeB) {
const aSelected = nodeA.isSelected();
const bSelected = nodeB.isSelected();
return aSelected && bSelected ? 0 : aSelected ? 1 : -1;
},
editable: false,
suppressFillHandle: true,
// overrides
...selectionColumnDef,
// non-overridable properties
colId: `${CONTROLS_COLUMN_ID_PREFIX}`
};
const col = new AgColumn(colDef, null, colDef.colId, false);
this.createBean(col);
return [col];
}
return [];
}
};
var GROUP_AUTO_COLUMN_ID = "ag-Grid-AutoColumn";
function getColumnsFromTree(rootColumns) {
const result = [];
const recursiveFindColumns = (childColumns) => {
for (let i = 0; i < childColumns.length; i++) {
const child = childColumns[i];
if (isColumn(child)) {
result.push(child);
} else if (isProvidedColumnGroup(child)) {
recursiveFindColumns(child.getChildren());
}
}
};
recursiveFindColumns(rootColumns);
return result;
}
function getWidthOfColsInList(columnList) {
return columnList.reduce((width, col) => width + col.getActualWidth(), 0);
}
function destroyColumnTree(context, oldTree, newTree) {
const oldObjectsById = {};
if (!oldTree) {
return;
}
depthFirstOriginalTreeSearch(null, oldTree, (child) => {
oldObjectsById[child.getInstanceId()] = child;
});
if (newTree) {
depthFirstOriginalTreeSearch(null, newTree, (child) => {
oldObjectsById[child.getInstanceId()] = null;
});
}
const colsToDestroy = Object.values(oldObjectsById).filter((item) => item != null);
context.destroyBeans(colsToDestroy);
}
function isColumnGroupAutoCol(col) {
const colId = col.getId();
return colId.startsWith(GROUP_AUTO_COLUMN_ID);
}
function isColumnControlsCol(col) {
return col.getColId().startsWith(CONTROLS_COLUMN_ID_PREFIX);
}
function convertColumnTypes(type) {
let typeKeys = [];
if (type instanceof Array) {
const invalidArray = type.some((a) => typeof a !== "string");
if (invalidArray) {
_warnOnce("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 {
_warnOnce("colDef.type should be of type 'string' | 'string[]'");
}
return typeKeys;
}
var FrameworkEventListenerService = class {
constructor(frameworkOverrides) {
this.frameworkOverrides = frameworkOverrides;
this.wrappedListeners = /* @__PURE__ */ new Map();
this.wrappedGlobalListeners = /* @__PURE__ */ new Map();
}
wrap(userListener) {
let listener = userListener;
if (this.frameworkOverrides.shouldWrapOutgoing) {
listener = (event) => {
this.frameworkOverrides.wrapOutgoing(() => userListener(event));
};
this.wrappedListeners.set(userListener, listener);
}
return listener;
}
wrapGlobal(userListener) {
let listener = userListener;
if (this.frameworkOverrides.shouldWrapOutgoing) {
listener = (eventType, event) => {
this.frameworkOverrides.wrapOutgoing(() => userListener(eventType, event));
};
this.wrappedGlobalListeners.set(userListener, listener);
}
return listener;
}
unwrap(userListener) {
return this.wrappedListeners.get(userListener) ?? userListener;
}
unwrapGlobal(userListener) {
return this.wrappedGlobalListeners.get(userListener) ?? userListener;
}
};
var SKIP_JS_BUILTINS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
function _iterateObject(object, callback) {
if (object == null) {
return;
}
if (Array.isArray(object)) {
for (let i = 0; i < object.length; i++) {
callback(i.toString(), object[i]);
}
return;
}
for (const [key, value] of Object.entries(object)) {
callback(key, value);
}
}
function _cloneObject(object) {
const copy = {};
const keys = Object.keys(object);
for (let i = 0; i < keys.length; i++) {
if (SKIP_JS_BUILTINS.has(keys[i])) {
continue;
}
const key = keys[i];
const value = object[key];
copy[key] = value;
}
return copy;
}
function _deepCloneDefinition(object, keysToSkip) {
if (!object) {
return;
}
const obj = object;
const res = {};
Object.keys(obj).forEach((key) => {
if (keysToSkip && keysToSkip.indexOf(key) >= 0 || SKIP_JS_BUILTINS.has(key)) {
return;
}
const value = obj[key];
const sourceIsSimpleObject = _isNonNullObject(value) && value.constructor === Object;
if (sourceIsSimpleObject) {
res[key] = _deepCloneDefinition(value);
} else {
res[key] = value;
}
});
return res;
}
function _getAllValuesInObject(obj) {
if (!obj) {
return [];
}
const anyObject = Object;
if (typeof anyObject.values === "function") {
return anyObject.values(obj);
}
const ret = [];
for (const key in obj) {
if (obj.hasOwnProperty(key) && obj.propertyIsEnumerable(key)) {
ret.push(obj[key]);
}
}
return ret;
}
function _mergeDeep(dest, source, copyUndefined = true, makeCopyOfSimpleObjects = false) {
if (!_exists(source)) {
return;
}
_iterateObject(source, (key, sourceValue) => {
if (SKIP_JS_BUILTINS.has(key)) {
return;
}
let destValue = dest[key];
if (destValue === sourceValue) {
return;
}
if (makeCopyOfSimpleObjects) {
const objectIsDueToBeCopied = destValue == null && sourceValue != null;
if (objectIsDueToBeCopied) {
const sourceIsSimpleObject = typeof sourceValue === "object" && sourceValue.constructor === Object;
const 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 !== void 0) {
dest[key] = sourceValue;
}
});
}
function _getValueUsingField(data, field, fieldContainsDots) {
if (!field || !data) {
return;
}
if (!fieldContainsDots) {
return data[field];
}
const fields = field.split(".");
let currentObject = data;
for (let i = 0; i < fields.length; i++) {
if (currentObject == null) {
return void 0;
}
currentObject = currentObject[fields[i]];
}
return currentObject;
}
function _isNonNullObject(value) {
return typeof value === "object" && value !== null;
}
var COL_DEF_DEFAULTS = {
resizable: true,
sortable: true
};
var instanceIdSequence = 0;
function getNextColInstanceId() {
return instanceIdSequence++;
}
function isColumn(col) {
return col instanceof AgColumn;
}
var AgColumn = class extends BeanStub {
constructor(colDef, userProvidedColDef, colId, primary) {
super();
this.isColumn = true;
this.instanceId = getNextColInstanceId();
this.autoHeaderHeight = null;
this.moving = false;
this.menuVisible = false;
this.lastLeftPinned = false;
this.firstRightPinned = false;
this.filterActive = false;
this.columnEventService = new LocalEventService();
this.tooltipEnabled = false;
this.rowGroupActive = false;
this.pivotActive = false;
this.aggregationActive = false;
this.colDef = colDef;
this.userProvidedColDef = userProvidedColDef;
this.colId = colId;
this.primary = primary;
this.setState(colDef);
}
wireBeans(beans) {
this.columnHoverService = beans.columnHoverService;
}
getInstanceId() {
return this.instanceId;
}
setState(colDef) {
if (colDef.sort !== void 0) {
if (colDef.sort === "asc" || colDef.sort === "desc") {
this.sort = colDef.sort;
}
} else {
if (colDef.initialSort === "asc" || colDef.initialSort === "desc") {
this.sort = colDef.initialSort;
}
}
const sortIndex = colDef.sortIndex;
const initialSortIndex = colDef.initialSortIndex;
if (sortIndex !== void 0) {
if (sortIndex !== null) {
this.sortIndex = sortIndex;
}
} else {
if (initialSortIndex !== null) {
this.sortIndex = initialSortIndex;
}
}
const hide = colDef.hide;
const initialHide = colDef.initialHide;
if (hide !== void 0) {
this.visible = !hide;
} else {
this.visible = !initialHide;
}
if (colDef.pinned !== void 0) {
this.setPinned(colDef.pinned);
} else {
this.setPinned(colDef.initialPinned);
}
const flex = colDef.flex;
const initialFlex = colDef.initialFlex;
if (flex !== void 0) {
this.flex = flex;
} else if (initialFlex !== void 0) {
this.flex = initialFlex;
}
}
// gets called when user provides an alternative colDef, eg
setColDef(colDef, userProvidedColDef, source) {
this.colDef = colDef;
this.userProvidedColDef = userProvidedColDef;
this.initMinAndMaxWidths();
this.initDotNotation();
this.initTooltip();
this.columnEventService.dispatchEvent(this.createColumnEvent("colDefChanged", source));
}
getUserProvidedColDef() {
return this.userProvidedColDef;
}
setParent(parent) {
this.parent = parent;
}
getParent() {
return this.parent;
}
setOriginalParent(originalParent) {
this.originalParent = originalParent;
}
getOriginalParent() {
return this.originalParent;
}
// this is done after constructor as it uses gridOptionsService
postConstruct() {
this.initMinAndMaxWidths();
this.resetActualWidth("gridInitializing");
this.initDotNotation();
this.initTooltip();
}
initDotNotation() {
const suppressDotNotation = this.gos.get("suppressFieldDotNotation");
this.fieldContainsDots = _exists(this.colDef.field) && this.colDef.field.indexOf(".") >= 0 && !suppressDotNotation;
this.tooltipFieldContainsDots = _exists(this.colDef.tooltipField) && this.colDef.tooltipField.indexOf(".") >= 0 && !suppressDotNotation;
}
initMinAndMaxWidths() {
const colDef = this.colDef;
this.minWidth = colDef.minWidth ?? this.gos.environment.getDefaultColumnMinWidth();
this.maxWidth = colDef.maxWidth ?? Number.MAX_SAFE_INTEGER;
}
initTooltip() {
this.tooltipEnabled = _exists(this.colDef.tooltipField) || _exists(this.colDef.tooltipValueGetter) || _exists(this.colDef.tooltipComponent);
}
resetActualWidth(source) {
const initialWidth = this.calculateColInitialWidth(this.colDef);
this.setActualWidth(initialWidth, source, true);
}
calculateColInitialWidth(colDef) {
let width;
const colDefWidth = _attrToNumber(colDef.width);
const colDefInitialWidth = _attrToNumber(colDef.initialWidth);
if (colDefWidth != null) {
width = colDefWidth;
} else if (colDefInitialWidth != null) {
width = colDefInitialWidth;
} else {
width = 200;
}
return Math.max(M