@genesislcap/grid-pro 14.348.0 → 14.350.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.
Files changed (124) hide show
  1. package/dist/custom-elements.json +2293 -1443
  2. package/dist/dts/cell-renderers/boolean.renderer.d.ts.map +1 -1
  3. package/dist/dts/datasource/base.datasource.d.ts +20 -15
  4. package/dist/dts/datasource/base.datasource.d.ts.map +1 -1
  5. package/dist/dts/datasource/index.d.ts +1 -0
  6. package/dist/dts/datasource/index.d.ts.map +1 -1
  7. package/dist/dts/datasource/server-side.datasource.d.ts +9 -9
  8. package/dist/dts/datasource/server-side.datasource.d.ts.map +1 -1
  9. package/dist/dts/grid-pro-genesis-datasource/datasource-events.types.d.ts +101 -0
  10. package/dist/dts/grid-pro-genesis-datasource/datasource-events.types.d.ts.map +1 -0
  11. package/dist/dts/grid-pro-genesis-datasource/grid-pro-genesis-datasource.d.ts +24 -9
  12. package/dist/dts/grid-pro-genesis-datasource/grid-pro-genesis-datasource.d.ts.map +1 -1
  13. package/dist/dts/grid-pro-v34.d.ts +862 -0
  14. package/dist/dts/grid-pro-v34.d.ts.map +1 -0
  15. package/dist/dts/grid-pro.d.ts +88 -1
  16. package/dist/dts/grid-pro.d.ts.map +1 -1
  17. package/dist/dts/grid-pro.definitions.d.ts.map +1 -1
  18. package/dist/dts/index.d.ts +1 -0
  19. package/dist/dts/index.d.ts.map +1 -1
  20. package/dist/dts/status-bar-components/label-value.status-bar.d.ts +1 -1
  21. package/dist/dts/status-bar-components/label-value.status-bar.d.ts.map +1 -1
  22. package/dist/dts/status-bar-components/load-more.status-bar.d.ts +1 -1
  23. package/dist/dts/status-bar-components/load-more.status-bar.d.ts.map +1 -1
  24. package/dist/dts/status-bar-components/pagination.status-bar.d.ts +1 -1
  25. package/dist/dts/status-bar-components/pagination.status-bar.d.ts.map +1 -1
  26. package/dist/dts/status-bar-components/reload.status-bar.d.ts +1 -1
  27. package/dist/dts/status-bar-components/reload.status-bar.d.ts.map +1 -1
  28. package/dist/esm/cell-renderers/boolean.renderer.js +6 -7
  29. package/dist/esm/datasource/base.datasource.js +68 -95
  30. package/dist/esm/datasource/index.js +1 -0
  31. package/dist/esm/datasource/server-side.datasource.js +127 -149
  32. package/dist/esm/grid-pro-genesis-datasource/datasource-events.types.js +33 -0
  33. package/dist/esm/grid-pro-genesis-datasource/grid-pro-genesis-datasource.js +83 -78
  34. package/dist/esm/grid-pro-v34.js +1034 -0
  35. package/dist/esm/grid-pro.definitions.js +1 -1
  36. package/dist/esm/grid-pro.js +283 -8
  37. package/dist/esm/grid-pro.template.js +1 -1
  38. package/dist/esm/index.js +1 -0
  39. package/dist/esm/status-bar-components/pagination.status-bar.js +18 -11
  40. package/dist/grid-pro.api.json +3188 -698
  41. package/dist/grid-pro.d.ts +1171 -118
  42. package/docs/api/grid-pro.errorhandlerdialogstyles.md +11 -0
  43. package/docs/api/grid-pro.genesisgriddatasourceelement.md +0 -21
  44. package/docs/api/grid-pro.geterrorhandlerdialogtemplate.md +64 -0
  45. package/docs/api/grid-pro.gridpro.md +17 -0
  46. package/docs/api/grid-pro.gridpro.thememode.md +11 -0
  47. package/docs/api/{grid-pro.gridprobasedatasource.applyallagtransactions.md → grid-pro.gridprobasedatasource.applyalltransactions.md} +3 -3
  48. package/docs/api/grid-pro.gridprobasedatasource.applytransaction.md +3 -3
  49. package/docs/api/grid-pro.gridprobasedatasource.getdatasourcestatusbarpanels.md +15 -1
  50. package/docs/api/grid-pro.gridprobasedatasource.isdisconnected.md +1 -1
  51. package/docs/api/{grid-pro.gridprobasedatasource.agtransaction.md → grid-pro.gridprobasedatasource.keepcoldefsonclearrowdata.md} +3 -3
  52. package/docs/api/grid-pro.gridprobasedatasource.md +17 -55
  53. package/docs/api/grid-pro.gridprobasedatasource.pagination.md +1 -1
  54. package/docs/api/grid-pro.gridprobasedatasource.setdisconnected.md +1 -1
  55. package/docs/api/{grid-pro.gridprobasedatasource.applyfuncname.md → grid-pro.gridprobasedatasource.transactiondata.md} +3 -3
  56. package/docs/api/grid-pro.gridprogenesisdatasource.applytransaction.md +4 -4
  57. package/docs/api/grid-pro.gridprogenesisdatasource.init.md +4 -20
  58. package/docs/api/grid-pro.gridprogenesisdatasource.md +7 -34
  59. package/docs/api/{grid-pro.gridprogenesisdatasource.applyfuncname.md → grid-pro.gridprogenesisdatasource.transactiondata.md} +3 -3
  60. package/docs/api/grid-pro.gridproserversidedatasource.applytransaction.md +4 -4
  61. package/docs/api/grid-pro.gridproserversidedatasource.md +1 -74
  62. package/docs/api/grid-pro.gridproserversidedatasource.onpaginationchanged.md +2 -2
  63. package/docs/api/{grid-pro.gridproserversidedatasource.rowmodel.md → grid-pro.gridprov34._constructor_.md} +5 -3
  64. package/docs/api/grid-pro.gridprov34.addeventlistener.md +89 -0
  65. package/docs/api/{grid-pro.gridproserversidedatasource.applyfuncname.md → grid-pro.gridprov34.aggrid.md} +3 -3
  66. package/docs/api/{grid-pro.gridproserversidedatasource.applyasyncfuncname.md → grid-pro.gridprov34.aggridoptions.md} +3 -3
  67. package/docs/api/grid-pro.gridprov34.autocellrendererbytype.md +14 -0
  68. package/docs/api/grid-pro.gridprov34.cachefilterconfig.md +18 -0
  69. package/docs/api/grid-pro.gridprov34.classnames.md +14 -0
  70. package/docs/api/grid-pro.gridprov34.clearlocalgridoptions.md +17 -0
  71. package/docs/api/grid-pro.gridprov34.columncomponentname.md +14 -0
  72. package/docs/api/grid-pro.gridprov34.combineallgridcomponents.md +53 -0
  73. package/docs/api/grid-pro.gridprov34.connectedcallback.md +18 -0
  74. package/docs/api/grid-pro.gridprov34.customerrorhandlertemplate.md +21 -0
  75. package/docs/api/grid-pro.gridprov34.disconnectedcallback.md +18 -0
  76. package/docs/api/grid-pro.gridprov34.enablecellflashing.md +21 -0
  77. package/docs/api/grid-pro.gridprov34.enablerowflashing.md +16 -0
  78. package/docs/api/grid-pro.gridprov34.eventsandcallbacks.md +14 -0
  79. package/docs/api/grid-pro.gridprov34.getfiltermodel.md +20 -0
  80. package/docs/api/grid-pro.gridprov34.getsavedcolumnstate.md +21 -0
  81. package/docs/api/grid-pro.gridprov34.getselectedrows.md +19 -0
  82. package/docs/api/{grid-pro.gridproserversidedatasource.applytransactionasync.md → grid-pro.gridprov34.globaleventlistener.md} +7 -9
  83. package/docs/api/grid-pro.gridprov34.gridapi.md +14 -0
  84. package/docs/api/grid-pro.gridprov34.gridautosizingenabled.md +16 -0
  85. package/docs/api/grid-pro.gridprov34.gridcomponents.md +16 -0
  86. package/docs/api/grid-pro.gridprov34.griderroritems.md +14 -0
  87. package/docs/api/grid-pro.gridprov34.gridoptions.md +14 -0
  88. package/docs/api/grid-pro.gridprov34.gridoptionsconfig.md +28 -0
  89. package/docs/api/grid-pro.gridprov34.gridparams.md +12 -0
  90. package/docs/api/grid-pro.gridprov34.gridprodatasource.md +18 -0
  91. package/docs/api/grid-pro.gridprov34.gridslot.md +14 -0
  92. package/docs/api/grid-pro.gridprov34.hasselectedrows.md +19 -0
  93. package/docs/api/grid-pro.gridprov34.headercasetype.md +18 -0
  94. package/docs/api/grid-pro.gridprov34.headerheight.md +14 -0
  95. package/docs/api/grid-pro.gridprov34.hidedatasourceerror.md +18 -0
  96. package/docs/api/grid-pro.gridprov34.initialised.md +14 -0
  97. package/docs/api/grid-pro.gridprov34.isserverside.md +12 -0
  98. package/docs/api/grid-pro.gridprov34.md +1008 -0
  99. package/docs/api/grid-pro.gridprov34.mergeallcolumndefsandstates.md +230 -0
  100. package/docs/api/grid-pro.gridprov34.onlytemplatecoldefs.md +14 -0
  101. package/docs/api/grid-pro.gridprov34.pagination.md +21 -0
  102. package/docs/api/grid-pro.gridprov34.paginationpagesize.md +25 -0
  103. package/docs/api/grid-pro.gridprov34.persistcolumnstatekey.md +16 -0
  104. package/docs/api/grid-pro.gridprov34.persistfiltermodelkey.md +16 -0
  105. package/docs/api/grid-pro.gridprov34.provider.md +14 -0
  106. package/docs/api/grid-pro.gridprov34.restorecachedfilterconfig.md +18 -0
  107. package/docs/api/grid-pro.gridprov34.rowdata.md +18 -0
  108. package/docs/api/grid-pro.gridprov34.rowdatachanged.md +67 -0
  109. package/docs/api/grid-pro.gridprov34.rowheight.md +14 -0
  110. package/docs/api/grid-pro.gridprov34.setfiltermodel.md +55 -0
  111. package/docs/api/grid-pro.gridprov34.setuppaginationandstatusbar.md +53 -0
  112. package/docs/api/grid-pro.gridprov34.statepersistanceenabled.md +18 -0
  113. package/docs/api/grid-pro.gridprov34.statepersistence.md +14 -0
  114. package/docs/api/grid-pro.gridprov34.statusbarconfig.md +21 -0
  115. package/docs/api/grid-pro.gridprov34.thememode.md +14 -0
  116. package/docs/api/grid-pro.gridprov34.withstatusbar.md +21 -0
  117. package/docs/api/grid-pro.md +29 -1
  118. package/docs/api-report.md.api.md +377 -41
  119. package/package.json +16 -14
  120. package/docs/api/grid-pro.genesisgriddatasourceelement.aggrid.md +0 -11
  121. package/docs/api/grid-pro.gridprobasedatasource.applyasyncfuncname.md +0 -11
  122. package/docs/api/grid-pro.gridprobasedatasource.applytransactionasync.md +0 -66
  123. package/docs/api/grid-pro.gridprogenesisdatasource.applyasyncfuncname.md +0 -11
  124. package/docs/api/grid-pro.gridprogenesisdatasource.applytransactionasync.md +0 -66
