@wavemaker/app-ng-runtime 11.14.1-33.647787 → 11.14.1-34.647830

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 (103) hide show
  1. package/build-task/bundles/index.umd.js +1 -1
  2. package/build-task/esm2022/data/form/form-field/form-field.build.mjs +2 -2
  3. package/build-task/fesm2022/index.mjs +1 -1
  4. package/build-task/fesm2022/index.mjs.map +1 -1
  5. package/components/base/bundles/index.umd.js +71 -17
  6. package/components/base/esm2022/pipes/custom-pipes.mjs +10 -10
  7. package/components/base/esm2022/utils/widget-utils.mjs +3 -3
  8. package/components/base/esm2022/widgets/common/base/base.component.mjs +51 -6
  9. package/components/base/esm2022/widgets/common/lazy-load/lazy-load.directive.mjs +7 -3
  10. package/components/base/esm2022/widgets/framework/property-change-handler.mjs +7 -2
  11. package/components/base/fesm2022/index.mjs +72 -18
  12. package/components/base/fesm2022/index.mjs.map +1 -1
  13. package/components/base/pipes/custom-pipes.d.ts +5 -5
  14. package/components/basic/label/bundles/index.umd.js +9 -1
  15. package/components/basic/label/esm2022/label.directive.mjs +10 -2
  16. package/components/basic/label/fesm2022/index.mjs +9 -1
  17. package/components/basic/label/fesm2022/index.mjs.map +1 -1
  18. package/components/basic/search/bundles/index.umd.js +2 -2
  19. package/components/basic/search/esm2022/search.component.mjs +3 -3
  20. package/components/basic/search/fesm2022/index.mjs +2 -2
  21. package/components/basic/search/fesm2022/index.mjs.map +1 -1
  22. package/components/chart/bundles/index.umd.js +2 -2
  23. package/components/chart/esm2022/chart.utils.mjs +3 -3
  24. package/components/chart/fesm2022/index.mjs +2 -2
  25. package/components/chart/fesm2022/index.mjs.map +1 -1
  26. package/components/containers/wizard/bundles/index.umd.js +21 -2
  27. package/components/containers/wizard/esm2022/wizard-step/wizard-step.component.mjs +3 -1
  28. package/components/containers/wizard/esm2022/wizard.component.mjs +20 -3
  29. package/components/containers/wizard/fesm2022/index.mjs +21 -2
  30. package/components/containers/wizard/fesm2022/index.mjs.map +1 -1
  31. package/components/containers/wizard/wizard-step/wizard-step.component.d.ts +2 -0
  32. package/components/data/pagination/bundles/index.umd.js +6 -1
  33. package/components/data/pagination/esm2022/pagination.component.mjs +7 -2
  34. package/components/data/pagination/fesm2022/index.mjs +6 -1
  35. package/components/data/pagination/fesm2022/index.mjs.map +1 -1
  36. package/components/data/table/bundles/index.umd.js +546 -28
  37. package/components/data/table/esm2022/table-action/table-action.directive.mjs +12 -2
  38. package/components/data/table/esm2022/table-column/table-column.directive.mjs +108 -4
  39. package/components/data/table/esm2022/table-column-group/table-column-group.directive.mjs +9 -1
  40. package/components/data/table/esm2022/table-cud.directive.mjs +22 -5
  41. package/components/data/table/esm2022/table-filter.directive.mjs +43 -4
  42. package/components/data/table/esm2022/table-row/table-row.directive.mjs +8 -1
  43. package/components/data/table/esm2022/table-row-action/table-row-action.directive.mjs +8 -1
  44. package/components/data/table/esm2022/table.component.mjs +345 -19
  45. package/components/data/table/fesm2022/index.mjs +548 -30
  46. package/components/data/table/fesm2022/index.mjs.map +1 -1
  47. package/components/data/table/table-action/table-action.directive.d.ts +3 -2
  48. package/components/data/table/table-column/table-column.directive.d.ts +3 -2
  49. package/components/data/table/table-column-group/table-column-group.directive.d.ts +3 -2
  50. package/components/data/table/table-cud.directive.d.ts +3 -1
  51. package/components/data/table/table-filter.directive.d.ts +3 -1
  52. package/components/data/table/table-row/table-row.directive.d.ts +3 -2
  53. package/components/data/table/table-row-action/table-row-action.directive.d.ts +3 -2
  54. package/components/data/table/table.component.d.ts +16 -2
  55. package/components/input/checkboxset/bundles/index.umd.js +2 -2
  56. package/components/input/checkboxset/esm2022/checkboxset.component.mjs +3 -3
  57. package/components/input/checkboxset/fesm2022/index.mjs +2 -2
  58. package/components/input/checkboxset/fesm2022/index.mjs.map +1 -1
  59. package/components/input/radioset/bundles/index.umd.js +2 -2
  60. package/components/input/radioset/esm2022/radioset.component.mjs +3 -3
  61. package/components/input/radioset/fesm2022/index.mjs +2 -2
  62. package/components/input/radioset/fesm2022/index.mjs.map +1 -1
  63. package/components/navigation/breadcrumb/bundles/index.umd.js +6 -6
  64. package/components/navigation/breadcrumb/esm2022/breadcrumb.component.mjs +4 -3
  65. package/components/navigation/breadcrumb/fesm2022/index.mjs +3 -2
  66. package/components/navigation/breadcrumb/fesm2022/index.mjs.map +1 -1
  67. package/components/navigation/menu/bundles/index.umd.js +5 -0
  68. package/components/navigation/menu/esm2022/menu.component.mjs +6 -1
  69. package/components/navigation/menu/fesm2022/index.mjs +5 -0
  70. package/components/navigation/menu/fesm2022/index.mjs.map +1 -1
  71. package/components/navigation/popover/bundles/index.umd.js +6 -6
  72. package/components/navigation/popover/esm2022/popover.component.mjs +4 -4
  73. package/components/navigation/popover/fesm2022/index.mjs +3 -3
  74. package/components/navigation/popover/fesm2022/index.mjs.map +1 -1
  75. package/components/navigation/popover/popover.component.d.ts +6 -0
  76. package/components/page/default/bundles/index.umd.js +1 -0
  77. package/components/page/default/esm2022/page.directive.mjs +2 -1
  78. package/components/page/default/fesm2022/index.mjs +1 -0
  79. package/components/page/default/fesm2022/index.mjs.map +1 -1
  80. package/core/bundles/index.umd.js +120 -15
  81. package/core/esm2022/public_api.mjs +2 -2
  82. package/core/esm2022/utils/utils.mjs +6 -2
  83. package/core/esm2022/utils/watcher.mjs +118 -15
  84. package/core/fesm2022/index.mjs +124 -15
  85. package/core/fesm2022/index.mjs.map +1 -1
  86. package/core/public_api.d.ts +1 -1
  87. package/core/utils/utils.d.ts +1 -0
  88. package/npm-shrinkwrap.json +2 -2
  89. package/package-lock.json +2 -2
  90. package/package.json +1 -1
  91. package/runtime/base/bundles/index.umd.js +23 -14
  92. package/runtime/base/components/base-prefab.component.d.ts +6 -4
  93. package/runtime/base/esm2022/components/base-page.component.mjs +2 -1
  94. package/runtime/base/esm2022/components/base-partial.component.mjs +2 -2
  95. package/runtime/base/esm2022/components/base-prefab.component.mjs +20 -12
  96. package/runtime/base/esm2022/services/pipe-provider.service.mjs +4 -4
  97. package/runtime/base/fesm2022/index.mjs +23 -14
  98. package/runtime/base/fesm2022/index.mjs.map +1 -1
  99. package/runtime/dynamic/bundles/index.umd.js +4 -0
  100. package/runtime/dynamic/esm2022/app/app.config.mjs +6 -2
  101. package/runtime/dynamic/fesm2022/index.mjs +5 -1
  102. package/runtime/dynamic/fesm2022/index.mjs.map +1 -1
  103. package/scripts/datatable/datatable.js +359 -35
