@genesislcap/grid-pro 15.35.1 → 16.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,108 +1,64 @@
1
1
  import { __awaiter, __decorate, __rest } from "tslib";
2
+ import { ClientSideRowModelModule } from '@ag-grid-community/client-side-row-model';
3
+ import { ComponentUtil, Events, Grid, ModuleRegistry } from '@ag-grid-community/core';
4
+ import { CsvExportModule } from '@ag-grid-community/csv-export';
2
5
  import { DatasourceDefaults } from '@genesislcap/foundation-comms';
3
- import { avoidTreeShaking, LifecycleMixin, respondToVisibility, } from '@genesislcap/foundation-utils';
4
- import { baseLayerLuminance, StandardLuminance } from '@microsoft/fast-components';
6
+ import { avoidTreeShaking, insertDocumentCSSRule, LifecycleMixin, respondToVisibility, } from '@genesislcap/foundation-utils';
5
7
  import { attr, DOM, observable } from '@microsoft/fast-element';
6
8
  import { FoundationElement } from '@microsoft/fast-foundation';
7
- import { CellStyleModule, CheckboxEditorModule, ClientSideRowModelApiModule, ClientSideRowModelModule, ColumnApiModule, ColumnAutoSizeModule, createGrid, CsvExportModule, CustomEditorModule, CustomFilterModule, DateEditorModule, DateFilterModule, DragAndDropModule, EventApiModule, HighlightChangesModule, InfiniteRowModelModule, ModuleRegistry, NumberEditorModule, NumberFilterModule, PaginationModule, RenderApiModule, RowApiModule, RowDragModule, RowSelectionModule, RowStyleModule, SelectEditorModule, TextEditorModule, TextFilterModule, TooltipModule, _ColumnMoveModule as ColumnMoveModule, } from 'ag-grid-community';
9
+ import { classNames } from '@microsoft/fast-web-utilities';
8
10
  import * as changeCase from 'change-case';
9
11
  import debounce from 'lodash.debounce';
10
12
  import { GridProCell } from './cell';
11
13
  import { DateEditor, MultiselectEditor, NumberEditor, SelectEditor, StringEditor, } from './cell-editors';
12
14
  import { ActionRenderer, ActionsMenuRenderer, BooleanRenderer, EditableRenderer, IconRenderer, SelectRenderer, StatusPillRenderer, } from './cell-renderers';
13
15
  import { GridProColumn, resolveVisibleColumnFields } from './column';
14
- import { EnumColumnFilter, EnumColumnFloatingFilter, GridProFilterTypes } from './column-filters';
15
- import { ColumnSelection } from './column-selection';
16
- import { GRID_PRO_COLUMN_DRAG_BRIDGE_CONTEXT_KEY, gridProColumnDragBridgeModule, } from './column-selection/grid-pro-column-drag-bridge';
17
- import { GridProClientSideDatasource, GridProInfiniteDatasource, GridProServerSideDatasource, } from './datasource';
16
+ import { GridProClientSideDatasource, GridProServerSideDatasource } from './datasource';
18
17
  import { baseDatasourceEventNames } from './datasource/base.types';
18
+ import { agThemeFontFaceMap, defaultAgGridFontFace } from './external';
19
19
  import { GridProGenesisDatasource, gridProGenesisDatasourceEventNames, } from './grid-pro-genesis-datasource';
20
20
  import { datasourceEventNames, } from './grid-pro-genesis-datasource/datasource-events.types';
21
- import { AG_PROPERTIES, copyAttributesToGridOptions, DEBOUNCED_RESIZE_TIME, gridProErrorNames, gridProEventNames, } from './grid-pro.definitions';
22
- import { DEFAULT_STATUS_BAR_CONFIG, EDITED_COLUMN_FIELD, ERROR_COLUMN_FIELD, GRID_READY_EVENT, GridOptionsConfig, GridProRendererTypes, GridProStatusBarTypes, } from './grid-pro.types';
21
+ import { AG_PROPERTIES, copyAttributesToGridOptions, DEBOUNCED_RESIZE_TIME, defaultGridProConfig, foundationGridProShadowOptions, gridProErrorNames, gridProEventNames, } from './grid-pro.definitions';
22
+ import { foundationGridProStyles as styles } from './grid-pro.styles';
23
+ import { gridProTemplate as template } from './grid-pro.template';
24
+ import { AgGridTheme, agThemeFontsId, agThemeTokenMapClassname, DEFAULT_STATUS_BAR_CONFIG, EDITED_COLUMN_FIELD, ERROR_COLUMN_FIELD, GRID_READY_EVENT, GridOptionsConfig, GridProRendererTypes, GridProStatusBarTypes, } from './grid-pro.types';
23
25
  import { StatePersistence } from './state-persistence';
24
26
  import { LabelValueStatusBarComponent, LoadMoreStatusBarComponent, ReloadStatusBarComponent, RowCountStatusBarComponent, } from './status-bar-components';
25
27
  import { ErrorTooltip } from './tooltips';
26
- import { convertToKebabCase, logger, mergeAndDedupColDefWithColumnState, sanitizeColumnState, } from './utils';
27
- avoidTreeShaking(GridProGenesisDatasource, GridProClientSideDatasource, GridProServerSideDatasource, GridProInfiniteDatasource, GridProCell, GridProColumn, ColumnSelection);
28
- ModuleRegistry.registerModules([
29
- CsvExportModule,
30
- ClientSideRowModelModule,
31
- PaginationModule,
32
- RowStyleModule,
33
- ClientSideRowModelApiModule,
34
- EventApiModule,
35
- TextFilterModule,
36
- HighlightChangesModule,
37
- ColumnApiModule,
38
- NumberFilterModule,
39
- CellStyleModule,
40
- DateFilterModule,
41
- RowApiModule,
42
- TooltipModule,
43
- ColumnAutoSizeModule,
44
- RenderApiModule,
45
- RowDragModule,
46
- RowSelectionModule,
47
- CustomEditorModule,
48
- TextEditorModule,
49
- NumberEditorModule,
50
- DateEditorModule,
51
- SelectEditorModule,
52
- CheckboxEditorModule,
53
- CustomFilterModule,
54
- InfiniteRowModelModule,
55
- DragAndDropModule,
56
- ColumnMoveModule,
57
- gridProColumnDragBridgeModule,
58
- // ValidationModule,
59
- ]);
28
+ import { convertColDefsToColumnStates, convertToKebabCase, logger, mergeAndDedupColDefWithColumnState, sanitizeColumnState, } from './utils';
29
+ avoidTreeShaking(GridProGenesisDatasource, GridProClientSideDatasource, GridProServerSideDatasource, GridProCell, GridProColumn);
30
+ ModuleRegistry.registerModules([CsvExportModule, ClientSideRowModelModule]);
60
31
  const DEBOUNCE_TIME = 400;
61
- const Events = {
62
- EVENT_GRID_READY: 'gridReady',
63
- };
32
+ // Re-export AG_PROPERTIES from definitions for backwards compatibility
33
+ export { AG_PROPERTIES };
64
34
  /**
65
- * Finds `key`'s accessor among the component's own prototypes.
66
- * @remarks Own properties are skipped because the caller installs one: `connectedCallback` can run
67
- * more than once, and starting from the instance would wrap the accessor it defined last time. The
68
- * walk stops at `HTMLElement` so that a property merely sharing a name with a native one (such as
69
- * `tabIndex`) is left alone instead of picking up DOM semantics through the caller.
70
- * @internal
71
- */
72
- function findDeclaredAccessor(target, key) {
73
- let proto = Object.getPrototypeOf(target);
74
- while (proto && proto !== HTMLElement.prototype) {
75
- const descriptor = Object.getOwnPropertyDescriptor(proto, key);
76
- if (descriptor)
77
- return descriptor;
78
- proto = Object.getPrototypeOf(proto);
79
- }
80
- return undefined;
81
- }
82
- /**
83
- * The Grid Pro element (AG Grid v35 compatible).
84
- * @remarks Grid Pro is a Web Component wrapper around the AG Grid Community library.
85
- * @beta
35
+ * The Grid Pro Legacy element (AG Grid v29 compatible).
36
+ * @remarks Grid Pro Legacy is a Web Component wrapper around the AG Grid Community library.
37
+ * @public
38
+ * @deprecated Legacy AG Grid v29 wrapper. Use `GridPro` (AG Grid v36) instead.
86
39
  * @tagname %%prefix%%-grid-pro
87
40
  *
88
- * @fires gridReady - Fired when AG Grid is ready (detail includes the grid-ready event and grid id). detail: `GridReadyEventDetail`
89
- * @fires onGridReady - Deprecated alias for the grid-ready signal; prefer `gridReady`. detail: `GridReadyEventDetail`
41
+ * @fires gridReady - Fired when AG Grid is ready (detail includes the grid-ready event and grid id)
42
+ * @fires onGridReady - Deprecated alias for the grid-ready signal; prefer `gridReady`
90
43
  * @fires gridready - Native `Event` from `globalEventListener` when AG Grid fires `gridReady` (`agGridDetails` holds the AG Grid event)
91
- * @remarks Re-emits AG Grid public API events when listeners are registered via `addEventListener` (event names match AG Grid public event strings). The same AG Grid events are also dispatched as native `Event`s with lowercased `type` and payload on `agGridDetails` (for example `addEventListener('columnresized', ...)`).
44
+ * @remarks Re-emits AG Grid public API events when listeners are registered via `addEventListener` (event names match `ComponentUtil.PUBLIC_EVENTS` from `@ag-grid-community/core`). The same AG Grid events are also dispatched as native `Event`s with lowercased `type` and payload on `agGridDetails` (for example `addEventListener('columnresized', ...)`).
92
45
  */