@@ -0,0 +1,1034 @@
1
+ import { __awaiter, __decorate, __rest } from "tslib";
2
+ import { DatasourceDefaults } from '@genesislcap/foundation-comms';
3
+ import { LifecycleMixin, respondToVisibility } from '@genesislcap/foundation-utils';
4
+ import { baseLayerLuminance, StandardLuminance } from '@microsoft/fast-components';
5
+ import { attr, DOM, observable } from '@microsoft/fast-element';
6
+ import { FoundationElement } from '@microsoft/fast-foundation';
7
+ import { ModuleRegistry, createGrid, CsvExportModule, ClientSideRowModelModule, ClientSideRowModelApiModule, EventApiModule, TextFilterModule, CellStyleModule, ColumnApiModule, DateFilterModule, HighlightChangesModule, NumberFilterModule, PaginationModule, RowStyleModule, RowApiModule, TooltipModule, ColumnAutoSizeModule, RenderApiModule, } from 'ag-grid-community';
8
+ import * as changeCase from 'change-case';
9
+ import debounce from 'lodash.debounce';
10
+ import { GridProCell } from './cell';
11
+ import { DateEditor, MultiselectEditor, NumberEditor, SelectEditor, StringEditor, } from './cell-editors';
12
+ import { ActionRenderer, ActionsMenuRenderer, BooleanRenderer, EditableRenderer, StatusPillRenderer, SelectRenderer, } from './cell-renderers';
13
+ import { GridProColumn } from './column';
14
+ import { GridProClientSideDatasource, GridProServerSideDatasource } from './datasource';
15
+ import { baseDatasourceEventNames } from './datasource/base.types';
16
+ import { GridProGenesisDatasource, gridProGenesisDatasourceEventNames, } from './grid-pro-genesis-datasource';
17
+ import { datasourceEventNames, } from './grid-pro-genesis-datasource/datasource-events.types';
18
+ import { DEBOUNCED_RESIZE_TIME, gridProErrorNames, gridProEventNames, } from './grid-pro.definitions';
19
+ import { DEFAULT_STATUS_BAR_CONFIG, EDITED_COLUMN_FIELD, ERROR_COLUMN_FIELD, GRID_READY_EVENT, GridOptionsConfig, GridProRendererTypes, GridProStatusBarTypes, } from './grid-pro.types';
20
+ import { StatePersistence } from './state-persistence';
21
+ import { LabelValueStatusBarComponent, LoadMoreStatusBarComponent, PaginationStatusBarComponent, ReloadStatusBarComponent, } from './status-bar-components';
22
+ import { ErrorTooltip } from './tooltips';
23
+ import { logger, mergeAndDedupColDefWithColumnState } from './utils';
24
+ GridProGenesisDatasource;
25
+ GridProClientSideDatasource;
26
+ GridProServerSideDatasource;
27
+ GridProCell;
28
+ GridProColumn;
29
+ ModuleRegistry.registerModules([
30
+ CsvExportModule,
31
+ ClientSideRowModelModule,
32
+ PaginationModule,
33
+ RowStyleModule,
34
+ ClientSideRowModelApiModule,
35
+ EventApiModule,
36
+ TextFilterModule,
37
+ HighlightChangesModule,
38
+ ColumnApiModule,
39
+ NumberFilterModule,
40
+ CellStyleModule,
41
+ DateFilterModule,
42
+ RowApiModule,
43
+ TooltipModule,
44
+ ColumnAutoSizeModule,
45
+ RenderApiModule,
46
+ // ValidationModule,
47
+ ]);
48
+ const DEBOUNCE_TIME = 400;
49
+ // Events constants for v34 compatibility
50
+ const Events = {
51
+ EVENT_GRID_READY: 'gridReady',
52
+ };
53
+ /**
54
+ * The Grid Pro element (AG Grid v34 compatible).
55
+ * @remarks Grid Pro is a Web Component wrapper around the AG Grid Community library.
56
+ * @beta
57
+ * @tagname %%prefix%%-grid-pro
58
+ */
59
+ export class GridProV34 extends LifecycleMixin(FoundationElement) {
60
+ rowDataChanged(_, rowData) {
61
+ if (this.initialised) {
62
+ this.gridApi.setGridOption('rowData', rowData);
63
+ }
64
+ }
65
+ getfilterModel() {
66
+ return __awaiter(this, void 0, void 0, function* () {
67
+ if (!this.persistFilterModelKey) {
68
+ return this._filterConfig;
69
+ }
70
+ const filterModel = yield this.statePersistence.getFilterModel(this.persistFilterModelKey);
71
+ return filterModel;
72
+ });
73
+ }
74
+ setFilterModel(value) {
75
+ return __awaiter(this, void 0, void 0, function* () {
76
+ if (!this.persistFilterModelKey) {
77
+ this._filterConfig = value;
78
+ return;
79
+ }
80
+ yield this.statePersistence.saveFilterModel(this.persistFilterModelKey, value);
81
+ });
82
+ }
83
+ constructor() {
84
+ super();
85
+ this.gridErrorItems = [];
86
+ // Genesis-specific attrs
87
+ this.autoCellRendererByType = false;
88
+ this.onlyTemplateColDefs = false;
89
+ /**
90
+ * Boolean attribute to control whether the grid autosizes the columns upon interaction.
91
+ * This will disable the column widths from being manually set, and doesn't save the widths
92
+ * in local storage if you are using `persist-column-state-key`.
93
+ */
94
+ this.gridAutosizingEnabled = false;
95
+ /**
96
+ * If false, will disable cell flashing for all cells by default, unless otherwise defined in custom colDef
97
+ * @remarks Defaults to true
98
+ */
99
+ this.enableCellFlashing = false;
100
+ /**
101
+ * If true, will enable row flashing for all rows for `add` async transactions
102
+ */
103
+ this.enableRowFlashing = false;
104
+ this.columnComponentName = 'grid-pro-column';
105
+ this.themeMode = 'dark';
106
+ /**
107
+ * Enable pagination for the grid.
108
+ * @remarks
109
+ * When enabled, the grid will automatically configure pagination settings.
110
+ * Note that AG Grid's full pagination functionality requires the Enterprise module.
111
+ * While basic pagination will work in Community edition, advanced features like
112
+ * custom pagination components require Enterprise.
113
+ * @see https://www.ag-grid.com/javascript-data-grid/row-pagination/
114
+ * @see https://www.ag-grid.com/javascript-data-grid/server-side-model-pagination/
115
+ */
116
+ this.pagination = false;
117
+ /**
118
+ * Configuration for the grid status bar components.
119
+ * @remarks
120
+ * This requires AG Grid Enterprise module to be enabled.
121
+ * The status bar will only be displayed if the Enterprise module is available.
122
+ * @see https://www.ag-grid.com/javascript-data-grid/component-status-bar/
123
+ */
124
+ this.statusBarConfig = DEFAULT_STATUS_BAR_CONFIG;
125
+ /**
126
+ * Enables or disables the grid status bar.
127
+ * @remarks
128
+ * Default is false.
129
+ * When disabled, no status bar will be displayed regardless of statusBarConfig.
130
+ * This requires AG Grid Enterprise module to be available for the status bar to be displayed when enabled.
131
+ */
132
+ this.withStatusBar = false;
133
+ this.rehydrationAttempted = false;
134
+ this.rootEventsListeners = [];
135
+ this.gridEventsQueue = [];
136
+ this.registeredGridEvents = new Set();
137
+ this._filterConfig = undefined;
138
+ const hideDataSourceError = this.hideDatasourceError.bind(this);
139
+ this.rootEventsListeners.push({ key: gridProGenesisDatasourceEventNames.dataInit, action: hideDataSourceError }, { key: gridProEventNames.datasourceErrorClose, action: hideDataSourceError },
140
+ // Base datasource error handling for resource validation and initialization errors
141
+ {
142
+ key: baseDatasourceEventNames.error,
143
+ action: this.handleBaseDatasourceError.bind(this),
144
+ }, {
145
+ key: baseDatasourceEventNames.connected,
146
+ action: hideDataSourceError,
147
+ });
148
+ }
149
+ /**
150
+ * Adds an event listener to the grid element.
151
+ * @param eventType - The event type to listen for. Recommened to use the `Events` from AG Grid.
152
+ * @param listener - The event listener to call when the event is fired.
153
+ * @param options - An options object that specifies characteristics about the event listener.
154
+ * @privateRemarks
155
+ * This will change once we do the AG Upgrade and `eventType` will be correctly typed.
156
+ */
157
+ addEventListener(eventType, listener, options) {
158
+ super.addEventListener(eventType, listener, options);
159
+ if (this.gridApi) {
160
+ this.addGridEventListener(eventType);
161
+ }
162
+ else {
163
+ if (!this.gridEventsQueue.includes(eventType)) {
164
+ this.gridEventsQueue.push(eventType);
165
+ }
166
+ }
167
+ }
168
+ addGridEventListener(eventType) {
169
+ if (this.registeredGridEvents.has(eventType)) {
170
+ return;
171
+ }
172
+ this.registeredGridEvents.add(eventType);
173
+ this.gridApi.addEventListener(eventType, (e) => {
174
+ this.$emit(eventType, e);
175
+ });
176
+ }
177
+ handleError(type, event) {
178
+ this.gridErrorItems = [...this.gridErrorItems, { detail: event.detail, type }];
179
+ }
180
+ handleBaseDatasourceError(event) {
181
+ // Map base datasource errors to grid-pro error format
182
+ const gridProError = {
183
+ detail: { message: event.detail.message },
184
+ type: gridProErrorNames.datasource,
185
+ };
186
+ this.gridErrorItems = [
187
+ ...this.gridErrorItems,
188
+ { detail: gridProError.detail, type: gridProError.type },
189
+ ];
190
+ }
191
+ hideDatasourceError() {
192
+ this.gridErrorItems = this.gridErrorItems.filter((item) => item.type !== gridProErrorNames.datasource);
193
+ this.removeAttribute('ds-disconnected');
194
+ }
195
+ connectedCallback() {
196
+ super.connectedCallback();
197
+ baseLayerLuminance.subscribe({
198
+ handleChange: (record) => {
199
+ const luminance = baseLayerLuminance.getValueFor(record.target);
200
+ this.themeMode = luminance === StandardLuminance.DarkMode ? 'dark' : 'light';
201
+ },
202
+ }, this.provider);
203
+ if (this.gridAutosizingEnabled) {
204
+ respondToVisibility(this, (gridVisible) => {
205
+ if (gridVisible) {
206
+ this.debouncedColumnAutosize.bind(this)();
207
+ }
208
+ });
209
+ }
210
+ this.rehydrationAttempted = false;
211
+ if (!this.shouldRunConnect)
212
+ return;
213
+ this.rootEventsListeners.forEach(({ key, action }) => {
214
+ this.addEventListener(key, action);
215
+ });
216
+ // Add datasource event listeners
217
+ this.toggleDatasourceEventListeners(true);
218
+ this.paginationPageSize = this.isServerSide
219
+ ? this.gridProDatasource.maxRows
220
+ : DatasourceDefaults.DEFAULT_PAGINATION_PAGE_SIZE;
221
+ }
222
+ disconnectedCallback() {
223
+ super.disconnectedCallback();
224
+ this.rehydrationAttempted = false;
225
+ const shouldRunDisconnect = this.shouldRunDisconnect;
226
+ this.rootEventsListeners.forEach(({ key, action }) => {
227
+ this.removeEventListener(key, action);
228
+ });
229
+ // Remove datasource event listeners
230
+ this.toggleDatasourceEventListeners(false);
231
+ DOM.queueUpdate(() => {
232
+ var _a;
233
+ if (!shouldRunDisconnect)
234
+ return;
235
+ this.initialised = false;
236
+ (_a = this.gridApi) === null || _a === void 0 ? void 0 : _a.destroy();
237
+ // Clear registered events when grid is destroyed
238
+ this.registeredGridEvents.clear();
239
+ });
240
+ }
241
+ /**
242
+ * Helper method to add or remove datasource event listeners
243
+ * @internal
244
+ */
245
+ toggleDatasourceEventListeners(add) {
246
+ const eventHandlers = [
247
+ [datasourceEventNames.initialize, this.handleInitialize],
248
+ [datasourceEventNames.dataLoaded, this.handleDataLoaded],
249
+ [datasourceEventNames.dataChanged, this.handleDataChanged],
250
+ [datasourceEventNames.schemaUpdated, this.handleSchemaUpdated],
251
+ [datasourceEventNames.dataCleared, this.handleDataCleared],
252
+ [datasourceEventNames.loadingStarted, this.handleLoadingStarted],
253
+ [datasourceEventNames.loadingFinished, this.handleLoadingFinished],
254
+ [datasourceEventNames.noDataAvailable, this.handleNoDataAvailable],
255
+ [datasourceEventNames.filtersRestored, this.handleFiltersRestored],
256
+ [datasourceEventNames.moreDataAvailable, this.handleMoreDataAvailable],
257
+ [datasourceEventNames.error, this.handleDatasourceError],
258
+ // Server-side specific events
259
+ [datasourceEventNames.cacheFilterConfig, this.cacheFilterConfig],
260
+ [datasourceEventNames.refreshServerSide, this.handleRefreshServerSide],
261
+ [datasourceEventNames.setServerSideDatasource, this.handleSetServerSideDatasource],
262
+ [datasourceEventNames.addGridCssClass, this.handleAddGridCssClass],
263
+ [datasourceEventNames.removeGridCssClass, this.handleRemoveGridCssClass],
264
+ [datasourceEventNames.applyServerSideTransaction, this.handleApplyServerSideTransaction],
265
+ ];
266
+ const method = add ? 'addEventListener' : 'removeEventListener';
267
+ eventHandlers.forEach(([eventName, handler]) => {
268
+ this[method](eventName, handler.bind(this));
269
+ });
270
+ }
271
+ /**
272
+ * Handles datasource initialization
273
+ * @internal
274
+ */
275
+ handleInitialize(event) {
276
+ const { options, keepColDefsOnClearRowData } = event.detail;
277
+ if (keepColDefsOnClearRowData) {
278
+ this.columnState = this.gridApi.getColumnState();
279
+ }
280
+ // Set the grid options and initialize the grid
281
+ this.gridOptions = Object.assign(Object.assign(Object.assign({}, this.agGridOptions), options), (keepColDefsOnClearRowData ? { columnDefs: this.gridApi.getColumnDefs() } : {}));
282
+ this.initGrid();
283
+ }
284
+ /**
285
+ * Handles data loading from datasource
286
+ * @internal
287
+ */
288
+ handleDataLoaded(event) {
289
+ const { data } = event.detail;
290
+ if (this.gridApi) {
291
+ this.gridApi.setGridOption('rowData', data);
292
+ }
293
+ }
294
+ /**
295
+ * Handles data changes from datasource
296
+ * @internal
297
+ */
298
+ handleDataChanged(event) {
299
+ const { changes } = event.detail;
300
+ if (!this.gridApi)
301
+ return;
302
+ const result = this.gridApi.applyTransaction(changes);
303
+ this.flashAddedCells(result === null || result === void 0 ? void 0 : result.add);
304
+ }
305
+ flashAddedCells(rowNodes) {
306
+ if (this.enableRowFlashing && (rowNodes === null || rowNodes === void 0 ? void 0 : rowNodes.length)) {
307
+ this.gridApi.flashCells({ rowNodes });
308
+ }
309
+ }
310
+ /**
311
+ * Handles schema updates from datasource
312
+ * @internal
313
+ */
314
+ handleSchemaUpdated(event) {
315
+ return __awaiter(this, void 0, void 0, function* () {
316
+ const { schema } = event.detail;
317
+ if (this.gridApi) {
318
+ // Merge with template definitions
319
+ const mergedColumnDefs = yield this.mergeAllColumnDefsAndStates(schema, true);
320
+ this.gridApi.setGridOption('columnDefs', mergedColumnDefs);
321
+ }
322
+ });
323
+ }
324
+ /**
325
+ * Handles data clearing from datasource
326
+ * @internal
327
+ */
328
+ handleDataCleared(event) {
329
+ const { includeSchema } = event.detail;
330
+ if (!this.gridApi)
331
+ return;
332
+ if (includeSchema) {
333
+ this.gridApi.setGridOption('columnDefs', []);
334
+ }
335
+ this.gridApi.setGridOption('rowData', []);
336
+ this.gridApi.refreshCells({ force: true });
337
+ }
338
+ /**
339
+ * Handles loading started from datasource
340
+ * @internal
341
+ */
342
+ handleLoadingStarted() {
343
+ if (this.gridApi) {
344
+ this.gridApi.setGridOption('loading', true);
345
+ }
346
+ }
347
+ /**
348
+ * Handles loading finished from datasource
349
+ * @internal
350
+ */
351
+ handleLoadingFinished() {
352
+ if (this.gridApi) {
353
+ this.gridApi.hideOverlay();
354
+ }
355
+ }
356
+ /**
357
+ * Handles no data available from datasource
358
+ * @internal
359
+ */
360
+ handleNoDataAvailable() {
361
+ if (this.gridApi) {
362
+ this.gridApi.setGridOption('loading', false);
363
+ this.gridApi.showNoRowsOverlay();
364
+ }
365
+ }
366
+ /**
367
+ * Handles filter restoration from datasource
368
+ * @internal
369
+ */
370
+ handleFiltersRestored() {
371
+ this.restoreCachedFilterConfig();
372
+ }
373
+ /**
374
+ * Handles more data availability from datasource
375
+ * @internal
376
+ */
377
+ handleMoreDataAvailable(event) {
378
+ var _a, _b, _c, _d;
379
+ const { hasMoreData, sourceRef } = event.detail;
380
+ if (!this.gridApi)
381
+ return;
382
+ const statusBar = (_b = (_a = this.gridApi).getStatusPanel) === null || _b === void 0 ? void 0 : _b.call(_a, GridProStatusBarTypes.loadMore);
383
+ if (statusBar) {
384
+ (_d = (_c = statusBar).updateParams) === null || _d === void 0 ? void 0 : _d.call(_c, {
385
+ moreRows: hasMoreData,
386
+ sourceRef,
387
+ });
388
+ }
389
+ }
390
+ /**
391
+ * Handles datasource errors
392
+ * @internal
393
+ */
394
+ handleDatasourceError() {
395
+ this.setAttribute('ds-disconnected', 'ds-disconnected');
396
+ }
397
+ /**
398
+ * Handles refreshing server-side data
399
+ * @internal
400
+ */
401
+ handleRefreshServerSide(event) {
402
+ const { purge } = event.detail;
403
+ if (this.gridApi) {
404
+ this.gridApi.refreshServerSide({ purge });
405
+ }
406
+ }
407
+ /**
408
+ * Handles setting server-side datasource
409
+ * @internal
410
+ */
411
+ handleSetServerSideDatasource(event) {
412
+ const { datasource } = event.detail;
413
+ if (this.gridApi) {
414
+ this.gridApi.setGridOption('serverSideDatasource', datasource);
415
+ }
416
+ }
417
+ /**
418
+ * Handles adding CSS class to grid element
419
+ * @internal
420
+ */
421
+ handleAddGridCssClass(event) {
422
+ var _a;
423
+ const { className } = event.detail;
424
+ // Add CSS class to grid element
425
+ const gridElement = ((_a = this.gridSlot) === null || _a === void 0 ? void 0 : _a.parentElement) || this;
426
+ if (gridElement) {
427
+ gridElement.classList.add(className);
428
+ }
429
+ }
430
+ /**
431
+ * Handles removing CSS class from grid element
432
+ * @internal
433
+ */
434
+ handleRemoveGridCssClass(event) {
435
+ var _a;
436
+ const { className } = event.detail;
437
+ // Remove CSS class from grid element
438
+ const gridElement = ((_a = this.gridSlot) === null || _a === void 0 ? void 0 : _a.parentElement) || this;
439
+ if (gridElement) {
440
+ gridElement.classList.remove(className);
441
+ }
442
+ }
443
+ /**
444
+ * Handles applying server-side transactions
445
+ * @internal
446
+ */
447
+ handleApplyServerSideTransaction(event) {
448
+ const { transaction, async, callback } = event.detail;
449
+ if (!this.gridApi)
450
+ return;
451
+ const result = this.gridApi.applyServerSideTransaction(transaction);
452
+ }
453
+ combineAllGridComponents(gridOptionsComponents) {
454
+ const defaultFoundationAgComponents = {
455
+ [GridProRendererTypes.action]: ActionRenderer,
456
+ [GridProRendererTypes.actionsMenu]: ActionsMenuRenderer,
457
+ [GridProRendererTypes.boolean]: BooleanRenderer,
458
+ [GridProRendererTypes.editable]: EditableRenderer,
459
+ [GridProRendererTypes.statusPill]: StatusPillRenderer,
460
+ [GridProRendererTypes.select]: SelectRenderer,
461
+ [GridProRendererTypes.selectEditor]: SelectEditor,
462
+ [GridProRendererTypes.numberEditor]: NumberEditor,
463
+ [GridProRendererTypes.multiselectEditor]: MultiselectEditor,
464
+ [GridProRendererTypes.dateEditor]: DateEditor,
465
+ [GridProRendererTypes.stringEditor]: StringEditor,
466
+ [GridProStatusBarTypes.labelValue]: LabelValueStatusBarComponent,
467
+ [GridProStatusBarTypes.loadMore]: LoadMoreStatusBarComponent,
468
+ [GridProStatusBarTypes.pagination]: PaginationStatusBarComponent,
469
+ [GridProStatusBarTypes.reload]: ReloadStatusBarComponent,
470
+ };
471
+ return Object.assign(Object.assign(Object.assign({}, defaultFoundationAgComponents), gridOptionsComponents), this.gridComponents);
472
+ }
473
+ statePersistanceEnabled() {
474
+ if (!this.persistColumnStateKey || this.persistColumnStateKey.length === 0) {
475
+ return false;
476
+ }
477
+ return true;
478
+ }
479
+ /**
480
+ * Gets the currently selected rows from the grid
481
+ * @public
482
+ * @returns Array of selected row data
483
+ */
484
+ getSelectedRows() {
485
+ var _a, _b, _c, _d;
486
+ try {
487
+ if (!this.initialised || !this.gridApi) {
488
+ return [];
489
+ }
490
+ const rowSelectionMode = (_a = this.gridOptions) === null || _a === void 0 ? void 0 : _a.rowSelection;
491
+ // If row selection is enabled (single or multiple), use row selection only
492
+ if (rowSelectionMode === 'single' || rowSelectionMode === 'multiple') {
493
+ if (this.gridApi.getSelectedRows && this.gridApi.getSelectedRows().length > 0) {
494
+ return this.gridApi.getSelectedRows();
495
+ }
496
+ return [];
497
+ }
498
+ // If row selection is disabled (undefined/none), use cell range selection
499
+ if (((_b = this.gridApi) === null || _b === void 0 ? void 0 : _b.getCellRanges) && this.gridApi.getCellRanges().length > 0) {
500
+ return this.getCellRangeRowData();
501
+ }
502
+ // Fallback: if no cell ranges but range selection is disabled,
503
+ // check for focused cell (single cell selection)
504
+ if (!((_c = this.gridOptions) === null || _c === void 0 ? void 0 : _c.enableRangeSelection)) {
505
+ const focusedCell = (_d = this.gridApi) === null || _d === void 0 ? void 0 : _d.getFocusedCell();
506
+ if (focusedCell) {
507
+ const rowNode = this.gridApi.getDisplayedRowAtIndex(focusedCell.rowIndex);
508
+ if (rowNode === null || rowNode === void 0 ? void 0 : rowNode.data) {
509
+ return [rowNode.data];
510
+ }
511
+ }
512
+ }
513
+ return [];
514
+ }
515
+ catch (error) {
516
+ logger.error('Grid Pro: Error getting selected rows:', error);
517
+ return [];
518
+ }
519
+ }
520
+ /**
521
+ * Gets the row data from selected cell ranges
522
+ * @internal
523
+ * @returns Array containing the row data from selected cell ranges, or empty array if none
524
+ */
525
+ getCellRangeRowData() {
526
+ var _a;
527
+ if (!((_a = this.gridApi) === null || _a === void 0 ? void 0 : _a.getCellRanges)) {
528
+ return [];
529
+ }
530
+ const cellRanges = this.gridApi.getCellRanges();
531
+ if (cellRanges.length === 0) {
532
+ return [];
533
+ }
534
+ const rowData = [];
535
+ // Collect unique row data from all selected cell ranges
536
+ cellRanges.forEach((range) => {
537
+ const startIndex = range.startRow.rowIndex;
538
+ const endIndex = range.endRow.rowIndex;
539
+ // Iterate over indices directly for better performance
540
+ for (let rowIndex = startIndex; rowIndex <= endIndex; rowIndex += 1) {
541
+ const rowNode = this.gridApi.getDisplayedRowAtIndex(rowIndex);
542
+ if ((rowNode === null || rowNode === void 0 ? void 0 : rowNode.data) && !rowData.some((existing) => existing === rowNode.data)) {
543
+ rowData.push(rowNode.data);
544
+ }
545
+ }
546
+ });
547
+ return rowData;
548
+ }
549
+ /**
550
+ * Checks if any rows are currently selected
551
+ * @public
552
+ * @returns True if rows are selected, false otherwise
553
+ */
554
+ hasSelectedRows() {
555
+ const selectedRows = this.getSelectedRows();
556
+ return selectedRows.length > 0;
557
+ }
558
+ /**
559
+ * Because we try and resize the grid to fit using callbacks on events, this will cause
560
+ * a stack overflow of calls to resize, so we need to debounce it.
561
+ * @internal
562
+ */
563
+ debouncedColumnAutosize() {
564
+ if (!this.gridAutosizingEnabled)
565
+ return;
566
+ if (this.debounced) {
567
+ clearTimeout(this.debounced);
568
+ this.debounced = null;
569
+ }
570
+ this.debounced = setTimeout(() => {
571
+ var _a;
572
+ (_a = this.gridApi) === null || _a === void 0 ? void 0 : _a.sizeColumnsToFit();
573
+ }, DEBOUNCED_RESIZE_TIME);
574
+ }
575
+ /**
576
+ * If {@link @genesislcap/grid-pro#GridPro.gridAutosizingEnabled} is true, will remove the widths from the column states.
577
+ * @internal
578
+ */
579
+ removeConfigWidthsToAutosize(colState) {
580
+ return colState.map((col) => (Object.assign(Object.assign({}, col), { width: null })));
581
+ }
582
+ saveColumnState() {
583
+ return __awaiter(this, void 0, void 0, function* () {
584
+ if (this.rehydrationAttempted && this.statePersistanceEnabled()) {
585
+ let colState = this.gridApi.getColumnState();
586
+ colState = this.gridAutosizingEnabled
587
+ ? this.removeConfigWidthsToAutosize(colState)
588
+ : colState;
589
+ const allHeadersHidden = colState.filter((c) => {
590
+ if (c.hide)
591
+ return false;
592
+ const col = this.gridApi.getColumn(c.colId);
593
+ return Boolean(col.getColDef().headerName);
594
+ }).length === 0;
595
+ if (colState.length === 0 ||
596
+ JSON.stringify(colState) === JSON.stringify(this.columnState) ||
597
+ allHeadersHidden)
598
+ return;
599
+ yield this.statePersistence.saveColumnState(this.persistColumnStateKey, colState);
600
+ this.columnState = colState;
601
+ }
602
+ });
603
+ }
604
+ /**
605
+ * Gets the saved grid ColumnState[] from storage
606
+ * @remarks This is used to restore the grid state when the grid is rehydrated
607
+ * @privateRemarks Not using `columnApi.get|setColumnState()` for these flows as it doesn't work setting new columnDefs vs different ordering.
608
+ * @public
609
+ */
610
+ getSavedColumnState() {
611
+ return __awaiter(this, void 0, void 0, function* () {
612
+ this.columnState = [];
613
+ if (this.statePersistanceEnabled()) {
614
+ this.columnState = (yield this.statePersistence.getColumnState(this.persistColumnStateKey));
615
+ }
616
+ return this.columnState;
617
+ });
618
+ }
619
+ restoreColumnState() {
620
+ return __awaiter(this, void 0, void 0, function* () {
621
+ var _a;
622
+ this.rehydrationAttempted = true;
623
+ const colState = yield this.getSavedColumnState();
624
+ if (colState && colState.length > 0) {
625
+ (_a = this.gridApi) === null || _a === void 0 ? void 0 : _a.applyColumnState({
626
+ state: colState,
627
+ applyOrder: true,
628
+ });
629
+ }
630
+ });
631
+ }
632
+ cacheFilterConfig() {
633
+ var _a;
634
+ this.setFilterModel(((_a = this.gridApi) === null || _a === void 0 ? void 0 : _a.getFilterModel()) || undefined);
635
+ }
636
+ restoreCachedFilterConfig() {
637
+ return __awaiter(this, void 0, void 0, function* () {
638
+ var _a, _b;
639
+ const filterModel = yield this.getfilterModel();
640
+ if (typeof filterModel !== 'undefined') {
641
+ (_a = this.gridApi) === null || _a === void 0 ? void 0 : _a.setFilterModel(filterModel);
642
+ (_b = this.gridApi) === null || _b === void 0 ? void 0 : _b.onFilterChanged();
643
+ }
644
+ });
645
+ }
646
+ /**
647
+ * @public
648
+ */
649
+ get gridOptions() {
650
+ return this.agGridOptions;
651
+ }
652
+ /**
653
+ * @public
654
+ */
655
+ get isServerSide() {
656
+ return this.gridProDatasource instanceof GridProServerSideDatasource;
657
+ }
658
+ /**
659
+ * @public
660
+ */
661
+ get gridParams() {
662
+ return {
663
+ globalListener: this.globalEventListener.bind(this),
664
+ };
665
+ }
666
+ /**
667
+ * Get the datasource element.
668
+ * @remarks This will return the first datasource element found in the light DOM, wrapping all concrete datasource implementations.
669
+ * @public
670
+ */
671
+ get gridProDatasource() {
672
+ return (this.querySelector('grid-pro-genesis-datasource') ||
673
+ this.querySelector('grid-pro-client-side-datasource') ||
674
+ this.querySelector('grid-pro-server-side-datasource'));
675
+ }
676
+ set gridOptions(options) {
677
+ const debounceSaveColumnState = debounce(this.saveColumnState.bind(this), DEBOUNCE_TIME);
678
+ const debouceSaveFiltermodel = debounce(this.cacheFilterConfig.bind(this), DEBOUNCE_TIME);
679
+ const gridOnChangeCallback = () => {
680
+ debounceSaveColumnState();
681
+ this.debouncedColumnAutosize.bind(this)();
682
+ };
683
+ const { columnDefs, components, defaultColDef, getRowId, onGridReady, onFilterChanged } = options, rest = __rest(options, ["columnDefs", "components", "defaultColDef", "getRowId", "onGridReady", "onFilterChanged"]);
684
+ 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) => {
685
+ var _a, _b, _c;
686
+ this.gridApi = event.api;
687
+ if (this.gridEventsQueue.length) {
688
+ this.gridEventsQueue.forEach((type) => {
689
+ this.addGridEventListener(type);
690
+ });
691
+ }
692
+ if (this.rowData) {
693
+ this.gridApi.setGridOption('rowData', this.rowData);
694
+ }
695
+ if (onGridReady) {
696
+ onGridReady(event);
697
+ }
698
+ if (((_a = this.gridProDatasource) === null || _a === void 0 ? void 0 : _a.keepColDefsOnClearRowData) && ((_b = this.columnState) === null || _b === void 0 ? void 0 : _b.length) > 0) {
699
+ this.gridApi.applyColumnState({
700
+ state: this.columnState,
701
+ applyOrder: true,
702
+ });
703
+ }
704
+ this.$emit(Events.EVENT_GRID_READY, {
705
+ event,
706
+ gridId: this.id,
707
+ });
708
+ // TODO: Remove this event when we do the AG Upgrade
709
+ this.$emit(GRID_READY_EVENT, {
710
+ event,
711
+ gridId: this.id,
712
+ });
713
+ // TODO: prevent rendering datasource slot until grid is ready
714
+ // so there is no need for this even and handling it in datasources
715
+ (_c = this.gridProDatasource) === null || _c === void 0 ? void 0 : _c.$emit(datasourceEventNames.ready, { pagination: this.pagination });
716
+ this.restoreColumnState.bind(this)();
717
+ this.restoreCachedFilterConfig.bind(this)();
718
+ this.debouncedColumnAutosize.bind(this)();
719
+ }, onColumnPinned: gridOnChangeCallback, onColumnResized: gridOnChangeCallback, onColumnMoved: gridOnChangeCallback, onDisplayedColumnsChanged: gridOnChangeCallback, onFilterChanged: (filterChangedEvent) => {
720
+ debouceSaveFiltermodel();
721
+ if (onFilterChanged) {
722
+ onFilterChanged(filterChangedEvent);
723
+ }
724
+ }, onGridSizeChanged: gridOnChangeCallback, onSortChanged: gridOnChangeCallback }), rest);
725
+ if (this.gridProDatasource) {
726
+ derivedOptions.columnDefs = columnDefs;
727
+ derivedOptions.getRowId = getRowId;
728
+ this.setupPaginationAndStatusBar(derivedOptions);
729
+ this.setLocalGridOptions(derivedOptions);
730
+ }
731
+ else {
732
+ this.mergeAllColumnDefsAndStates(columnDefs).then((value) => {
733
+ derivedOptions.columnDefs = value;
734
+ derivedOptions.getRowId = getRowId;
735
+ this.setupPaginationAndStatusBar(derivedOptions);
736
+ this.setLocalGridOptions(derivedOptions);
737
+ this.initGrid();
738
+ });
739
+ }
740
+ }
741
+ setLocalGridOptions(derivedOptions) {
742
+ // Simplified approach for v34 - directly merge options
743
+ this.agGridOptions = Object.assign(Object.assign({}, this.agGridOptions), derivedOptions);
744
+ }
745
+ /**
746
+ * Clears the local grid options, this is used to clear the grid options when the grid is restarted.
747
+ * @public
748
+ */
749
+ clearLocalGridOptions() {
750
+ this.agGridOptions = undefined;
751
+ }
752
+ initGrid() {
753
+ DOM.queueUpdate(() => {
754
+ if (this.initialised) {
755
+ // Needed due gridSlot children cleanup
756
+ if (this.gridSlot.firstChild) {
757
+ // prevent re-instantiating the grid using the same slot content
758
+ this.gridSlot.removeChild(this.gridSlot.firstChild);
759
+ }
760
+ }
761
+ this.agGrid = createGrid(this.gridSlot, this.agGridOptions, this.gridParams);
762
+ this.initialised = true;
763
+ });
764
+ }
765
+ /**
766
+ * Will merge templated column definitions with `columnDefs` plus localStorage's column state or `deferredColumnStates`.
767
+ * @public
768
+ * @remarks This will favor the column state from the browser's local storage over the `deferredColumnStates` property on the `grid-pro-genesis-datasource` element.
769
+ * @param columnDefs - The column definitions to apply to the grid.
770
+ * @param deferredColumnDefsOrState - If true, will merge the column definitions with the saved column state or the `deferredColumnStates` property
771
+ * on the `grid-pro-genesis-datasource` element. Defaults to false but `grid-pro-genesis-datasource` will set this to true.
772
+ * @returns The merged column definitions.
773
+ */
774
+ mergeAllColumnDefsAndStates(columnDefs_1) {
775
+ return __awaiter(this, arguments, void 0, function* (columnDefs, deferredColumnDefsOrState = false) {
776
+ var _a;
777
+ const columnDefinitionsFromMetadata = columnDefs || [];
778
+ columnDefinitionsFromMetadata.forEach((colDefFromMetadata) => {
779
+ if (this.headerCaseType && colDefFromMetadata.field && !colDefFromMetadata.headerName) {
780
+ const changeCaseByType = changeCase[this.headerCaseType];
781
+ if (changeCaseByType) {
782
+ colDefFromMetadata.headerName = changeCaseByType(colDefFromMetadata.field);
783
+ }
784
+ else {
785
+ logger.warn(`Invalid header-case-type attribute value: ${this.headerCaseType}. Please use one of the following: camelCase, capitalCase, dotCase, headerCase, noCase, paramCase, pascalCase, pathCase, sentenceCase, snakeCase.`);
786
+ }
787
+ }
788
+ });
789
+ const templateColumnDefs = Array.from(this.querySelectorAll(this.columnComponentName))
790
+ .map((templateColumn) => templateColumn.definition)
791
+ .map((columnDef) => {
792
+ // enable cell flashing for each column if unspecified on column level but enabled on grid level
793
+ if (this.enableCellFlashing && columnDef.enableCellChangeFlash === undefined) {
794
+ columnDef.enableCellChangeFlash = true;
795
+ }
796
+ if (columnDef.editable) {
797
+ if (!columnDef.cellRenderer && !columnDef.cellRendererSelector) {
798
+ columnDef.cellRendererSelector = (params) => {
799
+ if (params.data[EDITED_COLUMN_FIELD] === columnDef.field) {
800
+ return {
801
+ component: GridProRendererTypes.editable,
802
+ };
803
+ }
804
+ };
805
+ }
806
+ if (!columnDef.tooltipComponent && !columnDef.tooltipValueGetter) {
807
+ columnDef.tooltipComponent = ErrorTooltip;
808
+ columnDef.tooltipValueGetter = (params) => {
809
+ const error = params.data[ERROR_COLUMN_FIELD];
810
+ if (error && error.column === columnDef.field) {
811
+ return error.message;
812
+ }
813
+ };
814
+ }
815
+ if (!columnDef.cellClassRules) {
816
+ columnDef.cellClassRules = {
817
+ error: (params) => { var _a; return ((_a = params.data[ERROR_COLUMN_FIELD]) === null || _a === void 0 ? void 0 : _a.column) === params.colDef.field; },
818
+ };
819
+ }
820
+ }
821
+ const metadataColumnDef = columnDefinitionsFromMetadata.find((colDef) => columnDef.field === colDef.field);
822
+ return Object.assign(Object.assign({}, metadataColumnDef), columnDef);
823
+ });
824
+ const templateColumnKeys = templateColumnDefs.map((x) => x.field);
825
+ const colDefsToReturn = [
826
+ ...templateColumnDefs,
827
+ ...(this.onlyTemplateColDefs
828
+ ? []
829
+ : columnDefinitionsFromMetadata.filter((g) => !templateColumnKeys.includes(g.field))),
830
+ ];
831
+ if (this.gridProDatasource && deferredColumnDefsOrState) {
832
+ const savedColumnState = yield this.getSavedColumnState();
833
+ if ((savedColumnState === null || savedColumnState === void 0 ? void 0 : savedColumnState.length) > 0) {
834
+ return mergeAndDedupColDefWithColumnState(colDefsToReturn, savedColumnState);
835
+ }
836
+ else if (((_a = this.gridProDatasource.deferredColumnStates) === null || _a === void 0 ? void 0 : _a.length) > 0) {
837
+ return mergeAndDedupColDefWithColumnState(colDefsToReturn, this.gridProDatasource.deferredColumnStates);
838
+ }
839
+ }
840
+ return colDefsToReturn;
841
+ });
842
+ }
843
+ panelExists(statusPanelType, panels) {
844
+ return panels.some((panel) => panel.statusPanel === statusPanelType);
845
+ }
846
+ addRowCountPanel(statusPanels) {
847
+ // For server-side models, AG Grid's built-in row count components don't work properly
848
+ // because they expect access to the complete dataset. Instead, rely on our custom
849
+ // pagination component which properly handles server-side row counts.
850
+ if (this.isServerSide) {
851
+ return;
852
+ }
853
+ if (this.statusBarConfig && this.statusBarConfig.rows === true) {
854
+ const rowCountStatusPanel = 'agTotalAndFilteredRowCountComponent';
855
+ if (!this.panelExists(rowCountStatusPanel, statusPanels)) {
856
+ statusPanels.push({
857
+ statusPanel: rowCountStatusPanel,
858
+ align: 'left',
859
+ });
860
+ }
861
+ }
862
+ }
863
+ addMaxRowsPanel(statusPanels) {
864
+ if (this.statusBarConfig && this.statusBarConfig.maxRows === true) {
865
+ if (!this.panelExists(GridProStatusBarTypes.labelValue, statusPanels)) {
866
+ statusPanels.push({
867
+ statusPanel: GridProStatusBarTypes.labelValue,
868
+ statusPanelParams: {
869
+ label: 'Max Rows',
870
+ value: this.gridProDatasource.maxRows || DatasourceDefaults.MAX_ROWS_250,
871
+ hide: false,
872
+ },
873
+ align: 'left',
874
+ });
875
+ }
876
+ }
877
+ }
878
+ addAggregationPanel(statusPanels) {
879
+ if (this.statusBarConfig && this.statusBarConfig.aggregation === true) {
880
+ if (!this.panelExists('agAggregationComponent', statusPanels)) {
881
+ statusPanels.push({
882
+ statusPanel: 'agAggregationComponent',
883
+ align: 'right',
884
+ });
885
+ }
886
+ }
887
+ }
888
+ addDatasourcePanels(statusPanels) {
889
+ if (this.gridProDatasource) {
890
+ const datasourceStatusPanels = this.gridProDatasource.getDatasourceStatusBarPanels(this.isServerSide, this.statusBarConfig);
891
+ // Filter out duplicate datasource panels
892
+ const newDatasourcePanels = datasourceStatusPanels.filter((panel) => !this.panelExists(panel.statusPanel, statusPanels));
893
+ statusPanels.push(...newDatasourcePanels);
894
+ }
895
+ }
896
+ addPaginationPanel(statusPanels) {
897
+ if (this['_pagination']) {
898
+ if (!this.panelExists(GridProStatusBarTypes.pagination, statusPanels)) {
899
+ statusPanels.push({
900
+ statusPanel: GridProStatusBarTypes.pagination,
901
+ align: 'right',
902
+ });
903
+ }
904
+ }
905
+ }
906
+ setupPaginationAndStatusBar(gridOptions) {
907
+ // Keep the guard for production code, but allow override for testing
908
+ // if (this.initialised && !allowDuplicateCheck) return;
909
+ var _a, _b;
910
+ if (this['_pagination']) {
911
+ gridOptions.pagination = true;
912
+ gridOptions.suppressScrollOnNewData = true;
913
+ gridOptions.paginationPageSize = this.paginationPageSize;
914
+ }
915
+ // Set default status bar with components based on configuration
916
+ if (this.withStatusBar && this.statusBarConfig) {
917
+ // For duplicate checking (testing scenario), clear existing status panels to prevent duplicates
918
+ // unless they are user-defined panels that we want to preserve
919
+ const existingPanels = ((_a = gridOptions.statusBar) === null || _a === void 0 ? void 0 : _a.statusPanels) || [];
920
+ const statusPanels = [...existingPanels];
921
+ this.addRowCountPanel(statusPanels);
922
+ this.addMaxRowsPanel(statusPanels);
923
+ this.addAggregationPanel(statusPanels);
924
+ this.addDatasourcePanels(statusPanels);
925
+ if (this['_pagination']) {
926
+ gridOptions.suppressPaginationPanel = true;
927
+ this.addPaginationPanel(statusPanels);
928
+ }
929
+ const userDefinedStatusPanels = ((_b = gridOptions.statusBar) === null || _b === void 0 ? void 0 : _b.statusPanels) || [];
930
+ const newUserDefinedPanels = userDefinedStatusPanels.filter((panel) => !this.panelExists(panel.statusPanel, statusPanels));
931
+ statusPanels.push(...newUserDefinedPanels);
932
+ gridOptions.statusBar = {
933
+ statusPanels: statusPanels,
934
+ };
935
+ }
936
+ }
937
+ globalEventListener(eventType, event) {
938
+ const eventLowerCase = eventType.toLowerCase();
939
+ const browserEvent = new Event(eventLowerCase);
940
+ const browserEventNoType = browserEvent;
941
+ browserEventNoType.agGridDetails = event;
942
+ // for when defining events via myGrid.addEventListener('columnresized', function (event) {...
943
+ this.dispatchEvent(browserEvent);
944
+ // for when defining events via myGrid.oncolumnresized = function (event) {....
945
+ const callbackMethod = 'on' + eventLowerCase;
946
+ if (typeof this[callbackMethod] === 'function') {
947
+ this[callbackMethod](browserEvent);
948
+ }
949
+ }
950
+ }
951
+ __decorate([
952
+ observable
953
+ ], GridProV34.prototype, "gridApi", void 0);
954
+ __decorate([
955
+ observable
956
+ ], GridProV34.prototype, "gridErrorItems", void 0);
957
+ __decorate([
958
+ StatePersistence
959
+ ], GridProV34.prototype, "statePersistence", void 0);
960
+ __decorate([
961
+ attr({ attribute: 'auto-cell-renderer-by-type', mode: 'boolean' })
962
+ ], GridProV34.prototype, "autoCellRendererByType", void 0);
963
+ __decorate([
964
+ attr({ attribute: 'only-template-col-defs', mode: 'boolean' })
965
+ ], GridProV34.prototype, "onlyTemplateColDefs", void 0);
966
+ __decorate([
967
+ attr({ mode: 'boolean', attribute: 'grid-autosizing' })
968
+ ], GridProV34.prototype, "gridAutosizingEnabled", void 0);
969
+ __decorate([
970
+ attr({ mode: 'boolean', attribute: 'enable-cell-flashing' })
971
+ ], GridProV34.prototype, "enableCellFlashing", void 0);
972
+ __decorate([
973
+ attr({ mode: 'boolean', attribute: 'enable-row-flashing' })
974
+ ], GridProV34.prototype, "enableRowFlashing", void 0);
975
+ __decorate([
976
+ attr({ attribute: 'persist-column-state-key' })
977
+ ], GridProV34.prototype, "persistColumnStateKey", void 0);
978
+ __decorate([
979
+ attr({ attribute: 'persist-filter-model-key' })
980
+ ], GridProV34.prototype, "persistFilterModelKey", void 0);
981
+ __decorate([
982
+ attr({ attribute: 'header-case-type' })
983
+ ], GridProV34.prototype, "headerCaseType", void 0);
984
+ __decorate([
985
+ observable
986
+ ], GridProV34.prototype, "rowData", void 0);
987
+ __decorate([
988
+ attr
989
+ ], GridProV34.prototype, "columnComponentName", void 0);
990
+ __decorate([
991
+ observable
992
+ ], GridProV34.prototype, "eventsAndCallbacks", void 0);
993
+ __decorate([
994
+ attr
995
+ ], GridProV34.prototype, "headerHeight", void 0);
996
+ __decorate([
997
+ attr
998
+ ], GridProV34.prototype, "rowHeight", void 0);
999
+ __decorate([
1000
+ observable
1001
+ ], GridProV34.prototype, "classNames", void 0);
1002
+ __decorate([
1003
+ observable
1004
+ ], GridProV34.prototype, "agGrid", void 0);
1005
+ __decorate([
1006
+ observable
1007
+ ], GridProV34.prototype, "gridSlot", void 0);
1008
+ __decorate([
1009
+ observable
1010
+ ], GridProV34.prototype, "themeMode", void 0);
1011
+ __decorate([
1012
+ observable
1013
+ ], GridProV34.prototype, "gridComponents", void 0);
1014
+ __decorate([
1015
+ attr({ mode: 'boolean' })
1016
+ ], GridProV34.prototype, "pagination", void 0);
1017
+ __decorate([
1018
+ attr({ attribute: 'pagination-page-size' })
1019
+ ], GridProV34.prototype, "paginationPageSize", void 0);
1020
+ __decorate([
1021
+ observable
1022
+ ], GridProV34.prototype, "statusBarConfig", void 0);
1023
+ __decorate([
1024
+ attr({ mode: 'boolean', attribute: 'with-status-bar' })
1025
+ ], GridProV34.prototype, "withStatusBar", void 0);
1026
+ __decorate([
1027
+ observable
1028
+ ], GridProV34.prototype, "customErrorHandlerTemplate", void 0);
1029
+ __decorate([
1030
+ GridOptionsConfig
1031
+ ], GridProV34.prototype, "gridOptionsConfig", void 0);
1032
+ __decorate([
1033
+ observable
1034
+ ], GridProV34.prototype, "provider", void 0);