@@ -108,7 +108,7 @@
108
108
  const ROW_OPS_FIELD = 'rowOperations';
109
109
  const noop = () => { };
110
110
  const isInputBodyWrapper = target => {
111
- const classes = ['.dropdown-menu', '.uib-typeahead-match', '.modal-dialog', '.toast'];
111
+ const classes = ['.dropdown-menu', '.uib-typeahead-match', '.modal-dialog', '.toast', '.bs-datepicker-container'];
112
112
  let isInput = false;
113
113
  classes.forEach(cls => {
114
114
  if (target.closest(cls).length) {
@@ -129,6 +129,19 @@
129
129
  };
130
130
  class TableComponent extends i4.StylableComponent {
131
131
  static { this.initializeProps = registerProps$5(); }
132
+ /** wm.Variable + inline or quickedit (editmode is string from markup; normalize case). */
133
+ isModelVariableInlineOrQuickEdit() {
134
+ if (lodashEs.get(this.datasource, 'category') !== 'wm.Variable') {
135
+ return false;
136
+ }
137
+ const em = String(this.editmode || '').toLowerCase();
138
+ return em === 'quickedit' || em === 'inline';
139
+ }
140
+ /** True while an inline/quickedit row save is updating the grid (incl. delayed navigator emit). */
141
+ shouldSoftRefreshAfterModelVarRowSave() {
142
+ return this.isModelVariableInlineOrQuickEdit()
143
+ && (this._isInlineEditSave || this._modelVarEditSoftRefreshActiveUntil > Date.now());
144
+ }
132
145
  set gridData(newValue) {
133
146
  this.isDataLoading = false;
134
147
  // Fix for [WMS-24012]: hide no datafound msg when variableInflight is true and dataset is empty
@@ -186,10 +199,24 @@
186
199
  this.setDataGridOption('colDefs', i2.getClonedObject(this.fieldDefs));
187
200
  }
188
201
  // If data and colDefs are present, call on before data render event
202
+ // Note: Errors in beforedatarender should not prevent table rendering
189
203
  if (!this.isdynamictable && !lodashEs.isEmpty(newValue) && gridOptions.colDefs.length) {
190
- this.invokeEventCallback('beforedatarender', { $data: this._gridData, $columns: this.columns, data: this._gridData, columns: this.columns });
204
+ try {
205
+ this.invokeEventCallback('beforedatarender', { $data: this._gridData, $columns: this.columns, data: this._gridData, columns: this.columns });
206
+ }
207
+ catch (error) {
208
+ // Log error but continue with rendering - beforedatarender errors should not block table rendering
209
+ console.warn('Error in beforedatarender event callback, continuing with table rendering:', error);
210
+ }
211
+ }
212
+ if (this.shouldSoftRefreshAfterModelVarRowSave()) {
213
+ const clonedData = i2.getClonedObject(this._gridData);
214
+ this.gridOptions.data = clonedData;
215
+ this.callDataGridMethod('softRefreshData', clonedData);
216
+ }
217
+ else {
218
+ this.setDataGridOption('data', i2.getClonedObject(this._gridData));
191
219
  }
192
- this.setDataGridOption('data', i2.getClonedObject(this._gridData));
193
220
  }
194
221
  }
195
222
  get gridData() {
@@ -242,6 +269,8 @@
242
269
  this.formfields = {};
243
270
  this.enablesort = true;
244
271
  this.showviewlessbutton = false;
272
+ /** Covers async navigator/dataset updates after inline/quickedit save (wm.Variable). */
273
+ this._modelVarEditSoftRefreshActiveUntil = 0;
245
274
  this.primaryKey = [];
246
275
  this.selectedItems = [];
247
276
  this.selectedItemChange = new rxjs.Subject();
@@ -580,7 +609,25 @@
580
609
  this.prevData = i2.getClonedObject(row);
581
610
  },
582
611
  afterRowUpdate: (row, e, callBack, options) => {
583
- this.updateRecord(lodashEs.extend({}, options, { row, 'prevData': this.prevData, 'event': e, 'callBack': callBack }));
612
+ const isModelVarInlineOrQuick = this.isModelVariableInlineOrQuickEdit();
613
+ if (isModelVarInlineOrQuick) {
614
+ this._isInlineEditSave = true;
615
+ // Inline save triggers navigatePage / dataset emit asynchronously; a
616
+ // microtask timeout cleared the flag before gridData ran → full rerender.
617
+ this._modelVarEditSoftRefreshActiveUntil = Date.now() + 550;
618
+ }
619
+ i2.muteWatchers();
620
+ const v = lodashEs.get(this.datasource, 'category') === 'wm.Variable' && options && options.rowindex != null;
621
+ this.updateRecord(lodashEs.extend({}, options, { row, prevData: v ? options.rowindex : this.prevData, event: e, callBack }));
622
+ setTimeout(() => {
623
+ i2.unMuteWatchers();
624
+ if (isModelVarInlineOrQuick) {
625
+ setTimeout(() => {
626
+ this._isInlineEditSave = false;
627
+ this._modelVarEditSoftRefreshActiveUntil = 0;
628
+ }, 520);
629
+ }
630
+ }, 10);
584
631
  },
585
632
  onBeforeRowUpdate: (row, e, options) => {
586
633
  return this.invokeEventCallback('beforerowupdate', { $event: e, $data: row, row, options: options });
@@ -652,11 +699,67 @@
652
699
  this.customExprCompiledTl = {};
653
700
  this.customExprCompiledSummaryTl = {};
654
701
  },
702
+ updateCustomExpressionContexts: (preparedData) => {
703
+ const viewCount = this.customExprViewRef.length;
704
+ for (let i = 0; i < viewCount; i++) {
705
+ const viewRef = this.customExprViewRef.get(i);
706
+ if (!viewRef || !viewRef.context || !viewRef.context.row || viewRef.context.row.$index === undefined) {
707
+ continue;
708
+ }
709
+ const existingRow = viewRef.context.row;
710
+ const rowIndex = existingRow.$index - 1;
711
+ const dataRow = preparedData[rowIndex];
712
+ if (!dataRow) {
713
+ continue;
714
+ }
715
+ Object.keys(dataRow).forEach(key => {
716
+ if (key !== '$$index' && key !== '$$pk') {
717
+ existingRow[key] = dataRow[key];
718
+ }
719
+ });
720
+ existingRow.$isFirst = existingRow.$index === 1;
721
+ existingRow.$isLast = this.gridData.length === existingRow.$index;
722
+ viewRef.markForCheck();
723
+ }
724
+ },
655
725
  clearRowDetailExpression: () => {
656
726
  this.rowDetailViewRef.clear();
657
727
  this.rowDefMap = {};
658
728
  this.rowDefInstances = {};
659
729
  },
730
+ invalidateRowDetailCache: (preparedData) => {
731
+ this.rowDefMap = {};
732
+ this.rowDefInstances = {};
733
+ // Update existing row detail view contexts in-place so currently
734
+ // expanded partials pick up the new row data via change detection.
735
+ const viewCount = this.rowDetailViewRef.length;
736
+ for (let i = 0; i < viewCount; i++) {
737
+ const viewRef = this.rowDetailViewRef.get(i);
738
+ if (!viewRef || !viewRef.context || !viewRef.context.row) {
739
+ continue;
740
+ }
741
+ const existingRow = viewRef.context.row;
742
+ const rowIndex = existingRow.$index - 1;
743
+ const dataRow = preparedData[rowIndex];
744
+ if (!dataRow) {
745
+ continue;
746
+ }
747
+ Object.keys(dataRow).forEach(key => {
748
+ if (key !== '$$index' && key !== '$$pk') {
749
+ existingRow[key] = dataRow[key];
750
+ }
751
+ });
752
+ viewRef.markForCheck();
753
+ }
754
+ },
755
+ refreshSelectedItems: () => {
756
+ const selectedRows = this.callDataGridMethod('getSelectedRows');
757
+ if (selectedRows.length) {
758
+ this.items.length = 0;
759
+ selectedRows.forEach(row => this.items.push(row));
760
+ this.selectedItemChange.next(selectedRows);
761
+ }
762
+ },
660
763
  generateCustomExpressions: (rowData, index, summaryRow) => {
661
764
  const row = this.getClonedRowObject(rowData);
662
765
  const compileTemplate = (tmpl) => {
@@ -1118,7 +1221,9 @@
1118
1221
  this.applyProps.forEach(args => this.callDataGridMethod(...args));
1119
1222
  if (this.editmode === i4.EDIT_MODE.QUICK_EDIT) {
1120
1223
  this.documentClickBind = this._documentClickBind.bind(this);
1121
- document.addEventListener('click', this.documentClickBind);
1224
+ // Use capture phase so a click on another grid (which calls stopPropagation) still reaches this
1225
+ // listener and lets the current grid save/close its editing row.
1226
+ document.addEventListener('click', this.documentClickBind, true);
1122
1227
  }
1123
1228
  }
1124
1229
  getConfiguredState() {
@@ -1234,6 +1339,10 @@
1234
1339
  return this.actualPageSize || 5;
1235
1340
  }
1236
1341
  watchVariableDataSet(newVal) {
1342
+ // Guard against component destruction
1343
+ if (this.isDestroyed) {
1344
+ return;
1345
+ }
1237
1346
  let result;
1238
1347
  // Check for Variable filters if applied
1239
1348
  if (this.gridOptions.isNavTypeScrollOrOndemand()) {
@@ -1291,6 +1400,12 @@
1291
1400
  }
1292
1401
  /*Return if data is invalid.*/
1293
1402
  if (!this.isDataValid()) {
1403
+ // If data is invalid and variableInflight is still true, clear loading state
1404
+ // This prevents tables from getting stuck in loading when data is invalid
1405
+ if (this.variableInflight) {
1406
+ this.variableInflight = false;
1407
+ this.setGridData([]);
1408
+ }
1294
1409
  return;
1295
1410
  }
1296
1411
  // If value is empty or in studio mode, dont enable the navigation
@@ -1318,7 +1433,13 @@
1318
1433
  // @ts-ignore
1319
1434
  if (!lodashEs.isObject(newVal) || newVal === '' || (newVal && newVal.dataValue === '')) {
1320
1435
  if (!this.variableInflight) {
1321
- // If variable has finished loading and resultSet is empty, ender empty data
1436
+ // If variable has finished loading and resultSet is empty, render empty data
1437
+ this.setGridData([]);
1438
+ }
1439
+ else {
1440
+ // If variableInflight is still true but we have invalid/empty data, clear loading state
1441
+ // This handles cases where data never arrives or is invalid
1442
+ this.variableInflight = false;
1322
1443
  this.setGridData([]);
1323
1444
  }
1324
1445
  return;
@@ -1328,13 +1449,144 @@
1328
1449
  }
1329
1450
  }
1330
1451
  ngOnDestroy() {
1331
- document.removeEventListener('click', this.documentClickBind);
1452
+ this._modelVarEditSoftRefreshActiveUntil = 0;
1453
+ this._isInlineEditSave = false;
1454
+ // MEMORY LEAK FIX: Remove document click listener
1455
+ document.removeEventListener('click', this.documentClickBind, true);
1456
+ // MEMORY LEAK FIX: Unsubscribe from navigator watches
1332
1457
  if (this.navigatorResultWatch) {
1333
1458
  this.navigatorResultWatch.unsubscribe();
1459
+ this.navigatorResultWatch = null;
1334
1460
  }
1335
1461
  if (this.navigatorMaxResultWatch) {
1336
1462
  this.navigatorMaxResultWatch.unsubscribe();
1463
+ this.navigatorMaxResultWatch = null;
1464
+ }
1465
+ // MEMORY LEAK FIX: Clear all ViewContainerRef embedded views
1466
+ // These hold references to row data, custom expressions, and inline widgets
1467
+ if (this.customExprViewRef) {
1468
+ this.customExprViewRef.clear();
1469
+ }
1470
+ if (this.rowActionsViewRef) {
1471
+ this.rowActionsViewRef.clear();
1472
+ }
1473
+ if (this.filterViewRef) {
1474
+ this.filterViewRef.clear();
1475
+ }
1476
+ if (this.inlineEditViewRef) {
1477
+ this.inlineEditViewRef.clear();
1337
1478
  }
1479
+ if (this.inlineEditNewViewRef) {
1480
+ this.inlineEditNewViewRef.clear();
1481
+ }
1482
+ if (this.rowDetailViewRef) {
1483
+ this.rowDetailViewRef.clear();
1484
+ }
1485
+ if (this.rowExpansionActionViewRef) {
1486
+ this.rowExpansionActionViewRef.clear();
1487
+ }
1488
+ if (this.dynamicTableRef) {
1489
+ this.dynamicTableRef.clear();
1490
+ }
1491
+ // MEMORY LEAK FIX: Clear compiled template caches
1492
+ this.rowActionsCompiledTl = {};
1493
+ this.rowFilterCompliedTl = {};
1494
+ this.inlineCompliedTl = {};
1495
+ this.inlineNewCompliedTl = {};
1496
+ this.customExprCompiledTl = {};
1497
+ this.customExprCompiledSummaryTl = {};
1498
+ this.rowDefInstances = {};
1499
+ this.rowDefMap = {};
1500
+ this.rowExpansionActionTl = {};
1501
+ // MEMORY LEAK FIX: Clear dynamic context
1502
+ if (this._dynamicContext) {
1503
+ Object.keys(this._dynamicContext).forEach(key => {
1504
+ delete this._dynamicContext[key];
1505
+ });
1506
+ this._dynamicContext = null;
1507
+ }
1508
+ // MEMORY LEAK FIX: Clear data arrays
1509
+ this._gridData = [];
1510
+ this.items = [];
1511
+ this.selectedItems = [];
1512
+ this.fieldDefs = [];
1513
+ this.fullFieldDefs = [];
1514
+ this.__fullData = null;
1515
+ // MEMORY LEAK FIX: Destroy jQuery datatable widget before clearing gridOptions
1516
+ if (this.datagridElement && this.datagridElement.datatable) {
1517
+ try {
1518
+ this.datagridElement.datatable('destroy');
1519
+ }
1520
+ catch (e) {
1521
+ // Ignore errors during destroy
1522
+ }
1523
+ }
1524
+ // MEMORY LEAK FIX: Clear gridOptions to release all function closures and data
1525
+ // gridOptions holds many closures that capture 'this' and prevent GC
1526
+ if (this.gridOptions) {
1527
+ // Clear data array
1528
+ if (this.gridOptions.data) {
1529
+ this.gridOptions.data = [];
1530
+ }
1531
+ // Clear column definitions
1532
+ if (this.gridOptions.colDefs) {
1533
+ this.gridOptions.colDefs = [];
1534
+ }
1535
+ // Clear row actions
1536
+ if (this.gridOptions.rowActions) {
1537
+ this.gridOptions.rowActions = [];
1538
+ }
1539
+ // Clear header config
1540
+ if (this.gridOptions.headerConfig) {
1541
+ this.gridOptions.headerConfig = [];
1542
+ }
1543
+ // Nullify all function references to break closures
1544
+ Object.keys(this.gridOptions).forEach(key => {
1545
+ if (typeof this.gridOptions[key] === 'function') {
1546
+ this.gridOptions[key] = null;
1547
+ }
1548
+ });
1549
+ }
1550
+ // MEMORY LEAK FIX: Clear other data structures
1551
+ this.columns = {};
1552
+ this.formfields = {};
1553
+ this.rowFilter = {};
1554
+ this.actions = [];
1555
+ this._actions = { header: [], footer: [] };
1556
+ this.exportOptions = [];
1557
+ this.headerConfig = [];
1558
+ this.rowActions = [];
1559
+ // MEMORY LEAK FIX: Clear all @ContentChildren QueryLists holding template references
1560
+ // These QueryLists hold TemplateRef instances that create circular references to the parent LView
1561
+ if (this.rowActionTmpl) {
1562
+ this.rowActionTmpl.reset([]);
1563
+ }
1564
+ if (this.filterTmpl) {
1565
+ this.filterTmpl.reset([]);
1566
+ }
1567
+ if (this.inlineWidgetTmpl) {
1568
+ this.inlineWidgetTmpl.reset([]);
1569
+ }
1570
+ if (this.inlineWidgetNewTmpl) {
1571
+ this.inlineWidgetNewTmpl.reset([]);
1572
+ }
1573
+ if (this.customExprTmpl) {
1574
+ this.customExprTmpl.reset([]);
1575
+ }
1576
+ if (this.rowExpansionActionTmpl) {
1577
+ this.rowExpansionActionTmpl.reset([]);
1578
+ }
1579
+ // MEMORY LEAK FIX: Clear @ContentChild template reference
1580
+ this.rowExpansionTmpl = null;
1581
+ // MEMORY LEAK FIX: Complete and clear subjects
1582
+ if (this.selectedItemChange) {
1583
+ this.selectedItemChange.complete();
1584
+ this.selectedItemChange = null;
1585
+ }
1586
+ // MEMORY LEAK FIX: Clear ViewChild references
1587
+ this.dataNavigator = null;
1588
+ this._tableElement = null;
1589
+ // console.log("table component destroyed");
1338
1590
  super.ngOnDestroy();
1339
1591
  }
1340
1592
  addRowIndex(row) {
@@ -1371,6 +1623,7 @@
1371
1623
  row.$isLast = this.gridData.length === row.$index;
1372
1624
  delete row.$$index;
1373
1625
  delete row.$$pk;
1626
+ delete row.$$wmSourceListIndex;
1374
1627
  return row;
1375
1628
  }
1376
1629
  handleLoading(data) {
@@ -1405,6 +1658,9 @@
1405
1658
  if (!key.endsWith('_filter') && ((key.endsWith('_new') && newRow) || (!key.endsWith('_new') && !newRow))) {
1406
1659
  ctrls[key].setValue('');
1407
1660
  this.resetFormControl(ctrls[key]);
1661
+ // MEMORY LEAK FIX: Clear validators to release references
1662
+ ctrls[key].clearValidators();
1663
+ ctrls[key].clearAsyncValidators();
1408
1664
  }
1409
1665
  });
1410
1666
  }
@@ -1609,6 +1865,14 @@
1609
1865
  // Apply filter and sort, if data is refreshed through Refresh data method
1610
1866
  if (!this.isNavigationEnabled() && this._isClientSearch) {
1611
1867
  data = i2.getClonedObject(serviceData);
1868
+ if (lodashEs.isObject(data) && !lodashEs.isArray(data)) {
1869
+ data = [data];
1870
+ }
1871
+ if (lodashEs.get(this.datasource, 'category') === 'wm.Variable' && lodashEs.isArray(data)) {
1872
+ for (let i = 0; i < data.length; i++) {
1873
+ data[i].$$wmSourceListIndex = i;
1874
+ }
1875
+ }
1612
1876
  data = this.getSearchResult(data, this.filterInfo);
1613
1877
  data = this.getSortResult(data, this.sortInfo);
1614
1878
  this.serverData = data;
@@ -1724,7 +1988,14 @@
1724
1988
  defaultFieldDefs.forEach(col => {
1725
1989
  this.columns[col.field] = col;
1726
1990
  });
1727
- this.invokeEventCallback('beforedatarender', { $data: data, $columns: this.columns, data: data, columns: this.columns });
1991
+ // Note: Errors in beforedatarender should not prevent table rendering
1992
+ try {
1993
+ this.invokeEventCallback('beforedatarender', { $data: data, $columns: this.columns, data: data, columns: this.columns });
1994
+ }
1995
+ catch (error) {
1996
+ // Log error but continue with rendering - beforedatarender errors should not block table rendering
1997
+ console.warn('Error in beforedatarender event callback, continuing with table rendering:', error);
1998
+ }
1728
1999
  defaultFieldDefs = [];
1729
2000
  // Apply the changes made by the user
1730
2001
  lodashEs.forEach(this.columns, val => {
@@ -1763,19 +2034,23 @@
1763
2034
  return sortExp || '';
1764
2035
  }
1765
2036
  onPropertyChange(key, nv, ov) {
2037
+ // Guard against property changes after component destruction
2038
+ if (this.isDestroyed) {
2039
+ return;
2040
+ }
1766
2041
  let enableNewRow;
1767
2042
  switch (key) {
1768
2043
  case 'datasource':
1769
2044
  // Fix for [WMS-23653] when startUpdate is false (request on page load property is unchecked),
1770
2045
  // then set status msg as "No data found"
1771
- if (this.allowpagesizechange) {
2046
+ if (this.allowpagesizechange && this.datasource) {
1772
2047
  this.datasource.maxResults = this.pagesize || this.datasource.maxResults;
1773
2048
  }
1774
- if (nv.startUpdate === false) {
2049
+ if (nv && nv.startUpdate === false) {
1775
2050
  this.variableInflight = false;
1776
2051
  this.callDataGridMethod('setStatus', 'nodata', this.nodatamessage);
1777
2052
  }
1778
- if (lodashEs.get(this.datasource, 'category') !== 'wm.Variable') {
2053
+ if (this.datasource && lodashEs.get(this.datasource, 'category') !== 'wm.Variable') {
1779
2054
  this.headerselectall = false;
1780
2055
  this.setDataGridOption("headerselectall", false);
1781
2056
  }
@@ -1787,6 +2062,12 @@
1787
2062
  this.gridOptions.setIsNextPageData(false);
1788
2063
  }
1789
2064
  if (this.binddatasource && !this.datasource) {
2065
+ // If datasource is not set yet, clear loading state and show no data
2066
+ // This prevents tables from being stuck in loading state
2067
+ if (this.variableInflight) {
2068
+ this.variableInflight = false;
2069
+ this.callDataGridMethod('setStatus', 'nodata', this.nodatamessage);
2070
+ }
1790
2071
  return;
1791
2072
  }
1792
2073
  // if table is inside list then table dataset will be set as "item.XXX" and there is no datasource.
@@ -1890,9 +2171,11 @@
1890
2171
  this.allowpagesizechange = nv;
1891
2172
  break;
1892
2173
  case 'pagesizeoptions':
1893
- this.gridOptions.pagesizeoptions = nv;
1894
- this.pagesizeoptions = nv;
1895
- this.setDefaultPageSize(nv);
2174
+ this.prevPagesizeoptions = this.sanitizeCommaSeparatedIntegers(ov);
2175
+ this.gridOptions.pagesizeoptions = this.sanitizeCommaSeparatedIntegers(nv);
2176
+ this.pagesizeoptions = this.sanitizeCommaSeparatedIntegers(nv);
2177
+ if (this.allowpagesizechange)
2178
+ this.setDefaultPageSize(nv);
1896
2179
  break;
1897
2180
  case 'multiselecttitle':
1898
2181
  this.setDataGridOption('multiselecttitle', nv);
@@ -1916,6 +2199,10 @@
1916
2199
  case 'show':
1917
2200
  if (nv) {
1918
2201
  this.invokeEventCallback('show');
2202
+ // recompute layout now that the table is visible again
2203
+ if (this.datagridElement) {
2204
+ this.redraw(false);
2205
+ }
1919
2206
  }
1920
2207
  else {
1921
2208
  this.invokeEventCallback('hide');
@@ -1936,12 +2223,41 @@
1936
2223
  this.pagesize = nv;
1937
2224
  }
1938
2225
  this.updatedPageSize = nv;
2226
+ if (this.isPageSizeOptionsChanged()) {
2227
+ this.dataNavigator.defaultPageSizeOptions = this.pagesizeoptions?.split(',').map(Number).sort((a, b) => a - b) || [];
2228
+ this.dataNavigator.pageSizeOptions = [...this.dataNavigator.defaultPageSizeOptions];
2229
+ }
1939
2230
  }
1940
2231
  this.dataNavigator.options = {
1941
2232
  maxResults: nv
1942
2233
  };
1943
2234
  this.dataNavigator.widget.maxResults = nv;
1944
2235
  this.dataNavigator.maxResults = nv;
2236
+ if (this.datasource) {
2237
+ this.datasource.maxResults = this.pagesize || this.datasource.maxResults;
2238
+ }
2239
+ }
2240
+ isPageSizeOptionsChanged() {
2241
+ return !lodashEs.isEqual(this.prevPagesizeoptions, this.pagesizeoptions);
2242
+ }
2243
+ selectPageSize(pagesize) {
2244
+ if (!this.allowpagesizechange && !pagesize)
2245
+ return;
2246
+ if (pagesize < this.dataNavigator.pageSizeOptions[0] || pagesize > this.dataNavigator.pageSizeOptions[this.dataNavigator.pageSizeOptions.length - 1]
2247
+ || !this.dataNavigator.pageSizeOptions.includes(Number(pagesize))) {
2248
+ pagesize = this.dataNavigator.pageSizeOptions[0];
2249
+ }
2250
+ this.dataNavigator.onPageSizeChange(undefined, pagesize);
2251
+ }
2252
+ sanitizeCommaSeparatedIntegers(input) {
2253
+ if (!input)
2254
+ return "";
2255
+ const uniqueNumbers = Array.from(new Set(input
2256
+ .split(",")
2257
+ .map(v => v.trim())
2258
+ .filter(v => /^-?\d+$/.test(v))
2259
+ .map(v => Math.abs(parseInt(v, 10)))));
2260
+ return uniqueNumbers.join(",");
1945
2261
  }
1946
2262
  onDataSourceChange() {
1947
2263
  this.fieldDefs.forEach(col => {
@@ -2061,6 +2377,11 @@
2061
2377
  if (lodashEs.isObject(data) && !lodashEs.isArray(data)) {
2062
2378
  data = [data];
2063
2379
  }
2380
+ if (lodashEs.get(this.datasource, 'category') === 'wm.Variable' && lodashEs.isArray(data)) {
2381
+ for (let i = 0; i < data.length; i++) {
2382
+ data[i].$$wmSourceListIndex = i;
2383
+ }
2384
+ }
2064
2385
  data = this.getSearchResult(data, this.filterInfo);
2065
2386
  data = this.getSortResult(data, this.sortInfo);
2066
2387
  return data;
@@ -2121,11 +2442,16 @@
2121
2442
  }
2122
2443
  _documentClickBind(event) {
2123
2444
  const $target = event.target;
2124
- // If click triggered from same grid or a dialog, do not save the row
2445
+ // If the click is within this table, a dialog, or a date picker, do not save the row.
2125
2446
  if (this.$element[0].contains($target) || event.target.doctype || isInputBodyWrapper($($target))) {
2126
2447
  return;
2127
2448
  }
2128
- this.callDataGridMethod('saveRow');
2449
+ // If click is inside another datatable, that table's edit handler saves this row — skip to avoid a duplicate save. [WMS-31104]
2450
+ if ($($target).closest('.app-datagrid').length) {
2451
+ return;
2452
+ }
2453
+ // Click is outside all tables — save the editing row without returning focus to this table. [WMS-31104]
2454
+ this.callDataGridMethod('saveRow', undefined, true);
2129
2455
  }
2130
2456
  _redraw(forceRender) {
2131
2457
  if (forceRender) {
@@ -2133,7 +2459,7 @@
2133
2459
  }
2134
2460
  else {
2135
2461
  setTimeout(() => {
2136
- this.callDataGridMethod('setColGroupWidths');
2462
+ this.callDataGridMethod(forceRender === false ? 'refreshColumnWidths' : 'setColGroupWidths');
2137
2463
  this.callDataGridMethod('addOrRemoveScroll');
2138
2464
  });
2139
2465
  }
@@ -2463,11 +2789,11 @@
2463
2789
  this.table.toggleMessage(true, 'success', this.table.updatemessage);
2464
2790
  }
2465
2791
  if (this.table.datasource.execute(i2.DataSource.Operation.SUPPORTS_CRUD)) {
2466
- this.table.initiateSelectItem('current', response, undefined, false, options.callBack);
2792
+ this.table.initiateSelectItem('current', response, options.skipFocus, false, options.callBack);
2467
2793
  this.updateVariable(response, options.callBack);
2468
2794
  }
2469
2795
  else if (!this.table.datasource.execute(i2.DataSource.Operation.IS_API_AWARE)) {
2470
- this.table.initiateSelectItem('current', response, undefined, false, options.callBack);
2796
+ this.table.initiateSelectItem('current', response, options.skipFocus, this.table.datasource.category === 'wm.Variable', options.callBack);
2471
2797
  }
2472
2798
  i2.triggerFn(options.success, response);
2473
2799
  this.table.invokeEventCallback('rowupdate', { $event: options.event, $data: response, row: response });
@@ -2488,7 +2814,11 @@
2488
2814
  if (dataSource.execute(i2.DataSource.Operation.SUPPORTS_CRUD) || !dataSource.execute(i2.DataSource.Operation.IS_API_AWARE) || dataSource.category === 'wm.CrudVariable') {
2489
2815
  if (!dataSource.execute(i2.DataSource.Operation.IS_API_AWARE)) {
2490
2816
  const extraOptions = this.generatePath(this.table.binddataset);
2491
- dataSource.execute(i2.DataSource.Operation.SET_ITEM, { prevItem: options.prevData, item: options.row, path: extraOptions.path, parentIndex: extraOptions.index });
2817
+ const item = options.row;
2818
+ if (dataSource.category === 'wm.Variable' && item) {
2819
+ delete item['$$wmSourceListIndex'];
2820
+ }
2821
+ dataSource.execute(i2.DataSource.Operation.SET_ITEM, { prevItem: options.prevData, item, path: extraOptions.path, parentIndex: extraOptions.index });
2492
2822
  this.updateSuccessHandler(options.row, options);
2493
2823
  return;
2494
2824
  }
@@ -2571,7 +2901,14 @@
2571
2901
  if (dataSource.execute(i2.DataSource.Operation.SUPPORTS_CRUD) || !dataSource.execute(i2.DataSource.Operation.IS_API_AWARE) || this.table._isDependent || dataSource.category === 'wm.CrudVariable') {
2572
2902
  if (!dataSource.execute(i2.DataSource.Operation.IS_API_AWARE)) {
2573
2903
  const extraOptions = this.generatePath(this.table.binddataset);
2574
- dataSource.execute(i2.DataSource.Operation.REMOVE_ITEM, { item: options.row, path: extraOptions.path, parentIndex: extraOptions.index });
2904
+ let item = options.row;
2905
+ if (dataSource.category === 'wm.Variable' && options.rowindex != null) {
2906
+ item = options.rowindex;
2907
+ }
2908
+ else if (dataSource.category === 'wm.Variable' && item) {
2909
+ delete item['$$wmSourceListIndex'];
2910
+ }
2911
+ dataSource.execute(i2.DataSource.Operation.REMOVE_ITEM, { item, path: extraOptions.path, parentIndex: extraOptions.index });
2575
2912
  this.deleteSuccessHandler(options.row, undefined, options.evt, options.callBack);
2576
2913
  return;
2577
2914
  }
@@ -2717,6 +3054,12 @@
2717
3054
  this.table.callDataGridMethod('cancelEdit', $row);
2718
3055
  }
2719
3056
  }
3057
+ ngOnDestroy() {
3058
+ // MEMORY LEAK FIX: Clear all references
3059
+ this.table = null;
3060
+ this.dialogService = null;
3061
+ this.app = null;
3062
+ }
2720
3063
  static { this.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0__namespace, type: TableCUDDirective, deps: [{ token: TableComponent, self: true }, { token: i2__namespace.AbstractDialogService }, { token: i2__namespace.App }], target: i0__namespace.ɵɵFactoryTarget.Directive }); }
2721
3064
  static { this.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.13", type: TableCUDDirective, isStandalone: true, selector: "[wmTableCUD]", ngImport: i0__namespace }); }
2722
3065
  }
@@ -3028,7 +3371,19 @@
3028
3371
  }
3029
3372
  // Function that checks if a given string is a valid date and returns the timestamp if it is, or NaN if it's not.
3030
3373
  parseDateString(dateString) {
3374
+ if (typeof dateString !== 'string') {
3375
+ return NaN;
3376
+ }
3377
+ const trimmed = dateString.trim();
3378
+ if (!trimmed) {
3379
+ return NaN;
3380
+ }
3031
3381
  const timestamp = Date.parse(dateString);
3382
+ // handling case when string starts with string and end with number
3383
+ const monthRegex = /\b(?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|Jun(?:e)?|Jul(?:y)?|Aug(?:ust)?|Sep(?:t(?:ember)?)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\b/i;
3384
+ if (/^[A-Za-z]+/.test(trimmed) && /\d+$/.test(trimmed) && !monthRegex.test(trimmed)) {
3385
+ return NaN;
3386
+ }
3032
3387
  if (!isNaN(timestamp)) {
3033
3388
  return timestamp;
3034
3389
  }
@@ -3040,20 +3395,38 @@
3040
3395
  // Returns data sorted using sortObj
3041
3396
  getSortResult(data, sortObj) {
3042
3397
  if (sortObj && sortObj.direction) {
3043
- const fieldValue = lodashEs.get(lodashEs.find(data, sortObj.field), sortObj.field);
3398
+ const sampleItem = lodashEs.find(data, (item) => {
3399
+ const v = lodashEs.get(item, sortObj.field);
3400
+ return typeof v === 'string' && !!v.trim();
3401
+ });
3402
+ const fieldValue = sampleItem ? lodashEs.get(sampleItem, sortObj.field) : undefined;
3044
3403
  const isValidDateString = typeof fieldValue === 'string' ? this.parseDateString(fieldValue) : NaN;
3045
3404
  if (!isNaN(isValidDateString)) { // if the field is a date string
3046
- data = lodashEs.orderBy(data, [(item) => this.parseDateString(item[sortObj.field])], [sortObj.direction]);
3405
+ data = lodashEs.orderBy(data, [
3406
+ (item) => {
3407
+ const v = lodashEs.get(item, sortObj.field);
3408
+ return v === null || v === undefined || v === '' ? 1 : 0;
3409
+ },
3410
+ (item) => {
3411
+ const ts = this.parseDateString(lodashEs.get(item, sortObj.field));
3412
+ return isNaN(ts) ? 1 : 0;
3413
+ },
3414
+ (item) => this.parseDateString(lodashEs.get(item, sortObj.field))
3415
+ ], ['asc', 'asc', sortObj.direction]);
3047
3416
  }
3048
3417
  else if (sortObj.sortBy ? this.table.columns[sortObj.sortBy]?.caseinsensitive : this.table.columns[sortObj.field]?.caseinsensitive) {
3049
3418
  //Fix for [WMS-27505]: Added case-insensitive sorting so that uppercase and lowercase letters are treated the same when sorting.
3050
3419
  data = lodashEs.orderBy(data, [
3420
+ (item) => {
3421
+ const val = lodashEs.get(item, sortObj.field);
3422
+ return val === null || val === undefined || val === '' ? 1 : 0;
3423
+ },
3051
3424
  (item) => {
3052
3425
  const val = lodashEs.get(item, sortObj.field);
3053
3426
  return typeof val === 'string' ? val.toLowerCase() : val;
3054
3427
  },
3055
3428
  (item) => lodashEs.get(item, sortObj.field) // fallback to original value
3056
- ], [sortObj.direction, sortObj.direction]);
3429
+ ], ['asc', sortObj.direction, sortObj.direction]);
3057
3430
  }
3058
3431
  else {
3059
3432
  data = lodashEs.orderBy(data, sortObj.field, sortObj.direction);
@@ -3075,6 +3448,11 @@
3075
3448
  if (lodashEs.isObject(data) && !lodashEs.isArray(data)) {
3076
3449
  data = [data];
3077
3450
  }
3451
+ if (lodashEs.get(this.table.datasource, 'category') === 'wm.Variable' && lodashEs.isArray(data)) {
3452
+ for (let i = 0; i < data.length; i++) {
3453
+ data[i].$$wmSourceListIndex = i;
3454
+ }
3455
+ }
3078
3456
  /*Both the functions return same 'data' if arguments are undefined*/
3079
3457
  data = this.getSearchResult(data, this.table.filterInfo);
3080
3458
  data = this.getSortResult(data, this.table.sortInfo);
@@ -3405,6 +3783,10 @@
3405
3783
  condition: logicalOp
3406
3784
  });
3407
3785
  }
3786
+ ngOnDestroy() {
3787
+ // MEMORY LEAK FIX: Clear table reference
3788
+ this.table = null;
3789
+ }
3408
3790
  static { this.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0__namespace, type: TableFilterSortDirective, deps: [{ token: TableComponent, self: true }], target: i0__namespace.ɵɵFactoryTarget.Directive }); }
3409
3791
  static { this.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.13", type: TableFilterSortDirective, isStandalone: true, selector: "[wmTableFilterSort]", ngImport: i0__namespace }); }
3410
3792
  }
@@ -3462,7 +3844,7 @@
3462
3844
  title: lodashEs.isUndefined(this.title) ? (this['display-name'] || '') : this.title,
3463
3845
  action: this.action,
3464
3846
  accessroles: this.accessroles,
3465
- shortcutkey: this.shortcutkey,
3847
+ shortcutkey: this.shortcutkey || undefined,
3466
3848
  disabled: this.disabled,
3467
3849
  tabindex: this.tabindex,
3468
3850
  icon: this.icon,
@@ -3487,10 +3869,20 @@
3487
3869
  if (key === 'display-name') {
3488
3870
  this.buttonDef.displayName = nv;
3489
3871
  }
3872
+ else if (key === 'shortcutkey') {
3873
+ this.buttonDef.shortcutkey = nv || undefined;
3874
+ }
3490
3875
  else {
3491
3876
  this.buttonDef[key] = nv;
3492
3877
  }
3493
3878
  }
3879
+ ngOnDestroy() {
3880
+ // MEMORY LEAK FIX: Clear table and buttonDef references
3881
+ this.table = null;
3882
+ this.buttonDef = null;
3883
+ // Call parent ngOnDestroy (BaseComponent has cleanup)
3884
+ super.ngOnDestroy();
3885
+ }
3494
3886
  static { this.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0__namespace, type: TableActionDirective, deps: [{ token: i0__namespace.Injector }, { token: TableComponent, optional: true }, { token: 'EXPLICIT_CONTEXT', optional: true }], target: i0__namespace.ɵɵFactoryTarget.Directive }); }