93
- export class GridProBeta extends LifecycleMixin(FoundationElement) {
94
- /** @internal Shared AG column-drag bridge for custom tool panels. */
95
- getColumnDragBridge() {
96
- return this.columnDragBridge;
97
- }
46
+ export class GridProLegacy extends LifecycleMixin(FoundationElement) {
98
47
  rowDataChanged(_, rowData) {
99
- // `initialised` flips true right after createGrid(), but `gridApi` is only assigned in the
100
- // async onGridReady callback — so a binding push in that window would crash on an undefined
101
- // api. Skipping is lossless: onGridReady applies `this.rowData` itself once the api exists,
102
- // and FAST has already stored the new value on the instance before calling this handler.
48
+ // `initialised` flips true before `gridApi` is assigned (mid-reinit), so relying on it
49
+ // alone here can crash setRowData with an undefined api.
103
50
  if (this.initialised && this.gridApi) {
104
- this.gridApi.setGridOption('rowData', rowData);
51
+ this.gridApi.setRowData(rowData);
52
+ }
53
+ }
54
+ themeChanged(oldValue, newValue) {
55
+ if (!newValue) {
56
+ this.classNames = '';
57
+ this.destroyFontFace();
58
+ return;
105
59
  }
60
+ this.classNames = classNames(agThemeTokenMapClassname(newValue), newValue);
61
+ this.insertFontFace(newValue);
106
62
  }
107
63
  /**
108
64
  * The slot ref binds asynchronously, and the queued `initGrid` skips any run that beats it. FAST
@@ -118,9 +74,6 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
118
74
  this.initGrid();
119
75
  }
120
76
  }
121
- enableColumnSelectionChanged() {
122
- this.syncColumnSelectionHostLayout();
123
- }
124
77
  getfilterModel() {
125
78
  return __awaiter(this, void 0, void 0, function* () {
126
79
  if (!this.persistFilterModelKey) {
@@ -141,6 +94,9 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
141
94
  }
142
95
  constructor() {
143
96
  super();
97
+ // Cache for total column width to avoid repeated calculations
98
+ this.cachedTotalColumnWidth = null;
99
+ this.columnCount = 0;
144
100
  this.gridErrorItems = [];
145
101
  this.disposed = false;
146
102
  this.debouncedSaveColumnState = debounce(this.saveColumnState.bind(this), DEBOUNCE_TIME);
@@ -151,24 +107,64 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
151
107
  // Genesis-specific attrs
152
108
  this.autoCellRendererByType = false;
153
109
  this.onlyTemplateColDefs = false;
110
+ // AG-specific attrs
154
111
  /**
155
112
  * Boolean attribute to control whether the grid autosizes the columns upon interaction.
156
113
  * This will disable the column widths from being manually set, and doesn't save the widths
157
114
  * in local storage if you are using `persist-column-state-key`.
158
115
  */
159
116
  this.gridAutosizingEnabled = false;
117
+ /**
118
+ * Boolean attribute to control whether the grid automatically sizes columns to fit their content.
119
+ * This will call AG Grid's autoSizeColumns() method to automatically adjust column widths based on content.
120
+ * @public
121
+ */
122
+ this.sizeColumnsToContent = false;
123
+ /**
124
+ * Boolean attribute to adjust the size of columns to fit the available horizontal space.
125
+ * This will call AG Grid's sizeColumnsToFit() method.
126
+ * @public
127
+ */
128
+ this.sizeColumnsToFit = false;
129
+ /**
130
+ * The index to add new rows to when using `applyTransaction` or `applyTransactionAsync`
131
+ */
132
+ this.addIndex = 0;
133
+ /**
134
+ * Whether to use the `applyTransactionAsync` function for *add* transactions
135
+ * @remarks Defaults to false
136
+ */
137
+ this.asyncAdd = false;
138
+ /**
139
+ * Whether to use the `applyTransactionAsync` function for *remove* transactions
140
+ * @remarks Defaults to false
141
+ */
142
+ this.asyncRemove = false;
143
+ /**
144
+ * Whether to use the `applyTransactionAsync` function for *update* transactions
145
+ * @remarks Defaults to true
146
+ */
147
+ this.asyncUpdate = true;
160
148
  /**
161
149
  * If false, will disable cell flashing for all cells by default, unless otherwise defined in custom colDef
162
150
  * @remarks Defaults to true
163
151
  */
164
152
  this.enableCellFlashing = false;
153
+ /**
154
+ * @deprecated - use `enableRowFlashing` instead.
155
+ */
156
+ this.enabledRowFlashing = false;
165
157
  /**
166
158
  * If true, will enable row flashing for all rows for `add` async transactions
167
159
  */
168
160
  this.enableRowFlashing = false;
169
- /** Wired to `gridOptions.context` for columns picker → grid drag (see bridge module). */
170
- this.columnDragBridge = {};
161
+ /**
162
+ * The default column config to reset to when deleteColumnState is called.
163
+ */
164
+ this.defaultColumnConfig = [];
165
+ this.gridFontFace = defaultAgGridFontFace;
171
166
  this.columnComponentName = 'grid-pro-column';
167
+ this.theme = AgGridTheme.alpine;
172
168
  this.themeMode = 'dark';
173
169
  /**
174
170
  * Configuration for the grid status bar components.
@@ -186,27 +182,14 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
186
182
  * This requires AG Grid Enterprise module to be available for the status bar to be displayed when enabled.
187
183
  */
188
184
  this.withStatusBar = false;
189
- /**
190
- * Shows a Column Selection button above the grid.
191
- * @public
192
- */
193
- this.enableColumnSelection = false;
194
185
  this.applyingDatasourceGridOptions = false;
195
186
  this.rehydrationAttempted = false;
196
- this.rootEventsListeners = [];
197
- this.datasourceEventHandlers = [];
187
+ this.eventHandlers = [];
198
188
  this.gridEventsQueue = [];
199
189
  this.registeredGridEvents = new Set();
200
190
  this.gridEventListeners = new Map();
201
191
  this.boundGlobalEventListener = this.globalEventListener.bind(this);
202
192
  this._filterConfig = undefined;
203
- this.handleLuminanceChange = (record) => {
204
- const luminance = baseLayerLuminance.getValueFor(record.target);
205
- this.themeMode = luminance === StandardLuminance.DarkMode ? 'dark' : 'light';
206
- };
207
- this.luminanceObserver = {
208
- handleChange: (record) => this.handleLuminanceChange(record),
209
- };
210
193
  this.agAttributes = {};
211
194
  this.agPropertiesMap = AG_PROPERTIES.reduce((map, property) => {
212
195
  map[property.toLowerCase()] = property;
@@ -214,65 +197,28 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
214
197
  return map;
215
198
  }, {});
216
199
  const hideDataSourceError = this.hideDatasourceError.bind(this);
217
- this.rootEventsListeners.push([gridProGenesisDatasourceEventNames.dataInit, hideDataSourceError], [gridProEventNames.datasourceErrorClose, hideDataSourceError],
218
- // Base datasource error handling for resource validation and initialization errors
219
- [baseDatasourceEventNames.error, this.handleBaseDatasourceError.bind(this)], [baseDatasourceEventNames.connected, hideDataSourceError]);
220
- this.datasourceEventHandlers = [
221
- [datasourceEventNames.initialize, this.handleInitialize.bind(this)],
222
- [datasourceEventNames.dataLoaded, this.handleDataLoaded.bind(this)],
223
- [datasourceEventNames.dataChanged, this.handleDataChanged.bind(this)],
224
- [datasourceEventNames.schemaUpdated, this.handleSchemaUpdated.bind(this)],
225
- [datasourceEventNames.dataCleared, this.handleDataCleared.bind(this)],
226
- [datasourceEventNames.loadingStarted, this.handleLoadingStarted.bind(this)],
227
- [
228
- datasourceEventNames.loadingFinished,
229
- this.handleLoadingFinished.bind(this),
230
- ],
231
- [
232
- datasourceEventNames.noDataAvailable,
233
- this.handleNoDataAvailable.bind(this),
234
- ],
235
- [
236
- datasourceEventNames.filtersRestored,
237
- this.handleFiltersRestored.bind(this),
238
- ],
239
- [
240
- datasourceEventNames.moreDataAvailable,
241
- this.handleMoreDataAvailable.bind(this),
242
- ],
243
- [datasourceEventNames.error, this.handleDatasourceError.bind(this)],
244
- [datasourceEventNames.destroy, this.handleDatasourceDestroy.bind(this)],
245
- [datasourceEventNames.cacheFilterConfig, this.cacheFilterConfig.bind(this)],
246
- [
247
- datasourceEventNames.refreshServerSide,
248
- this.handleRefreshServerSide.bind(this),
249
- ],
250
- [
251
- datasourceEventNames.setServerSideDatasource,
252
- this.handleSetServerSideDatasource.bind(this),
253
- ],
254
- [
255
- datasourceEventNames.addGridCssClass,
256
- this.handleAddGridCssClass.bind(this),
257
- ],
258
- [
259
- datasourceEventNames.removeGridCssClass,
260
- this.handleRemoveGridCssClass.bind(this),
261
- ],
262
- [
263
- datasourceEventNames.applyServerSideTransaction,
264
- this.handleApplyServerSideTransaction.bind(this),
265
- ],
266
- // Infinite Row Model specific events
267
- [
268
- datasourceEventNames.setInfiniteDatasource,
269
- this.handleSetInfiniteDatasource.bind(this),
270
- ],
271
- [
272
- datasourceEventNames.refreshInfiniteCache,
273
- this.handleRefreshInfiniteCache.bind(this),
274
- ],
275
- ];
200
+ // Bind all event handlers once to ensure proper add/remove of listeners
201
+ this.eventHandlers.push(
202
+ // Root event listeners
203
+ [gridProGenesisDatasourceEventNames.dataInit, hideDataSourceError], [gridProEventNames.datasourceErrorClose, hideDataSourceError], [baseDatasourceEventNames.error, this.handleBaseDatasourceError.bind(this)], [baseDatasourceEventNames.connected, hideDataSourceError],
204
+ // Datasource event listeners
205
+ [datasourceEventNames.initialize, this.handleInitialize.bind(this)], [datasourceEventNames.dataLoaded, this.handleDataLoaded.bind(this)], [datasourceEventNames.dataChanged, this.handleDataChanged.bind(this)], [datasourceEventNames.schemaUpdated, this.handleSchemaUpdated.bind(this)], [datasourceEventNames.dataCleared, this.handleDataCleared.bind(this)], [datasourceEventNames.loadingStarted, this.handleLoadingStarted.bind(this)], [datasourceEventNames.loadingFinished, this.handleLoadingFinished.bind(this)], [datasourceEventNames.noDataAvailable, this.handleNoDataAvailable.bind(this)], [datasourceEventNames.filtersRestored, this.handleFiltersRestored.bind(this)], [datasourceEventNames.moreDataAvailable, this.handleMoreDataAvailable.bind(this)], [datasourceEventNames.error, this.handleDatasourceError.bind(this)], [datasourceEventNames.destroy, this.handleDatasourceDestroy.bind(this)],
206
+ // Server-side specific events
207
+ [datasourceEventNames.cacheFilterConfig, this.cacheFilterConfig.bind(this)], [datasourceEventNames.refreshServerSide, this.handleRefreshServerSide.bind(this)], [datasourceEventNames.setServerSideDatasource, this.handleSetServerSideDatasource.bind(this)], [datasourceEventNames.addGridCssClass, this.handleAddGridCssClass.bind(this)], [datasourceEventNames.removeGridCssClass, this.handleRemoveGridCssClass.bind(this)], [
208
+ datasourceEventNames.applyServerSideTransaction,
209
+ this.handleApplyServerSideTransaction.bind(this),
210
+ ],
211
+ // Infinite Row Model events: not supported by this legacy grid (it registers neither the
212
+ // module nor the handlers). Fail loudly rather than leaving a silently empty grid.
213
+ [datasourceEventNames.setInfiniteDatasource, this.refuseInfiniteDatasource.bind(this)]);
214
+ }
215
+ /**
216
+ * The Infinite Row Model is only wired into `GridPro` (AG Grid v36), so an infinite datasource placed
217
+ * inside this element can never load data. Report it instead of ignoring the event.
218
+ * @internal
219
+ */
220
+ refuseInfiniteDatasource() {
221
+ logger.error('GridProLegacy does not support the Infinite Row Model; use GridPro (AG Grid v36) with grid-pro-infinite-datasource / datasource-type="infinite".');
276
222
  }
277
223
  /**
278
224
  * Adds an event listener to the grid element.
@@ -284,12 +230,14 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
284
230
  */
285
231
  addEventListener(eventType, listener, options) {
286
232
  super.addEventListener(eventType, listener, options);
287
- if (this.gridApi) {
288
- this.addGridEventListener(eventType);
289
- }
290
- else {
291
- if (!this.gridEventsQueue.includes(eventType)) {
292
- this.gridEventsQueue.push(eventType);
233
+ if (ComponentUtil.PUBLIC_EVENTS.includes(eventType)) {
234
+ if (this.gridApi) {
235
+ this.addGridEventListener(eventType);
236
+ }
237
+ else {
238
+ if (!this.gridEventsQueue.includes(eventType)) {
239
+ this.gridEventsQueue.push(eventType);
240
+ }
293
241
  }
294
242
  }
295
243
  }
@@ -323,12 +271,8 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
323
271
  this.removeAttribute('ds-disconnected');
324
272
  }
325
273
  connectedCallback() {
326
- var _a;
327
274
  super.connectedCallback();
328
- this.syncColumnSelectionHostLayout();
329
275
  this.disposed = false;
330
- const luminanceTarget = (_a = this.provider) !== null && _a !== void 0 ? _a : this;
331
- this.luminanceSubscription = baseLayerLuminance.subscribe(this.luminanceObserver, luminanceTarget);
332
276
  if (this.gridAutosizingEnabled) {
333
277
  this.visibilityObserverCleanup = respondToVisibility(this, (gridVisible) => {
334
278
  if (gridVisible) {
@@ -337,44 +281,25 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
337
281
  });
338
282
  }
339
283
  this.rehydrationAttempted = false;
340
- if (!this.shouldRunConnect)
341
- return;
342
- this.rootEventsListeners.forEach(([eventName, handler]) => {
284
+ this.eventHandlers.forEach(([eventName, handler]) => {
343
285
  this.addEventListener(eventName, handler);
344
286
  });
345
- // Property reflection for AG Grid properties, so `grid.rowHeight = 40` reaches AG.
346
- // A few of these keys are also declared on the component as `@attr` (`headerHeight`,
347
- // `rowHeight`), and FAST installs their accessors on the prototype. This shadows those, so
348
- // delegate reads and writes to the accessor being covered up — a getter-less own property here
349
- // would leave the declared attribute unreadable.
287
+ if (!this.shouldRunConnect)
288
+ return;
350
289
  AG_PROPERTIES.forEach((key) => {
351
- const declared = findDeclaredAccessor(this, key);
352
290
  Object.defineProperty(this, key, {
353
- get: declared === null || declared === void 0 ? void 0 : declared.get,
354
291
  set: (v) => {
355
- var _a, _b;
356
- const previous = (_a = declared === null || declared === void 0 ? void 0 : declared.get) === null || _a === void 0 ? void 0 : _a.call(this);
357
- (_b = declared === null || declared === void 0 ? void 0 : declared.set) === null || _b === void 0 ? void 0 : _b.call(this, v);
358
- this.agAttributeChangedCallback(convertToKebabCase(key), previous, v);
292
+ this.agAttributeChangedCallback(convertToKebabCase(key), undefined, v);
359
293
  },
360
294
  enumerable: true,
361
295
  configurable: true,
362
296
  });
363
297
  });
364
- // Add datasource event listeners
365
- this.toggleDatasourceEventListeners(true);
366
298
  }
367
299
  disconnectedCallback() {
368
- var _a;
369
300
  this.disposed = true;
370
301
  this.debouncedSaveColumnState.cancel();
371
302
  this.debouncedSaveFilterModel.cancel();
372
- const luminanceTarget = (_a = this.provider) !== null && _a !== void 0 ? _a : this;
373
- baseLayerLuminance.unsubscribe(this.luminanceObserver, luminanceTarget);
374
- if (this.luminanceSubscription) {
375
- this.luminanceSubscription.unsubscribe();
376
- this.luminanceSubscription = undefined;
377
- }
378
303
  if (this.visibilityObserverCleanup) {
379
304
  this.visibilityObserverCleanup();
380
305
  this.visibilityObserverCleanup = undefined;
@@ -382,10 +307,12 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
382
307
  super.disconnectedCallback();
383
308
  this.rehydrationAttempted = false;
384
309
  const shouldRunDisconnect = this.shouldRunDisconnect;
385
- this.rootEventsListeners.forEach(([eventName, handler]) => {
310
+ this.eventHandlers.forEach(([eventName, handler]) => {
386
311
  this.removeEventListener(eventName, handler);
387
312
  });
388
313
  if (!shouldRunDisconnect) {
314
+ // If lifecycle is temporarily blocked (e.g. layout drag/reconnect path),
315
+ // still tear down once the element remains detached on the next tick.
389
316
  queueMicrotask(() => {
390
317
  if (!this.isConnected) {
391
318
  this.performDisconnectCleanup();
@@ -395,9 +322,6 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
395
322
  }
396
323
  this.performDisconnectCleanup();
397
324
  }
398
- syncColumnSelectionHostLayout() {
399
- this.classList.toggle('has-column-selection', this.enableColumnSelection);
400
- }
401
325
  performDisconnectCleanup() {
402
326
  if (this.debounced) {
403
327
  clearTimeout(this.debounced);
@@ -406,19 +330,21 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
406
330
  this.initialised = false;
407
331
  this.resetGridOptionsState();
408
332
  this.destroyGridInstance();
409
- // Only remove datasource listeners on a real teardown. A blocked (reflow) disconnect must
410
- // leave them in place, or a grid that survives the reflow stops reacting to datasource
411
- // events (loading/no-rows overlays never update).
412
- this.toggleDatasourceEventListeners(false);
413
333
  // Destroy can synchronously emit final grid events; cancel again to avoid
414
334
  // retaining this element through trailing debounce timers.
415
335
  this.debouncedSaveColumnState.cancel();
416
336
  this.debouncedSaveFilterModel.cancel();
337
+ this.invalidateColumnWidthCache();
417
338
  // Clear registered events when grid is destroyed
418
339
  this.registeredGridEvents.clear();
419
340
  this.gridEventsQueue = [];
420
341
  }
342
+ /**
343
+ * Tear down the AG Grid instance. Prefer {@link GridApi#destroy}; if `gridApi` is not set yet
344
+ * (e.g. disconnect before `grid-ready`), fall back to {@link Grid#destroy} on the vanilla wrapper.
345
+ */
421
346
  destroyGridInstance() {
347
+ var _a, _b;
422
348
  if (this.gridApi) {
423
349
  this.gridEventListeners.forEach((listener, eventType) => {
424
350
  this.gridApi.removeEventListener(eventType, listener);
@@ -426,42 +352,46 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
426
352
  }
427
353
  this.gridEventListeners.clear();
428
354
  if (this.gridApi) {
355
+ // AG Grid's destroy() leaves the client-side row model populated and leaves
356
+ // scroll/touch listeners on its detached DOM; since the unmounted view is cached
357
+ // by FAST's `when`, the destroyed grid skeleton stays reachable and would retain
358
+ // the entire dataset. Clear rows first so only the small skeleton can be retained.
359
+ if (!this.isServerSide) {
360
+ try {
361
+ (_b = (_a = this.gridApi).flushAsyncTransactions) === null || _b === void 0 ? void 0 : _b.call(_a);
362
+ this.gridApi.setRowData([]);
363
+ }
364
+ catch (e) {
365
+ logger.debug('Grid Pro: failed to clear row data before destroy', e);
366
+ }
367
+ }
429
368
  this.gridApi.destroy();
430
369
  }
431
370
  else if (this.agGrid) {
432
371
  this.agGrid.destroy();
433
372
  }
434
373
  if (this.gridSlot) {
435
- // Ensure AG Grid internal measurement/theme nodes are removed immediately.
436
374
  this.gridSlot.replaceChildren();
437
375
  }
438
376
  this.gridApi = undefined;
377
+ this.columnApi = undefined;
439
378
  this.agGrid = undefined;
440
379
  }
441
- /**
442
- * Helper method to add or remove datasource event listeners
443
- * @internal
444
- */
445
- toggleDatasourceEventListeners(add) {
446
- const method = add ? 'addEventListener' : 'removeEventListener';
447
- this.datasourceEventHandlers.forEach(([eventName, handler]) => {
448
- // Bypass GridProBeta.addEventListener override: datasource events should not be
449
- // mirrored/queued as AG Grid API events.
450
- super[method](eventName, handler);
451
- });
452
- }
453
380
  /**
454
381
  * Handles datasource initialization
455
382
  * @internal
456
383
  */
457
384
  handleInitialize(event) {
458
385
  const { options, keepColDefsOnClearRowData } = event.detail;
386
+ let columnDefinitions;
459
387
  if (keepColDefsOnClearRowData) {
460
- this.columnState = this.gridApi.getColumnState();
388
+ columnDefinitions = this.gridApi.getColumnDefs();
389
+ this.columnState = this.columnApi.getColumnState();
461
390
  }
391
+ const gridOptions = Object.assign(Object.assign(Object.assign({}, this.userProvidedGridOptions), (columnDefinitions && { columnDefs: columnDefinitions })), options);
462
392
  this.applyingDatasourceGridOptions = true;
463
393
  try {
464
- this.gridOptions = Object.assign(Object.assign(Object.assign({}, this.userProvidedGridOptions), options), (keepColDefsOnClearRowData ? { columnDefs: this.gridApi.getColumnDefs() } : {}));
394
+ this.gridOptions = Object.assign({}, gridOptions);
465
395
  this.initGrid();
466
396
  }
467
397
  finally {
@@ -475,7 +405,7 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
475
405
  handleDataLoaded(event) {
476
406
  const { data } = event.detail;
477
407
  if (this.gridApi) {
478
- this.gridApi.setGridOption('rowData', data);
408
+ this.gridApi.setRowData(data);
479
409
  }
480
410
  }
481
411
  /**
@@ -483,25 +413,40 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
483
413
  * @internal
484
414
  */
485
415
  handleDataChanged(event) {
416
+ var _a, _b, _c;
486
417
  const { changes } = event.detail;
487
- // Every datasource emits this for consumers, but only the client-side row model takes row
488
- // transactions: the infinite and server-side datasources drive the grid through
489
- // refresh-infinite-cache / apply-server-side-transaction, and applyTransaction on those
490
- // models is a no-op that logs an AG Grid warning per event.
491
- if (!this.gridApi || !this.isClientSideRowModel)
418
+ // Every datasource emits this for consumers, but row transactions are a client-side row
419
+ // model API: the server-side datasource drives the grid through apply-server-side-transaction,
420
+ // and applyTransaction on that model is a no-op that logs an AG Grid warning per event.
421
+ if (!this.gridApi || this.isServerSide)
492
422
  return;
493
- const result = this.gridApi.applyTransaction(changes);
494
- this.flashAddedCells(result === null || result === void 0 ? void 0 : result.add);
495
- }
496
- /**
497
- * Whether the live grid runs AG Grid's client-side row model (the default when the datasource
498
- * set no `rowModelType`).
499
- * @internal
500
- */
501
- get isClientSideRowModel() {
502
- var _a, _b, _c;
503
- const rowModelType = (_c = (_b = (_a = this.gridApi) === null || _a === void 0 ? void 0 : _a.getGridOption) === null || _b === void 0 ? void 0 : _b.call(_a, 'rowModelType')) !== null && _c !== void 0 ? _c : 'clientSide';
504
- return rowModelType === 'clientSide';
423
+ if (((_a = changes.add) === null || _a === void 0 ? void 0 : _a.length) > 0) {
424
+ if (this.asyncAdd) {
425
+ this.gridApi.applyTransactionAsync({ add: changes.add, addIndex: this.addIndex }, (result) => {
426
+ this.flashAddedCells(result === null || result === void 0 ? void 0 : result.add);
427
+ });
428
+ }
429
+ else {
430
+ const result = this.gridApi.applyTransaction({ add: changes.add, addIndex: this.addIndex });
431
+ this.flashAddedCells(result === null || result === void 0 ? void 0 : result.add);
432
+ }
433
+ }
434
+ if (((_b = changes.update) === null || _b === void 0 ? void 0 : _b.length) > 0) {
435
+ if (this.asyncUpdate) {
436
+ this.gridApi.applyTransactionAsync({ update: changes.update });
437
+ }
438
+ else {
439
+ this.gridApi.applyTransaction({ update: changes.update });
440
+ }
441
+ }
442
+ if (((_c = changes.remove) === null || _c === void 0 ? void 0 : _c.length) > 0) {
443
+ if (this.asyncRemove) {
444
+ this.gridApi.applyTransactionAsync({ remove: changes.remove });
445
+ }
446
+ else {
447
+ this.gridApi.applyTransaction({ remove: changes.remove });
448
+ }
449
+ }
505
450
  }
506
451
  flashAddedCells(rowNodes) {
507
452
  if (this.enableRowFlashing && (rowNodes === null || rowNodes === void 0 ? void 0 : rowNodes.length)) {
@@ -514,10 +459,8 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
514
459
  */
515
460
  handleSchemaUpdated(event) {
516
461
  return __awaiter(this, void 0, void 0, function* () {
517
- // Can fire before `gridApi` is ready (mid-reinit). Unlike rowData — which onGridReady
518
- // re-applies from `this.rowData` — the schema has no other home on the instance, so
519
- // returning here used to drop it silently and leave the grid with no columns. Stash it
520
- // and replay in onGridReady.
462
+ // Can fire before `gridApi` is ready (mid-reinit). Unlike agAttributes/rowData, the schema
463
+ // has no other home on the instance, so stash it and replay it in `onGridReady`.
521
464
  if (!this.gridApi) {
522
465
  this.pendingSchemaUpdate = event.detail;
523
466
  return;
@@ -526,81 +469,44 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
526
469
  });
527
470
  }
528
471
  /**
529
- * Builds and applies column defs from a schema payload.
472
+ * Builds and applies column defs from a schema/metadata payload.
530
473
  * @internal
531
474
  */
532
475
  processSchemaUpdate(_a) {
533
- return __awaiter(this, arguments, void 0, function* ({ schema }) {
534
- // Only auto-generate columns from the datasource schema when the consumer has NOT already
535
- // supplied their own column defs (e.g. via `gridOptions`/`deferredGridOptions.columnDefs` or
536
- // `grid-pro-column` templates). Overwriting here would discard user-provided definitions —
537
- // including `ColGroupDef` group structure and custom header names — and replace them with flat
538
- // metadata columns. This mirrors the stable `GridPro` behaviour.
476
+ return __awaiter(this, arguments, void 0, function* ({ schema, metadata }) {
539
477
  const preSetColumnDefs = this.gridApi.getColumnDefs();
540
- if (preSetColumnDefs && preSetColumnDefs.length > 0) {
541
- return;
542
- }
543
- this.applyCommunityFilterFallbacks(schema);
544
- // Merge with template definitions
545
- const mergedColumnDefs = yield this.mergeAllColumnDefsAndStates(schema, true);
546
- this.gridApi.setGridOption('columnDefs', mergedColumnDefs);
547
- // Restore the persisted filter model now that the columns exist. The datasource
548
- // emits `filtersRestored` synchronously right after `schemaUpdated`, but this handler
549
- // is async (it awaits column-state hydration before applying columnDefs), so the
550
- // `filtersRestored` restore can run before the columns exist and be silently dropped.
551
- // Restoring here guarantees the columns are present for `gridApi.setFilterModel`.
552
- this.restoreCachedFilterConfig();
553
- });
554
- }
555
- /**
556
- * Downgrades enterprise filters in metadata-generated colDefs when their modules are not
557
- * registered — from v35 AG Grid throws on unregistered filters instead of falling back.
558
- * Enum columns (recognised by their metadata-sourced set-filter values) keep those values by
559
- * falling back to the community `EnumColumnFilter` instead of a plain text filter.
560
- *
561
- * The enum floating filter is only wired as the column's component, not enabled: AG's floating
562
- * filter is a full-width header row, so enabling it for one column changes the layout of every
563
- * column. Active-filter state is surfaced instead by AG's native header filter icon plus the
564
- * header tooltip the enum filter maintains; consumers wanting the floating row opt in with
565
- * `floatingFilter: true`.
566
- * @internal
567
- */
568
- applyCommunityFilterFallbacks(schema) {
569
- const hasSetFilter = this.gridApi.isModuleRegistered('SetFilterModule');
570
- const hasMultiFilter = this.gridApi.isModuleRegistered('MultiFilterModule');
571
- schema.forEach((colDef) => {
572
- var _a, _b, _c, _d, _e;
573
- if (colDef.filter === 'agSetColumnFilter' && !hasSetFilter) {
574
- logger.debug(`SetFilterModule is not registered; column '${colDef.field}' falls back to the enum filter`);
575
- colDef.filter = GridProFilterTypes.enumFilter;
576
- (_a = colDef.floatingFilterComponent) !== null && _a !== void 0 ? _a : (colDef.floatingFilterComponent = GridProFilterTypes.enumFloatingFilter);
577
- return;
578
- }
579
- if (colDef.filter !== 'agMultiColumnFilter') {
580
- return;
581
- }
582
- const setSubFilter = (_c = (_b = colDef.filterParams) === null || _b === void 0 ? void 0 : _b.filters) === null || _c === void 0 ? void 0 : _c.find((subFilter) => subFilter.filter === 'agSetColumnFilter');
583
- if (!hasMultiFilter) {
584
- if ((_d = setSubFilter === null || setSubFilter === void 0 ? void 0 : setSubFilter.filterParams) === null || _d === void 0 ? void 0 : _d.values) {
585
- logger.debug(`MultiFilterModule is not registered; enum column '${colDef.field}' falls back to the enum filter`);
586
- colDef.filter = GridProFilterTypes.enumFilter;
587
- // Carry the whole sub-filter config over, not just `values` — a consumer-authored
588
- // multi filter may also set valueFormatter, blanks, etc.
589
- colDef.filterParams = Object.assign({}, setSubFilter.filterParams);
590
- (_e = colDef.floatingFilterComponent) !== null && _e !== void 0 ? _e : (colDef.floatingFilterComponent = GridProFilterTypes.enumFloatingFilter);
591
- }
592
- else {
593
- logger.warn('MultiFilterModule is not registered, falling back to text filter');
594
- colDef.filter = 'agTextColumnFilter';
478
+ if (!preSetColumnDefs || preSetColumnDefs.length === 0) {
479
+ const colDefs = metadata
480
+ .map((field) => {
481
+ var _a;
482
+ return (Object.assign(Object.assign({}, schema.find((colDef) => colDef.field === field.name)), (_a = this.gridApi) === null || _a === void 0 ? void 0 : _a.getColumnDef(field.name)));
483
+ })
484
+ .map((colDef) => (Object.assign(Object.assign({}, colDef), { cellRenderer: this.autoCellRendererByType ? colDef.cellRenderer : undefined, cellEditor: this.autoCellRendererByType ? colDef.cellEditor : undefined })));
485
+ const colDefsMergedWithTemplateDefs = yield this.mergeAllColumnDefsAndStates(colDefs, true);
486
+ if (colDefsMergedWithTemplateDefs) {
487
+ // AG's internals will check if group/pivot are NOT NULL to trigger module registration warning for `row-grouping`.
488
+ // When using gridApi to get the currentState to save, all boolean will return false when they were not set at all.
489
+ // ColDef type is `boolean` while ColumnState is `boolean | null`.
490
+ // `rowGroup`/`pivot` only exist on leaf `ColDef`s, not on `ColGroupDef`s, so skip groups.
491
+ colDefsMergedWithTemplateDefs.forEach((col) => {
492
+ if ('children' in col) {
493
+ return;
494
+ }
495
+ if (!col.rowGroup) {
496
+ col.rowGroup = null;
497
+ }
498
+ if (!col.pivot) {
499
+ col.pivot = null;
500
+ }
501
+ });
502
+ this.gridApi.setColumnDefs(colDefsMergedWithTemplateDefs);
503
+ // Restore the persisted filter model now that the columns exist. The datasource
504
+ // emits `filtersRestored` synchronously right after `schemaUpdated`, but this handler
505
+ // is async (it awaits column-state hydration before `setColumnDefs`), so the
506
+ // `filtersRestored` restore can run before the columns exist and be silently dropped.
507
+ // Restoring here guarantees the columns are present for `gridApi.setFilterModel`.
508
+ this.restoreCachedFilterConfig();
595
509
  }
596
- return;
597
- }
598
- // The multi filter itself is available but its set sub-filter's module is not — opening
599
- // the filter would throw AG error #256. The multi filter hosts custom child filters, so
600
- // only the nested set filter is swapped for the enum filter (same params, same model).
601
- if (!hasSetFilter && setSubFilter) {
602
- logger.debug(`SetFilterModule is not registered; the set sub-filter of column '${colDef.field}' falls back to the enum filter`);
603
- setSubFilter.filter = GridProFilterTypes.enumFilter;
604
510
  }
605
511
  });
606
512
  }
@@ -609,18 +515,27 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
609
515
  * @internal
610
516
  */
611
517
  handleDataCleared(event) {
518
+ var _a, _b;
612
519
  const { includeSchema } = event.detail;
613
520
  if (!this.gridApi)
614
521
  return;
522
+ // For server-side, these methods are handled via server-side transactions
523
+ // Only flush async transactions for client-side row model
524
+ if (!this.isServerSide) {
525
+ // Flush any pending async transactions
526
+ if (this.asyncAdd || this.asyncUpdate || this.asyncRemove) {
527
+ (_b = (_a = this.gridApi).flushAsyncTransactions) === null || _b === void 0 ? void 0 : _b.call(_a);
528
+ }
529
+ }
615
530
  if (includeSchema) {
616
- this.gridApi.setGridOption('columnDefs', []);
531
+ this.gridApi.setColumnDefs([]);
617
532
  }
618
- // rowData belongs to the client-side row model; the infinite and server-side caches are
619
- // cleared by their own refresh / transaction events.
620
- if (this.isClientSideRowModel) {
621
- this.gridApi.setGridOption('rowData', []);
533
+ // setRowData only works for client-side row model
534
+ // For server-side, data clearing is handled via server-side transactions
535
+ if (!this.isServerSide) {
536
+ this.gridApi.setRowData([]);
537
+ this.gridApi.refreshCells({ force: true });
622
538
  }
623
- this.gridApi.refreshCells({ force: true });
624
539
  }
625
540
  /**
626
541
  * Handles loading started from datasource
@@ -628,7 +543,7 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
628
543
  */
629
544
  handleLoadingStarted() {
630
545
  if (this.gridApi) {
631
- this.gridApi.setGridOption('loading', true);
546
+ this.gridApi.showLoadingOverlay();
632
547
  }
633
548
  }
634
549
  /**
@@ -637,7 +552,6 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
637
552
  */
638
553
  handleLoadingFinished() {
639
554
  if (this.gridApi) {
640
- this.gridApi.setGridOption('loading', false);
641
555
  this.gridApi.hideOverlay();
642
556
  }
643
557
  }
@@ -647,7 +561,6 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
647
561
  */
648
562
  handleNoDataAvailable() {
649
563
  if (this.gridApi) {
650
- this.gridApi.setGridOption('loading', false);
651
564
  this.gridApi.showNoRowsOverlay();
652
565
  }
653
566
  }
@@ -679,7 +592,8 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
679
592
  * Handles datasource errors
680
593
  * @internal
681
594
  */
682
- handleDatasourceError() {
595
+ handleDatasourceError(event) {
596
+ // Set visual indicator on grid
683
597
  this.setAttribute('ds-disconnected', 'ds-disconnected');
684
598
  }
685
599
  /**
@@ -706,7 +620,7 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
706
620
  handleSetServerSideDatasource(event) {
707
621
  const { datasource } = event.detail;
708
622
  if (this.gridApi) {
709
- this.gridApi.setGridOption('serverSideDatasource', datasource);
623
+ this.gridApi.setServerSideDatasource(datasource);
710
624
  }
711
625
  }
712
626
  /**
@@ -759,33 +673,6 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
759
673
  }
760
674
  }
761
675
  }
762
- /**
763
- * Handles setting infinite datasource
764
- * @internal
765
- */
766
- handleSetInfiniteDatasource(event) {
767
- const { datasource } = event.detail;
768
- if (this.gridApi) {
769
- this.gridApi.setGridOption('datasource', datasource);
770
- }
771
- }
772
- /**
773
- * Handles refreshing the infinite cache.
774
- * @remarks Mirrors {@link GridProBeta.handleRefreshServerSide}: `purge` drops the block cache
775
- * and re-reads, otherwise the loaded blocks are re-read in place.
776
- * @internal
777
- */
778
- handleRefreshInfiniteCache(event) {
779
- var _a;
780
- if (!this.gridApi)
781
- return;
782
- if ((_a = event.detail) === null || _a === void 0 ? void 0 : _a.purge) {
783
- this.gridApi.purgeInfiniteCache();
784
- }
785
- else {
786
- this.gridApi.refreshInfiniteCache();
787
- }
788
- }
789
676
  combineAllGridComponents(gridOptionsComponents) {
790
677
  const defaultFoundationAgComponents = {
791
678
  [GridProRendererTypes.action]: ActionRenderer,
@@ -800,8 +687,6 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
800
687
  [GridProRendererTypes.multiselectEditor]: MultiselectEditor,
801
688
  [GridProRendererTypes.dateEditor]: DateEditor,
802
689
  [GridProRendererTypes.stringEditor]: StringEditor,
803
- [GridProFilterTypes.enumFilter]: EnumColumnFilter,
804
- [GridProFilterTypes.enumFloatingFilter]: EnumColumnFloatingFilter,
805
690
  [GridProStatusBarTypes.labelValue]: LabelValueStatusBarComponent,
806
691
  [GridProStatusBarTypes.loadMore]: LoadMoreStatusBarComponent,
807
692
  [GridProStatusBarTypes.reload]: ReloadStatusBarComponent,
@@ -939,7 +824,7 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
939
824
  }, DEBOUNCED_RESIZE_TIME);
940
825
  }
941
826
  /**
942
- * If {@link @genesislcap/grid-pro#GridPro.gridAutosizingEnabled} is true, will remove the widths from the column states.
827
+ * If {@link @genesislcap/grid-pro#GridProLegacy.gridAutosizingEnabled} is true, will remove the widths from the column states.
943
828
  * @internal
944
829
  */
945
830
  removeConfigWidthsToAutosize(colState) {
@@ -948,7 +833,7 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
948
833
  saveColumnState() {
949
834
  return __awaiter(this, void 0, void 0, function* () {
950
835
  if (this.rehydrationAttempted && this.statePersistanceEnabled()) {
951
- let colState = this.gridApi.getColumnState();
836
+ let colState = this.columnApi.getColumnState();
952
837
  colState = sanitizeColumnState(colState);
953
838
  colState = this.gridAutosizingEnabled
954
839
  ? this.removeConfigWidthsToAutosize(colState)
@@ -956,7 +841,7 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
956
841
  const allHeadersHidden = colState.filter((c) => {
957
842
  if (c.hide)
958
843
  return false;
959
- const col = this.gridApi.getColumn(c.colId);
844
+ const col = this.columnApi.getColumn(c.colId);
960
845
  return Boolean(col.getColDef().headerName);
961
846
  }).length === 0;
962
847
  if (colState.length === 0 ||
@@ -978,11 +863,40 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
978
863
  return __awaiter(this, void 0, void 0, function* () {
979
864
  this.columnState = [];
980
865
  if (this.statePersistanceEnabled()) {
981
- this.columnState = (yield this.statePersistence.getColumnState(this.persistColumnStateKey));
866
+ this.columnState = yield this.statePersistence.getColumnState(this.persistColumnStateKey);
982
867
  }
983
868
  return this.columnState;
984
869
  });
985
870
  }
871
+ /**
872
+ * Deletes the saved column state for the current grid
873
+ * @param resetToDefault - Whether to reset columns to their default configuration. Defaults to true.
874
+ * @remarks This removes the persisted column state from storage, allowing the grid to use default column configuration
875
+ * @public
876
+ */
877
+ deleteColumnState() {
878
+ return __awaiter(this, arguments, void 0, function* (resetToDefault = true) {
879
+ var _a;
880
+ if (this.statePersistanceEnabled()) {
881
+ yield this.statePersistence.deleteColumnState(this.persistColumnStateKey);
882
+ this.columnState = [];
883
+ }
884
+ if (resetToDefault && this.columnApi) {
885
+ if (((_a = this.defaultColumnConfig) === null || _a === void 0 ? void 0 : _a.length) > 0) {
886
+ // Convert ColDef[] to ColumnState[] using utility function
887
+ const columnState = convertColDefsToColumnStates(this.defaultColumnConfig);
888
+ this.columnApi.applyColumnState({
889
+ state: columnState,
890
+ applyOrder: true,
891
+ });
892
+ }
893
+ else {
894
+ this.columnApi.resetColumnState();
895
+ }
896
+ this.handleColumnSizing();
897
+ }
898
+ });
899
+ }
986
900
  restoreColumnState() {
987
901
  return __awaiter(this, void 0, void 0, function* () {
988
902
  var _a;
@@ -990,7 +904,7 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
990
904
  const colState = yield this.getSavedColumnState();
991
905
  const sanitizedColState = sanitizeColumnState(colState);
992
906
  if (sanitizedColState && sanitizedColState.length > 0) {
993
- (_a = this.gridApi) === null || _a === void 0 ? void 0 : _a.applyColumnState({
907
+ (_a = this.columnApi) === null || _a === void 0 ? void 0 : _a.applyColumnState({
994
908
  state: sanitizedColState,
995
909
  applyOrder: true,
996
910
  });
@@ -1028,8 +942,7 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
1028
942
  */
1029
943
  get gridParams() {
1030
944
  return {
1031
- globalListener: this.boundGlobalEventListener,
1032
- modules: [gridProColumnDragBridgeModule, ColumnMoveModule, DragAndDropModule],
945
+ globalEventListener: this.boundGlobalEventListener,
1033
946
  };
1034
947
  }
1035
948
  /**
@@ -1040,14 +953,7 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
1040
953
  get gridProDatasource() {
1041
954
  return (this.querySelector('grid-pro-genesis-datasource') ||
1042
955
  this.querySelector('grid-pro-client-side-datasource') ||
1043
- this.querySelector('grid-pro-server-side-datasource') ||
1044
- this.querySelector('grid-pro-infinite-datasource'));
1045
- }
1046
- /**
1047
- * @public
1048
- */
1049
- get isInfiniteRowModel() {
1050
- return this.gridProDatasource instanceof GridProInfiniteDatasource;
956
+ this.querySelector('grid-pro-server-side-datasource'));
1051
957
  }
1052
958
  /**
1053
959
  * Reports the currently visible columns to the datasource. The datasource decides what to do with
@@ -1059,9 +965,9 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
1059
965
  const datasource = this.gridProDatasource;
1060
966
  if (!datasource)
1061
967
  return;
1062
- const visibleFields = resolveVisibleColumnFields((_b = (_a = this.gridApi) === null || _a === void 0 ? void 0 : _a.getAllDisplayedColumns) === null || _b === void 0 ? void 0 : _b.call(_a), (_d = (_c = this.gridApi) === null || _c === void 0 ? void 0 : _c.getColumnDefs) === null || _d === void 0 ? void 0 : _d.call(_c));
968
+ const visibleFields = resolveVisibleColumnFields((_b = (_a = this.columnApi) === null || _a === void 0 ? void 0 : _a.getAllDisplayedColumns) === null || _b === void 0 ? void 0 : _b.call(_a), (_d = (_c = this.gridApi) === null || _c === void 0 ? void 0 : _c.getColumnDefs) === null || _d === void 0 ? void 0 : _d.call(_c));
1063
969
  // Skip empty results so we never overwrite a known visible set with nothing (e.g. when the
1064
- // grid API/defs aren't populated yet during early lifecycle).
970
+ // column API/defs aren't populated yet during early lifecycle).
1065
971
  if (!visibleFields.length)
1066
972
  return;
1067
973
  datasource.setVisibleColumns(visibleFields);
@@ -1078,52 +984,45 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
1078
984
  return;
1079
985
  this.debouncedSaveColumnState();
1080
986
  this.debouncedColumnAutosize();
987
+ this.invalidateColumnWidthCache();
1081
988
  };
1082
989
  const notifyVisibilityChanged = () => {
1083
990
  if (this.disposed || !this.isConnected)
1084
991
  return;
1085
992
  this.debouncedNotifyDatasourceVisibleColumns();
1086
993
  };
1087
- // Collect attributes and map them to AG Grid properties
1088
994
  Array.from(this.attributes).forEach((attribute) => {
1089
995
  const attrName = this.agPropertiesMap[attribute.name];
1090
996
  if (!attrName)
1091
997
  return;
1092
998
  this.agAttributes[attrName] = attribute.value;
1093
999
  });
1094
- const { columnDefs, components, defaultColDef, getRowId, onGridReady, onFilterChanged, onFirstDataRendered } = options, rest = __rest(options, ["columnDefs", "components", "defaultColDef", "getRowId", "onGridReady", "onFilterChanged", "onFirstDataRendered"]);
1095
- const derivedOptions = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, this.gridOptionsConfig), { defaultColDef: Object.assign({ enableCellChangeFlash: this.enableCellFlashing, filter: true, resizable: true, sortable: true }, defaultColDef), components: this.combineAllGridComponents(components), headerHeight: this.headerHeight, rowHeight: this.rowHeight, animateRows: false, suppressDragLeaveHidesColumns: true }), this.eventsAndCallbacks), { onGridReady: (event) => __awaiter(this, void 0, void 0, function* () {
1096
- var _a, _b, _c;
1000
+ const _a = options, { columnDefs, components, defaultColDef, getRowId, onGridReady, onFilterChanged, onFirstDataRendered } = _a, rest = __rest(_a, ["columnDefs", "components", "defaultColDef", "getRowId", "onGridReady", "onFilterChanged", "onFirstDataRendered"]);
1001
+ const gridOptionsConfig = this.gridOptionsConfig;
1002
+ const derivedOptions = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, gridOptionsConfig), { defaultColDef: Object.assign({ enableCellChangeFlash: this.enableCellFlashing, filter: true, resizable: true, sortable: true }, defaultColDef), components: this.combineAllGridComponents(components), suppressDragLeaveHidesColumns: true }), this.eventsAndCallbacks), { onGridReady: (event) => __awaiter(this, void 0, void 0, function* () {
1003
+ var _a, _b;
1097
1004
  this.gridApi = event.api;
1005
+ this.columnApi = event.columnApi;
1098
1006
  if (this.gridEventsQueue.length) {
1099
1007
  this.gridEventsQueue.forEach((type) => {
1100
1008
  this.addGridEventListener(type);
1101
1009
  });
1102
1010
  }
1103
- // Awaited so the columns land before rowData/columnState below — otherwise they
1104
- // would race against an empty column model. Caught because ag-grid neither awaits
1105
- // nor handles this callback's promise: a rejection (mergeAllColumnDefsAndStates
1106
- // hydrates column state) would surface as an unhandled rejection AND skip the rest
1107
- // of init — rowData, the consumer's onGridReady, the grid-ready emit. A grid with
1108
- // no columns beats one that never finishes starting.
1011
+ // Await so columns land before rowData/columnState/ready below - otherwise they'd
1012
+ // race against an empty column model.
1109
1013
  if (this.pendingSchemaUpdate) {
1110
1014
  const pendingSchemaUpdate = this.pendingSchemaUpdate;
1111
1015
  this.pendingSchemaUpdate = undefined;
1112
- try {
1113
- yield this.processSchemaUpdate(pendingSchemaUpdate);
1114
- }
1115
- catch (error) {
1116
- logger.error('Grid Pro: failed to apply the pending schema update on grid ready:', error);
1117
- }
1016
+ yield this.processSchemaUpdate(pendingSchemaUpdate);
1118
1017
  }
1119
1018
  if (this.rowData) {
1120
- this.gridApi.setGridOption('rowData', this.rowData);
1019
+ this.gridApi.setRowData(this.rowData);
1121
1020
  }
1122
1021
  if (onGridReady) {
1123
1022
  onGridReady(event);
1124
1023
  }
1125
- if (((_a = this.gridProDatasource) === null || _a === void 0 ? void 0 : _a.keepColDefsOnClearRowData) && ((_b = this.columnState) === null || _b === void 0 ? void 0 : _b.length) > 0) {
1126
- this.gridApi.applyColumnState({
1024
+ if (this.columnState && ((_a = this.columnState) === null || _a === void 0 ? void 0 : _a.length) > 0) {
1025
+ this.columnApi.applyColumnState({
1127
1026
  state: this.columnState,
1128
1027
  applyOrder: true,
1129
1028
  });
@@ -1140,16 +1039,20 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
1140
1039
  // Seed the datasource with the initially visible columns before the load is kicked off, so
1141
1040
  // a datasource that scopes its request to visible columns can narrow the first request.
1142
1041
  this.notifyDatasourceVisibleColumns();
1042
+ // Emit datasource ready event, signals that the datasource is ready to be used
1143
1043
  // TODO: prevent rendering datasource slot until grid is ready
1144
1044
  // so there is no need for this even and handling it in datasources
1145
- (_c = this.gridProDatasource) === null || _c === void 0 ? void 0 : _c.$emit(datasourceEventNames.ready);
1045
+ (_b = this.gridProDatasource) === null || _b === void 0 ? void 0 : _b.$emit(datasourceEventNames.ready);
1146
1046
  this.restoreColumnState();
1147
1047
  this.restoreCachedFilterConfig();
1148
1048
  this.debouncedColumnAutosize();
1149
1049
  }), onFirstDataRendered: (event) => {
1150
- // Safety net: by now the grid columns are populated, so (re)seed the datasource's visible
1050
+ // Handle column sizing
1051
+ this.handleColumnSizing();
1052
+ // Safety net: by now the column API is populated, so (re)seed the datasource's visible
1151
1053
  // columns in case the initial grid-ready seed ran before columns were available.
1152
1054
  this.notifyDatasourceVisibleColumns();
1055
+ // Call the original onFirstDataRendered if provided
1153
1056
  if (onFirstDataRendered) {
1154
1057
  onFirstDataRendered(event);
1155
1058
  }
@@ -1174,9 +1077,12 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
1174
1077
  onFilterChanged(filterChangedEvent);
1175
1078
  }
1176
1079
  }, onGridSizeChanged: gridOnChangeCallback, onSortChanged: gridOnChangeCallback }), rest);
1080
+ const hasGetRowId = 'getRowId' in (options !== null && options !== void 0 ? options : {});
1177
1081
  if (this.gridProDatasource) {
1178
1082
  derivedOptions.columnDefs = columnDefs;
1179
- derivedOptions.getRowId = getRowId;
1083
+ if (hasGetRowId) {
1084
+ derivedOptions.getRowId = getRowId;
1085
+ }
1180
1086
  this.setupStatusBar(derivedOptions);
1181
1087
  this.setLocalGridOptions(derivedOptions);
1182
1088
  }
@@ -1186,7 +1092,9 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
1186
1092
  return;
1187
1093
  }
1188
1094
  derivedOptions.columnDefs = value;
1189
- derivedOptions.getRowId = getRowId;
1095
+ if (hasGetRowId) {
1096
+ derivedOptions.getRowId = getRowId;
1097
+ }
1190
1098
  this.setupStatusBar(derivedOptions);
1191
1099
  this.setLocalGridOptions(derivedOptions);
1192
1100
  this.initGrid();
@@ -1194,12 +1102,7 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
1194
1102
  }
1195
1103
  }
1196
1104
  setLocalGridOptions(derivedOptions) {
1197
- // Merge options with reflected AG properties from attributes
1198
1105
  this.agGridOptions = Object.assign(Object.assign({}, this.agGridOptions), copyAttributesToGridOptions(derivedOptions, this.agAttributes));
1199
- this.agGridOptions.context = Object.assign(Object.assign({}, this.agGridOptions.context), { [GRID_PRO_COLUMN_DRAG_BRIDGE_CONTEXT_KEY]: this.columnDragBridge });
1200
- if (this.agGridOptions.allowDragFromColumnsToolPanel == null) {
1201
- this.agGridOptions.allowDragFromColumnsToolPanel = true;
1202
- }
1203
1106
  }
1204
1107
  /**
1205
1108
  * Clears the local grid options, this is used to clear the grid options when the grid is restarted.
@@ -1208,17 +1111,25 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
1208
1111
  clearLocalGridOptions() {
1209
1112
  this.agGridOptions = undefined;
1210
1113
  }
1114
+ /**
1115
+ * Clears all grid option state when the grid element is fully torn down.
1116
+ * @internal
1117
+ */
1211
1118
  resetGridOptionsState() {
1212
1119
  this.userProvidedGridOptions = undefined;
1213
1120
  this.agGridOptions = undefined;
1214
1121
  }
1215
1122
  initGrid() {
1216
1123
  DOM.queueUpdate(() => {
1217
- // `gridSlot` is a template ref, so it is undefined until the view binds, and this task runs
1218
- // on the shared update queue — an options change can queue it ahead of that binding. Reading
1219
- // `.firstChild` off it unguarded then throws from INSIDE a queued task, which the runner can
1220
- // only report against whichever test is running. Same guard as `grid-pro.ts`; both callers
1221
- // re-run on the next grid-options change, so skipping strands nothing.
1124
+ // `gridSlot` belongs in this readiness check, not just `disposed`/`isConnected`: it is a
1125
+ // template ref, so it is undefined until the view binds, and this task runs on the shared
1126
+ // update queue — an options change can queue it ahead of the binding that fills the ref.
1127
+ // Every other reader in this file already guards it; these two lines did not, so that
1128
+ // ordering threw `Cannot read properties of undefined (reading 'firstChild')` from INSIDE a
1129
+ // queued task. Such a throw is not attributable to whatever caused it: web-test-runner
1130
+ // reports it as an uncaught page exception against whichever test happens to be running,
1131
+ // which is how it surfaced — as an unrelated datasource test failing only under CI load.
1132
+ // Skipping is safe because both callers re-run on the next grid-options change.
1222
1133
  if (this.disposed || !this.isConnected || !this.gridSlot) {
1223
1134
  return;
1224
1135
  }
@@ -1230,10 +1141,21 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
1230
1141
  this.gridSlot.removeChild(this.gridSlot.firstChild);
1231
1142
  }
1232
1143
  }
1233
- this.agGrid = createGrid(this.gridSlot, this.agGridOptions, this.gridParams);
1144
+ this.agGrid = new Grid(this.gridSlot, this.agGridOptions, this.gridParams);
1234
1145
  this.initialised = true;
1235
1146
  });
1236
1147
  }
1148
+ /**
1149
+ * Will merge templated column definitions with `columnDefs` plus localStorage's column state or `deferredColumnStates`.
1150
+ * @deprecated use `applyTemplateDefinitions` instead.
1151
+ * @param columnDefs - The column definitions to apply to the grid.
1152
+ * @param deferredColumnDefsOrState - If true, will merge the column definitions with the saved column state or the `deferredColumnStates` property on the `grid-pro-genesis-datasource` element.
1153
+ * @returns The merged column definitions.
1154
+ */
1155
+ applyTemplateDefinitions(columnDefs, deferredColumnDefsOrState = false) {
1156
+ logger.deprecated('applyTemplateDefinitions', 'Use `mergeAllColumnDefsAndStates` instead.');
1157
+ return this.mergeAllColumnDefsAndStates(columnDefs, deferredColumnDefsOrState);
1158
+ }
1237
1159
  /**
1238
1160
  * Will merge templated column definitions with `columnDefs` plus localStorage's column state or `deferredColumnStates`.
1239
1161
  * @public
@@ -1261,7 +1183,7 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
1261
1183
  const templateColumnDefs = Array.from(this.querySelectorAll(this.columnComponentName))
1262
1184
  .map((templateColumn) => templateColumn.definition)
1263
1185
  .map((columnDef) => {
1264
- var _a, _b, _c, _d, _e, _f;
1186
+ var _a, _b;
1265
1187
  // enable cell flashing for each column if unspecified on column level but enabled on grid level
1266
1188
  if (this.enableCellFlashing && columnDef.enableCellChangeFlash === undefined) {
1267
1189
  columnDef.enableCellChangeFlash = true;
@@ -1272,25 +1194,21 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
1272
1194
  * respect that choice and don't inject metadata values. This allows consumers to
1273
1195
  * opt out of metadata values and let AG Grid extract values from row data instead.
1274
1196
  */
1275
- if (columnDef.filter === 'agSetColumnFilter' ||
1276
- columnDef.filter === GridProFilterTypes.enumFilter) {
1197
+ if (columnDef.filter === 'agSetColumnFilter') {
1277
1198
  const hasExplicitValues = columnDef.filterParams != null && 'values' in columnDef.filterParams;
1278
1199
  if (!hasExplicitValues) {
1279
- const metadataFilterParams = (_a = columnDefinitionsFromMetadata.find((colDef) => colDef.field === columnDef.field)) === null || _a === void 0 ? void 0 : _a.filterParams;
1280
- // Metadata enum values are flat ({ values }) on the server-side datasource path, but
1281
- // nested inside a multi-filter's set sub-filter on the client-side datasource path.
1282
- const metadataValues = (_b = metadataFilterParams === null || metadataFilterParams === void 0 ? void 0 : metadataFilterParams.values) !== null && _b !== void 0 ? _b : (_e = (_d = (_c = metadataFilterParams === null || metadataFilterParams === void 0 ? void 0 : metadataFilterParams.filters) === null || _c === void 0 ? void 0 : _c.find((subFilter) => subFilter.filter === 'agSetColumnFilter')) === null || _d === void 0 ? void 0 : _d.filterParams) === null || _e === void 0 ? void 0 : _e.values;
1200
+ const metadataValues = (_b = (_a = columnDefinitionsFromMetadata.find((colDef) => colDef.field === columnDef.field)) === null || _a === void 0 ? void 0 : _a.filterParams) === null || _b === void 0 ? void 0 : _b.values;
1283
1201
  if (metadataValues) {
1284
1202
  columnDef.filterParams = Object.assign(Object.assign({}, columnDef.filterParams), { values: metadataValues });
1285
1203
  }
1286
1204
  }
1287
- if (columnDef.filter === GridProFilterTypes.enumFilter) {
1288
- (_f = columnDef.floatingFilterComponent) !== null && _f !== void 0 ? _f : (columnDef.floatingFilterComponent = GridProFilterTypes.enumFloatingFilter);
1289
- }
1290
1205
  }
1291
1206
  if (columnDef.editable) {
1292
1207
  if (!columnDef.cellRenderer && !columnDef.cellRendererSelector) {
1293
1208
  columnDef.cellRendererSelector = (params) => {
1209
+ if (!(params === null || params === void 0 ? void 0 : params.data)) {
1210
+ return undefined;
1211
+ }
1294
1212
  if (params.data[EDITED_COLUMN_FIELD] === columnDef.field) {
1295
1213
  return {
1296
1214
  component: GridProRendererTypes.editable,
@@ -1301,6 +1219,9 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
1301
1219
  if (!columnDef.tooltipComponent && !columnDef.tooltipValueGetter) {
1302
1220
  columnDef.tooltipComponent = ErrorTooltip;
1303
1221
  columnDef.tooltipValueGetter = (params) => {
1222
+ if (!(params === null || params === void 0 ? void 0 : params.data)) {
1223
+ return undefined;
1224
+ }
1304
1225
  const error = params.data[ERROR_COLUMN_FIELD];
1305
1226
  if (error && error.column === columnDef.field) {
1306
1227
  return error.message;
@@ -1309,7 +1230,13 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
1309
1230
  }
1310
1231
  if (!columnDef.cellClassRules) {
1311
1232
  columnDef.cellClassRules = {
1312
- error: (params) => { var _a; return ((_a = params.data[ERROR_COLUMN_FIELD]) === null || _a === void 0 ? void 0 : _a.column) === params.colDef.field; },
1233
+ error: (params) => {
1234
+ var _a;
1235
+ if (!(params === null || params === void 0 ? void 0 : params.colDef) || !(params === null || params === void 0 ? void 0 : params.data)) {
1236
+ return false;
1237
+ }
1238
+ return ((_a = params.data[ERROR_COLUMN_FIELD]) === null || _a === void 0 ? void 0 : _a.column) === params.colDef.field;
1239
+ },
1313
1240
  };
1314
1241
  }
1315
1242
  }
@@ -1342,13 +1269,7 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
1342
1269
  // The custom rowCount panel is used for server-side infinite scroll (load more) scenarios;
1343
1270
  // client-side row models use AG Grid's own row count component instead.
1344
1271
  if (this.statusBarConfig && this.statusBarConfig.rows === true) {
1345
- // Check the derived gridOptions parameter, not this.gridOptions: setupStatusBar runs
1346
- // before setLocalGridOptions populates the field, so on first init the field is still
1347
- // undefined and a standalone grid's rowModelType would be missed.
1348
- const isServerSide = this.isServerSide ||
1349
- this.isInfiniteRowModel ||
1350
- (gridOptions === null || gridOptions === void 0 ? void 0 : gridOptions.rowModelType) === 'infinite' ||
1351
- (gridOptions === null || gridOptions === void 0 ? void 0 : gridOptions.rowModelType) === 'serverSide';
1272
+ const isServerSide = this.isServerSide || (gridOptions === null || gridOptions === void 0 ? void 0 : gridOptions.rowModelType) === 'serverSide';
1352
1273
  if (isServerSide) {
1353
1274
  if (!this.panelExists(GridProStatusBarTypes.rowCount, statusPanels)) {
1354
1275
  statusPanels.push({
@@ -1395,9 +1316,7 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
1395
1316
  }
1396
1317
  addDatasourcePanels(statusPanels) {
1397
1318
  if (this.gridProDatasource) {
1398
- // The infinite row model loads on scroll, so its loadMore() is a no-op: suppress the
1399
- // Load More panel for it the same way it is suppressed for the server-side row model.
1400
- const datasourceStatusPanels = this.gridProDatasource.getDatasourceStatusBarPanels(this.isServerSide || this.isInfiniteRowModel, this.statusBarConfig);
1319
+ const datasourceStatusPanels = this.gridProDatasource.getDatasourceStatusBarPanels(this.isServerSide, this.statusBarConfig);
1401
1320
  // Filter out duplicate datasource panels
1402
1321
  const newDatasourcePanels = datasourceStatusPanels.filter((panel) => !this.panelExists(panel.statusPanel, statusPanels));
1403
1322
  statusPanels.push(...newDatasourcePanels);
@@ -1425,6 +1344,94 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
1425
1344
  };
1426
1345
  }
1427
1346
  }
1347
+ /**
1348
+ * Handles column sizing based on sizeColumnsToContent and sizeColumnsToFit attributes
1349
+ * @private
1350
+ */
1351
+ handleColumnSizing() {
1352
+ if (!this.sizeColumnsToContent && !this.sizeColumnsToFit)
1353
+ return;
1354
+ if (this.sizeColumnsToContent && this.sizeColumnsToFit && this.columnApi && this.gridApi) {
1355
+ this.handleBothSizingModes();
1356
+ }
1357
+ else {
1358
+ this.handleIndividualSizingModes();
1359
+ }
1360
+ }
1361
+ /**
1362
+ * Handles when both sizeColumnsToContent and sizeColumnsToFit are enabled
1363
+ * @private
1364
+ */
1365
+ handleBothSizingModes() {
1366
+ const totalColumnWidth = this.calculateTotalColumnWidth();
1367
+ const gridWidth = this.getGridWidth();
1368
+ if (totalColumnWidth > gridWidth) {
1369
+ if (!this.columnApi)
1370
+ return;
1371
+ this.columnApi.autoSizeAllColumns();
1372
+ }
1373
+ else {
1374
+ if (!this.gridApi)
1375
+ return;
1376
+ this.gridApi.sizeColumnsToFit();
1377
+ }
1378
+ }
1379
+ /**
1380
+ * Handles individual sizing modes when only one is enabled
1381
+ * @private
1382
+ */
1383
+ handleIndividualSizingModes() {
1384
+ if (this.sizeColumnsToContent && this.columnApi) {
1385
+ this.columnApi.autoSizeAllColumns();
1386
+ }
1387
+ if (this.sizeColumnsToFit && this.gridApi) {
1388
+ this.gridApi.sizeColumnsToFit();
1389
+ }
1390
+ }
1391
+ /**
1392
+ * Calculates the total width of all columns
1393
+ * @private
1394
+ */
1395
+ calculateTotalColumnWidth() {
1396
+ if (!this.columnApi) {
1397
+ return 0;
1398
+ }
1399
+ const allColumns = this.columnApi.getAllGridColumns();
1400
+ const currentColumnCount = allColumns.length;
1401
+ // Check if cache is still valid (same number of columns)
1402
+ if (this.cachedTotalColumnWidth !== null && this.columnCount === currentColumnCount) {
1403
+ return this.cachedTotalColumnWidth;
1404
+ }
1405
+ // Calculate and cache the total width
1406
+ this.cachedTotalColumnWidth = allColumns.reduce((sum, col) => sum + (col.getActualWidth() || 0), 0);
1407
+ this.columnCount = currentColumnCount;
1408
+ return this.cachedTotalColumnWidth;
1409
+ }
1410
+ /**
1411
+ * Invalidates the cached column width calculation
1412
+ * @private
1413
+ * @remarks This method is called automatically when column changes occur (resize, move, pin, etc.)
1414
+ * to ensure the cached width calculation remains accurate.
1415
+ */
1416
+ invalidateColumnWidthCache() {
1417
+ this.cachedTotalColumnWidth = null;
1418
+ this.columnCount = 0;
1419
+ }
1420
+ /**
1421
+ * Gets the available grid width with fallbacks
1422
+ * @private
1423
+ */
1424
+ getGridWidth() {
1425
+ const gridElement = this;
1426
+ let gridWidth = (gridElement === null || gridElement === void 0 ? void 0 : gridElement.clientWidth) || 0;
1427
+ if (gridWidth === 0 && this.gridSlot) {
1428
+ gridWidth = this.gridSlot.clientWidth || 0;
1429
+ }
1430
+ if (gridWidth === 0) {
1431
+ gridWidth = this.clientWidth || 0;
1432
+ }
1433
+ return gridWidth;
1434
+ }
1428
1435
  get observedAttributes() {
1429
1436
  // allow properties to be supplied either lowercased or kebab-cased
1430
1437
  // this allows the user to either supply (for example) enableSorting or enabled-sorting
@@ -1435,7 +1442,6 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
1435
1442
  return lowerCasedPropertyNames.concat(kebabCasePropertyNames);
1436
1443
  }
1437
1444
  agAttributeChangedCallback(attName, oldValue, newValue) {
1438
- var _a;
1439
1445
  if (oldValue === newValue) {
1440
1446
  return;
1441
1447
  }
@@ -1443,9 +1449,13 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
1443
1449
  if (gridPropertyName) {
1444
1450
  // for properties set before gridOptions is called
1445
1451
  this.agAttributes[gridPropertyName] = newValue;
1446
- if (this.initialised) {
1447
- // for subsequent (post gridOptions) changes - use setGridOption API for v35
1448
- (_a = this.gridApi) === null || _a === void 0 ? void 0 : _a.setGridOption(gridPropertyName, newValue);
1452
+ // `initialised` flips true before `gridApi` is assigned (mid-reinit), so relying on it
1453
+ // alone here can crash processOnChange with an undefined api.
1454
+ if (this.initialised && this.gridApi) {
1455
+ // for subsequent (post gridOptions) changes
1456
+ const changeObject = {};
1457
+ changeObject[gridPropertyName] = { currentValue: newValue };
1458
+ ComponentUtil.processOnChange(changeObject, this.gridApi);
1449
1459
  }
1450
1460
  }
1451
1461
  }
@@ -1462,85 +1472,136 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
1462
1472
  this[callbackMethod](browserEvent);
1463
1473
  }
1464
1474
  }
1475
+ insertFontFace(newValue) {
1476
+ const fontFaceRule = agThemeFontFaceMap[newValue] || this.gridFontFace;
1477
+ this.destroyFontFace();
1478
+ const newDestroy = insertDocumentCSSRule(fontFaceRule, agThemeFontsId(newValue));
1479
+ if (newDestroy) {
1480
+ this.fontFaceDestroy = newDestroy;
1481
+ }
1482
+ }
1483
+ destroyFontFace() {
1484
+ if (this.fontFaceDestroy) {
1485
+ this.fontFaceDestroy();
1486
+ this.fontFaceDestroy = null;
1487
+ }
1488
+ }
1465
1489
  }
1466
1490
  __decorate([
1467
1491
  observable
1468
- ], GridProBeta.prototype, "gridApi", void 0);
1492
+ ], GridProLegacy.prototype, "columnApi", void 0);
1469
1493
  __decorate([
1470
1494
  observable
1471
- ], GridProBeta.prototype, "gridErrorItems", void 0);
1495
+ ], GridProLegacy.prototype, "gridApi", void 0);
1496
+ __decorate([
1497
+ observable
1498
+ ], GridProLegacy.prototype, "gridErrorItems", void 0);
1472
1499
  __decorate([
1473
1500
  StatePersistence
1474
- ], GridProBeta.prototype, "statePersistence", void 0);
1501
+ ], GridProLegacy.prototype, "statePersistence", void 0);
1475
1502
  __decorate([
1476
1503
  attr({ attribute: 'auto-cell-renderer-by-type', mode: 'boolean' })
1477
- ], GridProBeta.prototype, "autoCellRendererByType", void 0);
1504
+ ], GridProLegacy.prototype, "autoCellRendererByType", void 0);
1478
1505
  __decorate([
1479
1506
  attr({ attribute: 'only-template-col-defs', mode: 'boolean' })
1480
- ], GridProBeta.prototype, "onlyTemplateColDefs", void 0);
1507
+ ], GridProLegacy.prototype, "onlyTemplateColDefs", void 0);
1481
1508
  __decorate([
1482
1509
  attr({ mode: 'boolean', attribute: 'grid-autosizing' })
1483
- ], GridProBeta.prototype, "gridAutosizingEnabled", void 0);
1510
+ ], GridProLegacy.prototype, "gridAutosizingEnabled", void 0);
1511
+ __decorate([
1512
+ attr({ mode: 'boolean', attribute: 'size-columns-to-content' })
1513
+ ], GridProLegacy.prototype, "sizeColumnsToContent", void 0);
1514
+ __decorate([
1515
+ attr({ mode: 'boolean', attribute: 'size-columns-to-fit' })
1516
+ ], GridProLegacy.prototype, "sizeColumnsToFit", void 0);
1517
+ __decorate([
1518
+ attr({ attribute: 'add-index' })
1519
+ ], GridProLegacy.prototype, "addIndex", void 0);
1520
+ __decorate([
1521
+ attr({ mode: 'boolean', attribute: 'async-add' })
1522
+ ], GridProLegacy.prototype, "asyncAdd", void 0);
1523
+ __decorate([
1524
+ attr({ mode: 'boolean', attribute: 'async-remove' })
1525
+ ], GridProLegacy.prototype, "asyncRemove", void 0);
1526
+ __decorate([
1527
+ attr({ mode: 'boolean', attribute: 'async-update' })
1528
+ ], GridProLegacy.prototype, "asyncUpdate", void 0);
1484
1529
  __decorate([
1485
1530
  attr({ mode: 'boolean', attribute: 'enable-cell-flashing' })
1486
- ], GridProBeta.prototype, "enableCellFlashing", void 0);
1531
+ ], GridProLegacy.prototype, "enableCellFlashing", void 0);
1532
+ __decorate([
1533
+ attr({ mode: 'boolean', attribute: 'enabled-row-flashing' })
1534
+ ], GridProLegacy.prototype, "enabledRowFlashing", void 0);
1487
1535
  __decorate([
1488
1536
  attr({ mode: 'boolean', attribute: 'enable-row-flashing' })
1489
- ], GridProBeta.prototype, "enableRowFlashing", void 0);
1537
+ ], GridProLegacy.prototype, "enableRowFlashing", void 0);
1490
1538
  __decorate([
1491
1539
  attr({ attribute: 'persist-column-state-key' })
1492
- ], GridProBeta.prototype, "persistColumnStateKey", void 0);
1540
+ ], GridProLegacy.prototype, "persistColumnStateKey", void 0);
1493
1541
  __decorate([
1494
1542
  attr({ attribute: 'persist-filter-model-key' })
1495
- ], GridProBeta.prototype, "persistFilterModelKey", void 0);
1543
+ ], GridProLegacy.prototype, "persistFilterModelKey", void 0);
1544
+ __decorate([
1545
+ attr({ attribute: 'default-column-config' })
1546
+ ], GridProLegacy.prototype, "defaultColumnConfig", void 0);
1496
1547
  __decorate([
1497
1548
  attr({ attribute: 'header-case-type' })
1498
- ], GridProBeta.prototype, "headerCaseType", void 0);
1549
+ ], GridProLegacy.prototype, "headerCaseType", void 0);
1499
1550
  __decorate([
1500
1551
  observable
1501
- ], GridProBeta.prototype, "rowData", void 0);
1552
+ ], GridProLegacy.prototype, "rowData", void 0);
1553
+ __decorate([
1554
+ observable
1555
+ ], GridProLegacy.prototype, "gridFontFace", void 0);
1502
1556
  __decorate([
1503
1557
  attr
1504
- ], GridProBeta.prototype, "columnComponentName", void 0);
1558
+ ], GridProLegacy.prototype, "columnComponentName", void 0);
1505
1559
  __decorate([
1506
1560
  observable
1507
- ], GridProBeta.prototype, "eventsAndCallbacks", void 0);
1561
+ ], GridProLegacy.prototype, "eventsAndCallbacks", void 0);
1562
+ __decorate([
1563
+ attr
1564
+ ], GridProLegacy.prototype, "headerHeight", void 0);
1508
1565
  __decorate([
1509
1566
  attr
1510
- ], GridProBeta.prototype, "headerHeight", void 0);
1567
+ ], GridProLegacy.prototype, "rowHeight", void 0);
1511
1568
  __decorate([
1512
1569
  attr
1513
- ], GridProBeta.prototype, "rowHeight", void 0);
1570
+ ], GridProLegacy.prototype, "theme", void 0);
1514
1571
  __decorate([
1515
1572
  observable
1516
- ], GridProBeta.prototype, "classNames", void 0);
1573
+ ], GridProLegacy.prototype, "classNames", void 0);
1517
1574
  __decorate([
1518
1575
  observable
1519
- ], GridProBeta.prototype, "agGrid", void 0);
1576
+ ], GridProLegacy.prototype, "agGrid", void 0);
1520
1577
  __decorate([
1521
1578
  observable
1522
- ], GridProBeta.prototype, "gridSlot", void 0);
1579
+ ], GridProLegacy.prototype, "gridSlot", void 0);
1523
1580
  __decorate([
1524
1581
  observable
1525
- ], GridProBeta.prototype, "themeMode", void 0);
1582
+ ], GridProLegacy.prototype, "themeMode", void 0);
1526
1583
  __decorate([
1527
1584
  observable
1528
- ], GridProBeta.prototype, "gridComponents", void 0);
1585
+ ], GridProLegacy.prototype, "gridComponents", void 0);
1529
1586
  __decorate([
1530
1587
  observable
1531
- ], GridProBeta.prototype, "statusBarConfig", void 0);
1588
+ ], GridProLegacy.prototype, "statusBarConfig", void 0);
1532
1589
  __decorate([
1533
1590
  attr({ mode: 'boolean', attribute: 'with-status-bar' })
1534
- ], GridProBeta.prototype, "withStatusBar", void 0);
1535
- __decorate([
1536
- attr({ mode: 'boolean', attribute: 'enable-column-selection' })
1537
- ], GridProBeta.prototype, "enableColumnSelection", void 0);
1591
+ ], GridProLegacy.prototype, "withStatusBar", void 0);
1538
1592
  __decorate([
1539
1593
  observable
1540
- ], GridProBeta.prototype, "customErrorHandlerTemplate", void 0);
1594
+ ], GridProLegacy.prototype, "customErrorHandlerTemplate", void 0);
1541
1595
  __decorate([
1542
1596
  GridOptionsConfig
1543
- ], GridProBeta.prototype, "gridOptionsConfig", void 0);
1544
- __decorate([
1545
- observable
1546
- ], GridProBeta.prototype, "provider", void 0);
1597
+ ], GridProLegacy.prototype, "gridOptionsConfig", void 0);
1598
+ /**
1599
+ * A function that returns a Foundation Grid Pro Legacy registration for configuring the component with a DesignSystem.
1600
+ *
1601
+ * @public
1602
+ * @deprecated Legacy AG Grid v29 wrapper. Use `GridPro` (AG Grid v36) instead.
1603
+ * @remarks
1604
+ * HTML Element: \<foundation-grid-pro\>
1605
+ */
1606
+ export const foundationGridProLegacy = GridProLegacy.compose(Object.assign({ baseName: 'grid-pro', styles,
1607
+ template, shadowOptions: foundationGridProShadowOptions }, defaultGridProConfig));