3495
3887
  static { this.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.13", type: TableActionDirective, isStandalone: true, selector: "[wmTableAction]", providers: [
3496
3888
  i4.provideAsWidgetRef(TableActionDirective)
@@ -3655,6 +4047,14 @@
3655
4047
  const fieldName = this.group && this.group.name;
3656
4048
  i4.setHeaderConfigForTable(this.table.headerConfig, this.config, fieldName, fieldName ? colIndex : headerIndex);
3657
4049
  }
4050
+ ngOnDestroy() {
4051
+ // MEMORY LEAK FIX: Clear table, group, and config references
4052
+ this.table = null;
4053
+ this.group = null;
4054
+ this.config = null;
4055
+ // Call parent ngOnDestroy (BaseComponent has cleanup)
4056
+ super.ngOnDestroy();
4057
+ }
3658
4058
  static { this.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0__namespace, type: TableColumnGroupDirective, deps: [{ token: i0__namespace.Injector }, { token: TableColumnGroupDirective, optional: true, skipSelf: true }, { token: TableComponent, optional: true }, { token: 'EXPLICIT_CONTEXT', optional: true }], target: i0__namespace.ɵɵFactoryTarget.Directive }); }
3659
4059
  static { this.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.13", type: TableColumnGroupDirective, isStandalone: true, selector: "[wmTableColumnGroup]", providers: [
3660
4060
  i4.provideAsWidgetRef(TableColumnGroupDirective)
@@ -3849,6 +4249,10 @@
3849
4249
  }
3850
4250
  // Remove validators for the inline widget and set form to untouched
3851
4251
  removeValidations() {
4252
+ // Guard against component destruction or table/ngform being null
4253
+ if (this.isDestroyed || !this.table || !this.table.ngform) {
4254
+ return;
4255
+ }
3852
4256
  this.table.ngform.markAsUntouched();
3853
4257
  const control = this.getFormControl();
3854
4258
  if (!control) {
@@ -3860,6 +4264,10 @@
3860
4264
  }
3861
4265
  // Apply default|sync|async|prop validators for QuickEdit new row form control
3862
4266
  applyNewRowValidations() {
4267
+ // Guard against component destruction or table/ngform being null
4268
+ if (this.isDestroyed || !this.table || !this.table.ngform) {
4269
+ return;
4270
+ }
3863
4271
  if (!this._checkNewEditableRowControl()) {
3864
4272
  return;
3865
4273
  }
@@ -3876,22 +4284,37 @@
3876
4284
  }
3877
4285
  // Remove validators for the QuickEdit new row widget and set form to untouched
3878
4286
  removeNewRowValidations() {
4287
+ // Guard against component destruction or table/ngform being null
4288
+ if (this.isDestroyed || !this.table || !this.table.ngform) {
4289
+ return;
4290
+ }
3879
4291
  this.table.ngform.markAsUntouched();
3880
4292
  if (!this._checkNewEditableRowControl()) {
3881
4293
  return;
3882
4294
  }
3883
4295
  const control = this.getFormControl('_new');
4296
+ if (!control) {
4297
+ return;
4298
+ }
3884
4299
  control.clearValidators();
3885
4300
  control.clearAsyncValidators();
3886
4301
  control.updateValueAndValidity();
3887
4302
  }
3888
4303
  addFormControl(suffix) {
4304
+ // Guard against component destruction or table/ngform being null
4305
+ if (this.isDestroyed || !this.table || !this.table.ngform) {
4306
+ return;
4307
+ }
3889
4308
  const ctrlName = suffix ? (this.binding + suffix) : this.binding;
3890
4309
  this.table.ngform.addControl(ctrlName, this.table.fb.control(''));
3891
4310
  }
3892
4311
  getFormControl(suffix) {
4312
+ // Guard against component destruction or table/ngform being null
4313
+ if (this.isDestroyed || !this.table || !this.table.ngform) {
4314
+ return null;
4315
+ }
3893
4316
  const ctrlName = suffix ? (this.binding + suffix) : this.binding;
3894
- return this.table.ngform.controls[ctrlName];
4317
+ return this.table.ngform.controls[ctrlName] || null;
3895
4318
  }
3896
4319
  _checkNewEditableRowControl() {
3897
4320
  return this._isNewEditableRow && this.getFormControl('_new');
@@ -3965,12 +4388,16 @@
3965
4388
  }
3966
4389
  // On field value change, apply cascading filter and set validation message
3967
4390
  onValueChange(val, widget) {
4391
+ // Guard against component destruction or table being null
4392
+ if (this.isDestroyed || !this.table) {
4393
+ return;
4394
+ }
3968
4395
  if (val !== null) {
3969
4396
  i4.applyFilterOnField(this.table.datasource, this.widget, this.table.fieldDefs, val, {
3970
4397
  widget: 'edit-widget-type'
3971
4398
  });
3972
4399
  }
3973
- if (this.table.ngform.touched) {
4400
+ if (this.table.ngform && this.table.ngform.touched) {
3974
4401
  this.activeControlType = widget;
3975
4402
  if (widget === 'inlineInstance') {
3976
4403
  this.notifyChanges();
@@ -4228,7 +4655,7 @@
4228
4655
  this.defaultvalue = i4.getDefaultValue(this.defaultvalue, this.type, this.editWidgetType);
4229
4656
  break;
4230
4657
  case 'show':
4231
- this.table.redraw(true);
4658
+ this.table.redraw(false);
4232
4659
  this.showinfilter = this.nativeElement.hasAttribute('showinfilter') ? this.nativeElement.getAttribute('showinfilter') : nv;
4233
4660
  break;
4234
4661
  case 'filterdataset':
@@ -4261,6 +4688,83 @@
4261
4688
  this.table.redraw(true);
4262
4689
  }
4263
4690
  }
4691
+ ngOnDestroy() {
4692
+ // MEMORY LEAK FIX: Clear ContentChildren QueryLists
4693
+ if (this._filterInstances) {
4694
+ try {
4695
+ this._filterInstances.reset([]);
4696
+ }
4697
+ catch (e) {
4698
+ // Silently handle cleanup errors - QueryList might already be destroyed
4699
+ }
4700
+ }
4701
+ if (this._inlineInstances) {
4702
+ try {
4703
+ this._inlineInstances.reset([]);
4704
+ }
4705
+ catch (e) {
4706
+ // Silently handle cleanup errors - QueryList might already be destroyed
4707
+ }
4708
+ }
4709
+ if (this._inlineInstancesNew) {
4710
+ try {
4711
+ this._inlineInstancesNew.reset([]);
4712
+ }
4713
+ catch (e) {
4714
+ // Silently handle cleanup errors - QueryList might already be destroyed
4715
+ }
4716
+ }
4717
+ // MEMORY LEAK FIX: Clear all widget instance references
4718
+ this.filterInstance = null;
4719
+ this.inlineInstance = null;
4720
+ this.inlineInstanceNew = null;
4721
+ // MEMORY LEAK FIX: Clear template references
4722
+ this.customExprTmpl = null;
4723
+ this.inlineWidthTempRef = null;
4724
+ this.filterTemplateRef = null;
4725
+ // MEMORY LEAK FIX: Clear dataset references
4726
+ this._filterDataSet = null;
4727
+ this.dataset = null;
4728
+ this._dataoptions = null;
4729
+ this._datasource = null;
4730
+ // MEMORY LEAK FIX: Clear validation objects
4731
+ if (this.fieldValidations) {
4732
+ try {
4733
+ this.fieldValidations.destroy();
4734
+ }
4735
+ catch (e) {
4736
+ // Silently handle cleanup errors
4737
+ }
4738
+ this.fieldValidations = null;
4739
+ }
4740
+ if (this.fieldValidations_new) {
4741
+ try {
4742
+ this.fieldValidations_new.destroy();
4743
+ }
4744
+ catch (e) {
4745
+ // Silently handle cleanup errors
4746
+ }
4747
+ this.fieldValidations_new = null;
4748
+ }
4749
+ this.syncValidators = [];
4750
+ this.asyncValidators = [];
4751
+ // MEMORY LEAK FIX: Clear filter control reference
4752
+ this.filterControl = null;
4753
+ // MEMORY LEAK FIX: Clear notify fields array
4754
+ if (this.notifyForFields) {
4755
+ this.notifyForFields = [];
4756
+ }
4757
+ // MEMORY LEAK FIX: Clear observe fields array
4758
+ if (this.observeOnFields) {
4759
+ this.observeOnFields = [];
4760
+ }
4761
+ // MEMORY LEAK FIX: Clear table and group references
4762
+ // Note: These are injected dependencies, but clearing helps GC
4763
+ this.table = null;
4764
+ this.group = null;
4765
+ // Call parent ngOnDestroy
4766
+ super.ngOnDestroy();
4767
+ }
4264
4768
  static { this.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0__namespace, type: TableColumnDirective, deps: [{ token: i0__namespace.Injector }, { token: i2__namespace.AppDefaults }, { token: TableComponent, optional: true }, { token: TableColumnGroupDirective, optional: true }, { token: 'filterdataset.bind', attribute: true }, { token: 'dataset.bind', attribute: true }, { token: 'EXPLICIT_CONTEXT', optional: true }], target: i0__namespace.ɵɵFactoryTarget.Directive }); }
4265
4769
  static { this.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.13", type: TableColumnDirective, isStandalone: true, selector: "[wmTableColumn]", providers: [
4266
4770
  i4.provideAsWidgetRef(TableColumnDirective)
@@ -4355,6 +4859,13 @@
4355
4859
  this.config.content = this.content;
4356
4860
  }
4357
4861
  }
4862
+ ngOnDestroy() {
4863
+ // MEMORY LEAK FIX: Clear table and config references
4864
+ this.table = null;
4865
+ this.config = null;
4866
+ // Call parent ngOnDestroy (BaseComponent has cleanup)
4867
+ super.ngOnDestroy();
4868
+ }
4358
4869
  static { this.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0__namespace, type: TableRowDirective, deps: [{ token: i0__namespace.Injector }, { token: TableComponent, optional: true, skipSelf: true }, { token: 'EXPLICIT_CONTEXT', optional: true }], target: i0__namespace.ɵɵFactoryTarget.Directive }); }
4359
4870
  static { this.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.13", type: TableRowDirective, isStandalone: true, selector: "[wmTableRow]", providers: [
4360
4871
  i4.provideAsWidgetRef(TableRowDirective)
@@ -4436,6 +4947,13 @@
4436
4947
  this.populateAction();
4437
4948
  this.table.registerRowActions(this.buttonDef);
4438
4949
  }
4950
+ ngOnDestroy() {
4951
+ // MEMORY LEAK FIX: Clear table reference and button definition
4952
+ this.table = null;
4953
+ this.buttonDef = null;
4954
+ // Call parent ngOnDestroy (BaseComponent has cleanup)
4955
+ super.ngOnDestroy();
4956
+ }
4439
4957
  static { this.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0__namespace, type: TableRowActionDirective, deps: [{ token: i0__namespace.Injector }, { token: TableComponent, optional: true }, { token: i4.Context, self: true }, { token: 'EXPLICIT_CONTEXT', optional: true }], target: i0__namespace.ɵɵFactoryTarget.Directive }); }
4440
4958
  static { this.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.13", type: TableRowActionDirective, isStandalone: true, selector: "[wmTableRowAction]", providers: [
4441
4959
  i4.provideAsWidgetRef(TableRowActionDirective),