@sankhyalabs/ezui 0.0.0-bugfix-dev-KB-77126.0 → 0.0.0-bugfix-dev-KB-77074.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 (149) hide show
  1. package/dist/cjs/RecordValidationProcessor-10846595.js +108 -0
  2. package/dist/cjs/ez-card-item_3.cjs.entry.js +19 -12
  3. package/dist/cjs/ez-chart.cjs.entry.js +1 -1
  4. package/dist/cjs/ez-combo-box.cjs.entry.js +10 -46
  5. package/dist/cjs/ez-date-input.cjs.entry.js +2 -8
  6. package/dist/cjs/ez-date-time-input.cjs.entry.js +2 -8
  7. package/dist/cjs/ez-dialog.cjs.entry.js +2 -10
  8. package/dist/cjs/ez-form-view.cjs.entry.js +2 -2
  9. package/dist/cjs/ez-form.cjs.entry.js +324 -4
  10. package/dist/cjs/ez-grid.cjs.entry.js +70542 -14645
  11. package/dist/cjs/ez-list.cjs.entry.js +100 -151
  12. package/dist/cjs/ez-number-input.cjs.entry.js +0 -7
  13. package/dist/cjs/ez-popover.cjs.entry.js +1 -1
  14. package/dist/cjs/ez-popup.cjs.entry.js +1 -1
  15. package/dist/cjs/ez-search.cjs.entry.js +12 -28
  16. package/dist/cjs/ez-text-area.cjs.entry.js +4 -66
  17. package/dist/cjs/ez-text-input.cjs.entry.js +7 -49
  18. package/dist/cjs/ez-time-input.cjs.entry.js +0 -6
  19. package/dist/cjs/ezui.cjs.js +1 -1
  20. package/dist/cjs/loader.cjs.js +1 -1
  21. package/dist/collection/collection-manifest.json +1 -1
  22. package/dist/collection/components/ez-card-item/ez-card-item.css +5 -14
  23. package/dist/collection/components/ez-combo-box/ez-combo-box.js +14 -75
  24. package/dist/collection/components/ez-date-input/ez-date-input.js +4 -35
  25. package/dist/collection/components/ez-date-time-input/ez-date-time-input.js +4 -35
  26. package/dist/collection/components/ez-dialog/ez-dialog.css +3 -3
  27. package/dist/collection/components/ez-dialog/ez-dialog.js +1 -9
  28. package/dist/collection/components/ez-filter-input/ez-filter-input.css +11 -0
  29. package/dist/collection/components/ez-filter-input/ez-filter-input.js +52 -22
  30. package/dist/collection/components/ez-form/ez-form.js +0 -1
  31. package/dist/collection/components/ez-form-view/fieldbuilder/templates/TextInput.tpl.js +2 -2
  32. package/dist/collection/components/ez-grid/controller/ag-grid/AgGridController.js +25 -80
  33. package/dist/collection/components/ez-grid/controller/ag-grid/DataSource.js +0 -8
  34. package/dist/collection/components/ez-grid/controller/ag-grid/GridEditionManager.js +46 -167
  35. package/dist/collection/components/ez-grid/controller/ag-grid/components/EzGridCustomCellEditor.js +0 -7
  36. package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/ComboBox.tpl.js +0 -1
  37. package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/DateInput.tpl.js +0 -1
  38. package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/NumberInput.tpl.js +0 -1
  39. package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/Search.tpl.js +0 -1
  40. package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/TextInput.tpl.js +1 -4
  41. package/dist/collection/components/ez-grid/ez-grid.js +3 -90
  42. package/dist/collection/components/ez-list/ez-list.css +5 -5
  43. package/dist/collection/components/ez-list/ez-list.js +170 -152
  44. package/dist/collection/components/ez-number-input/ez-number-input.js +0 -25
  45. package/dist/collection/components/ez-popover/ez-popover.css +10 -3
  46. package/dist/collection/components/ez-popup/ez-popup.js +1 -1
  47. package/dist/collection/components/ez-search/ez-search.css +1 -1
  48. package/dist/collection/components/ez-search/ez-search.js +14 -55
  49. package/dist/collection/components/ez-text-area/ez-text-area.css +0 -49
  50. package/dist/collection/components/ez-text-area/ez-text-area.js +2 -102
  51. package/dist/collection/components/ez-text-input/ez-text-input.css +53 -27
  52. package/dist/collection/components/ez-text-input/ez-text-input.js +6 -84
  53. package/dist/collection/components/ez-time-input/ez-time-input.js +0 -24
  54. package/dist/collection/utils/form/DataBinder.js +3 -18
  55. package/dist/collection/utils/interfaces/AbstractFieldMetadata.js +1 -1
  56. package/dist/custom-elements/index.js +70890 -15272
  57. package/dist/esm/RecordValidationProcessor-9c6cc267.js +105 -0
  58. package/dist/esm/ez-card-item_3.entry.js +19 -12
  59. package/dist/esm/ez-chart.entry.js +1 -1
  60. package/dist/esm/ez-combo-box.entry.js +11 -47
  61. package/dist/esm/ez-date-input.entry.js +2 -8
  62. package/dist/esm/ez-date-time-input.entry.js +2 -8
  63. package/dist/esm/ez-dialog.entry.js +2 -10
  64. package/dist/esm/ez-form-view.entry.js +2 -2
  65. package/dist/esm/ez-form.entry.js +323 -3
  66. package/dist/esm/ez-grid.entry.js +70542 -14645
  67. package/dist/esm/ez-list.entry.js +101 -152
  68. package/dist/esm/ez-number-input.entry.js +0 -7
  69. package/dist/esm/ez-popover.entry.js +1 -1
  70. package/dist/esm/ez-popup.entry.js +1 -1
  71. package/dist/esm/ez-search.entry.js +12 -28
  72. package/dist/esm/ez-text-area.entry.js +4 -66
  73. package/dist/esm/ez-text-input.entry.js +7 -49
  74. package/dist/esm/ez-time-input.entry.js +0 -6
  75. package/dist/esm/ezui.js +1 -1
  76. package/dist/esm/loader.js +1 -1
  77. package/dist/ezui/ezui.esm.js +1 -1
  78. package/dist/ezui/p-188f1c4c.entry.js +1 -0
  79. package/dist/ezui/p-49456b34.entry.js +1 -0
  80. package/dist/ezui/p-5a90d7d1.entry.js +1 -0
  81. package/dist/ezui/p-5b205c80.entry.js +1 -0
  82. package/dist/ezui/p-62732269.entry.js +1 -0
  83. package/dist/ezui/p-86b6aa01.entry.js +1 -0
  84. package/dist/ezui/p-b3b94f72.entry.js +1 -0
  85. package/dist/ezui/p-b95632e8.entry.js +1 -0
  86. package/dist/ezui/p-bcd47eda.entry.js +1 -0
  87. package/dist/ezui/p-c3c3d640.entry.js +304 -0
  88. package/dist/ezui/p-cdc472cc.entry.js +1 -0
  89. package/dist/ezui/p-d2c06f38.entry.js +1 -0
  90. package/dist/ezui/p-d8f64bb7.entry.js +1 -0
  91. package/dist/ezui/p-dc4ada32.entry.js +1 -0
  92. package/dist/ezui/p-e85c48d7.entry.js +1 -0
  93. package/dist/ezui/p-f299c608.entry.js +1 -0
  94. package/dist/ezui/p-f42855b9.js +1 -0
  95. package/dist/ezui/p-f80ac647.entry.js +1 -0
  96. package/dist/types/components/ez-combo-box/ez-combo-box.d.ts +1 -7
  97. package/dist/types/components/ez-date-input/ez-date-input.d.ts +1 -6
  98. package/dist/types/components/ez-date-time-input/ez-date-time-input.d.ts +1 -6
  99. package/dist/types/components/ez-dialog/ez-dialog.d.ts +0 -2
  100. package/dist/types/components/ez-filter-input/ez-filter-input.d.ts +11 -4
  101. package/dist/types/components/ez-form-view/fieldbuilder/templates/TextInput.tpl.d.ts +1 -1
  102. package/dist/types/components/ez-grid/controller/EzGridController.d.ts +0 -12
  103. package/dist/types/components/ez-grid/controller/ag-grid/AgGridController.d.ts +2 -7
  104. package/dist/types/components/ez-grid/controller/ag-grid/DataSource.d.ts +1 -2
  105. package/dist/types/components/ez-grid/controller/ag-grid/GridEditionManager.d.ts +7 -19
  106. package/dist/types/components/ez-grid/controller/ag-grid/components/EzGridCustomCellEditor.d.ts +1 -3
  107. package/dist/types/components/ez-grid/controller/ag-grid/components/EzGridCustomCellRender.d.ts +1 -1
  108. package/dist/types/components/ez-grid/controller/ag-grid/components/EzGridCustomHeader.d.ts +1 -1
  109. package/dist/types/components/ez-grid/controller/ag-grid/components/cellRendererStatus.d.ts +1 -1
  110. package/dist/types/components/ez-grid/controller/ag-grid/components/selectionHeader.d.ts +1 -1
  111. package/dist/types/components/ez-grid/controller/ag-grid/editor/EzCellEditor.d.ts +1 -1
  112. package/dist/types/components/ez-grid/controller/ag-grid/editor/EzCellRender.d.ts +1 -1
  113. package/dist/types/components/ez-grid/controller/ag-grid/editor/IUICellEditor.d.ts +0 -1
  114. package/dist/types/components/ez-grid/controller/ag-grid/mock/Server.d.ts +1 -1
  115. package/dist/types/components/ez-grid/ez-grid.d.ts +1 -11
  116. package/dist/types/components/ez-list/ez-list.d.ts +26 -3
  117. package/dist/types/components/ez-number-input/ez-number-input.d.ts +0 -4
  118. package/dist/types/components/ez-search/ez-search.d.ts +1 -6
  119. package/dist/types/components/ez-text-area/ez-text-area.d.ts +0 -17
  120. package/dist/types/components/ez-text-input/ez-text-input.d.ts +0 -9
  121. package/dist/types/components/ez-time-input/ez-time-input.d.ts +0 -4
  122. package/dist/types/components.d.ts +42 -107
  123. package/dist/types/utils/form/DataBinder.d.ts +0 -3
  124. package/package.json +4 -11
  125. package/dist/cjs/DataBinder-3b083480.js +0 -445
  126. package/dist/cjs/FocusResolver-885f2173.js +0 -35
  127. package/dist/collection/utils/FocusResolver.js +0 -31
  128. package/dist/esm/DataBinder-02fa9bb9.js +0 -441
  129. package/dist/esm/FocusResolver-1ccbf850.js +0 -33
  130. package/dist/ezui/p-0a75bb05.entry.js +0 -1
  131. package/dist/ezui/p-0db68715.entry.js +0 -1
  132. package/dist/ezui/p-19098a3f.entry.js +0 -1
  133. package/dist/ezui/p-1f830a2f.entry.js +0 -1
  134. package/dist/ezui/p-2aa8e4b2.entry.js +0 -1
  135. package/dist/ezui/p-3dd919b7.entry.js +0 -1
  136. package/dist/ezui/p-455e737c.js +0 -1
  137. package/dist/ezui/p-8d0f02c7.entry.js +0 -309
  138. package/dist/ezui/p-91266ddd.entry.js +0 -1
  139. package/dist/ezui/p-97af4b13.entry.js +0 -1
  140. package/dist/ezui/p-a5b91a77.entry.js +0 -1
  141. package/dist/ezui/p-a80b1287.entry.js +0 -1
  142. package/dist/ezui/p-b54e17d2.entry.js +0 -1
  143. package/dist/ezui/p-bfad39eb.entry.js +0 -1
  144. package/dist/ezui/p-c27b2e17.entry.js +0 -1
  145. package/dist/ezui/p-cd2e78f0.entry.js +0 -1
  146. package/dist/ezui/p-d0ca26fe.entry.js +0 -1
  147. package/dist/ezui/p-dc628ed3.js +0 -1
  148. package/dist/ezui/p-ffd246f5.entry.js +0 -1
  149. package/dist/types/utils/FocusResolver.d.ts +0 -5
@@ -1,6 +1,6 @@
1
- import { ApplicationContext, DataType, LockManager, MaskFormatter, NumberUtils, SortMode, StringUtils, UserInterface, } from '@sankhyalabs/core';
2
- import { Grid } from "@ag-grid-community/core";
3
- import { LicenseManager } from '@ag-grid-enterprise/core';
1
+ import { ApplicationContext, DataType, MaskFormatter, NumberUtils, SortMode, StringUtils, UserInterface, } from '@sankhyalabs/core';
2
+ import { Grid, } from 'ag-grid-community';
3
+ import { Grid as EnterpriseGrid, LicenseManager } from 'ag-grid-enterprise';
4
4
  import DataSource from './DataSource';
5
5
  import { EzGridCustomHeader } from './components/EzGridCustomHeader';
6
6
  import { CellRendererStatus } from './components/cellRendererStatus';
@@ -8,12 +8,6 @@ import SelectionHeader from './components/selectionHeader';
8
8
  import gridTerms from './i18n/pt-BR';
9
9
  import { DISTINCT_FILTER_NAME_PREFIX, EZ_GRID_LOADING_SOURCE } from '../../../../utils/constants';
10
10
  import GridEditionManager from './GridEditionManager';
11
- import { ModuleRegistry } from '@ag-grid-community/core';
12
- import { EnterpriseCoreModule } from '@ag-grid-enterprise/core';
13
- import { RangeSelectionModule } from '@ag-grid-enterprise/range-selection';
14
- import { ServerSideRowModelModule } from '@ag-grid-enterprise/server-side-row-model';
15
- import { ClipboardModule } from '@ag-grid-enterprise/clipboard';
16
- import { MenuModule } from '@ag-grid-enterprise/menu';
17
11
  export default class AgGridController {
18
12
  configFilterColumn(filterColumn) {
19
13
  this._filterColumn = filterColumn;
@@ -33,7 +27,7 @@ export default class AgGridController {
33
27
  var _a;
34
28
  (_a = this._filterColumn) === null || _a === void 0 ? void 0 : _a.show(configs);
35
29
  }
36
- constructor(_enterprise) {
30
+ constructor(enterprise) {
37
31
  this.DEFAULT_ROW_HEIGHT = 30;
38
32
  this.DEFAULT_HEADER_ROW_HEIGHT = 32;
39
33
  this.CHECK_BOX_COL_ID = 'checkBoxColumn';
@@ -49,13 +43,7 @@ export default class AgGridController {
49
43
  this._customFormatters = new Map();
50
44
  this._gridShowDom = false;
51
45
  this.peddingExecutionsOnGridShow = [];
52
- ModuleRegistry.registerModules([
53
- EnterpriseCoreModule,
54
- RangeSelectionModule,
55
- ServerSideRowModelModule,
56
- ClipboardModule,
57
- MenuModule
58
- ]);
46
+ this._enterprise = enterprise;
59
47
  }
60
48
  getGridConfig() {
61
49
  return this._gridConfig;
@@ -133,7 +121,6 @@ export default class AgGridController {
133
121
  var _a;
134
122
  this._options = options;
135
123
  this._container = container;
136
- const lockerId = options.enableLockManger ? LockManager.addLockManagerCtxId(this._container) : null;
137
124
  if (this._grid === undefined) {
138
125
  LicenseManager.setLicenseKey(ApplicationContext.getContextValue('__EZUI__GRID_LICENSE__'));
139
126
  this._columnStateChangeCallback = options.onColumnStateChange;
@@ -141,7 +128,7 @@ export default class AgGridController {
141
128
  this._doubleClickCallBack = options.onDoubleClick;
142
129
  this._multipleSelection = options.allowMultipleSelection;
143
130
  this._dataUnit = options.dataUnit;
144
- this._editionManager = new GridEditionManager(this._dataUnit, options.useEnterLikeTab, options.recordsValidator, options.editionIsDisabled, options.customEditors || this._customEditors, options.customRenders || this._customRenders, options.enableContinuousInsert, options.enableGridInsert, lockerId);
131
+ this._editionManager = new GridEditionManager(this._dataUnit, options.useEnterLikeTab, options.recordsValidator, options.editionIsDisabled, options.customEditors || this._customEditors, options.customRenders || this._customRenders, options.enableContinuousInsert, options.enableGridInsert);
145
132
  this._statusResolver = options.statusResolver;
146
133
  if (this._dataUnit) {
147
134
  this._dataUnit.sortingProvider = this;
@@ -188,7 +175,12 @@ export default class AgGridController {
188
175
  this.setOptionsEvents(this._gridOptions);
189
176
  this.setOptionsSupress(this._gridOptions);
190
177
  this._gridOptions = this._editionManager.configureGrid(this._gridOptions);
191
- this._grid = new Grid(container, this._gridOptions);
178
+ if (this._enterprise) {
179
+ this._grid = new EnterpriseGrid(container, this._gridOptions);
180
+ }
181
+ else {
182
+ this._grid = new Grid(container, this._gridOptions);
183
+ }
192
184
  const selection = (_a = this._dataUnit) === null || _a === void 0 ? void 0 : _a.getSelectionInfo();
193
185
  if (selection === null || selection === void 0 ? void 0 : selection.isAllRecords()) {
194
186
  this.selectAll(true);
@@ -348,7 +340,7 @@ export default class AgGridController {
348
340
  defineRowModelType(opt, sourceOptions) {
349
341
  if (this._dataUnit != undefined) {
350
342
  opt.rowModelType = 'serverSide';
351
- opt.serverSideDatasource = this._dataSource = new DataSource(this._dataUnit, this, sourceOptions);
343
+ opt.serverSideDatasource = new DataSource(this._dataUnit, this, sourceOptions);
352
344
  opt.serverSideSortOnServer = true;
353
345
  opt.columnDefs = this._colDefs;
354
346
  }
@@ -499,7 +491,7 @@ export default class AgGridController {
499
491
  r.setData(data);
500
492
  });
501
493
  this._gridOptions.api.refreshCells({ force: true });
502
- const invalidCell = this._editionManager.getNextInvalidCell();
494
+ const invalidCell = this._editionManager.getInvalidCell();
503
495
  if (invalidCell) {
504
496
  const rowNode = this._gridOptions.api.getRowNode(invalidCell.recordId);
505
497
  if (rowNode && invalidCell.field) {
@@ -519,7 +511,6 @@ export default class AgGridController {
519
511
  if (this._grid === undefined) {
520
512
  throw new Error('Erro interno: Grid ainda não inicializado.');
521
513
  }
522
- this._gridOptions.api.clearRangeSelection();
523
514
  this._gridOptions.api.refreshServerSide({ purge: true });
524
515
  this._options.onRefresh();
525
516
  if (scrollToSelectedRow)
@@ -542,15 +533,12 @@ export default class AgGridController {
542
533
  }
543
534
  setFocus() {
544
535
  var _a, _b;
545
- if (!((_b = (_a = this._dataUnit) === null || _a === void 0 ? void 0 : _a.records) === null || _b === void 0 ? void 0 : _b.length)) {
546
- this.focusOnGridContainer();
547
- return;
548
- }
549
- if (!this._dataUnit.getSelectedRecord()) {
536
+ if ((_b = (_a = this._dataUnit) === null || _a === void 0 ? void 0 : _a.records) === null || _b === void 0 ? void 0 : _b.length) {
550
537
  this.setFocusFirstRow();
551
- return;
552
538
  }
553
- this.syncSelectWithDataUnit();
539
+ else {
540
+ this.focusOnGridContainer();
541
+ }
554
542
  }
555
543
  setAutoFocus(autoFocus) {
556
544
  var _a;
@@ -594,23 +582,6 @@ export default class AgGridController {
594
582
  this.startEditionOnRowByIndex(newRowIndex);
595
583
  }
596
584
  }
597
- syncSelectWithDataUnit() {
598
- const rowNode = this._gridOptions.api.getRowNode(this._dataUnit.getSelectedRecord().__record__id__);
599
- if ((rowNode === null || rowNode === void 0 ? void 0 : rowNode.rowIndex) < 0)
600
- return;
601
- const rowRange = this._gridOptions.api.getCellRanges().find(row => row.startRow.rowIndex === rowNode.rowIndex);
602
- if ((rowRange === null || rowRange === void 0 ? void 0 : rowRange.columns.length) > 0) {
603
- if (this._dataUnit.hasNewRecord()) {
604
- this.startEdition(rowNode.rowIndex, rowRange.columns[0]);
605
- return;
606
- }
607
- this.focusByCollAndRow(rowRange.columns[0], rowNode.rowIndex);
608
- this._gridOptions.api.addCellRange({ rowStartIndex: rowNode.rowIndex, rowEndIndex: rowNode.rowIndex, columns: rowRange.columns });
609
- return;
610
- }
611
- this._gridOptions.api.clearRangeSelection();
612
- this.setFocusOnRow(rowNode.rowIndex);
613
- }
614
585
  startEdition(rowIndex, firstCol) {
615
586
  this._gridOptions.api.clearRangeSelection();
616
587
  this._gridOptions.api.addCellRange({ rowStartIndex: rowIndex, rowEndIndex: rowIndex, columns: [firstCol] });
@@ -641,7 +612,6 @@ export default class AgGridController {
641
612
  let displayedColumns = this._gridOptions.columnApi.getAllDisplayedColumns();
642
613
  let firstColl = displayedColumns.find(column => column.getColDef().headerName !== '');
643
614
  this.focusByCollAndRow(firstColl, rowIndex);
644
- this._gridOptions.api.addCellRange({ rowStartIndex: rowIndex, rowEndIndex: rowIndex, columns: [firstColl] });
645
615
  }
646
616
  focusByCollAndRow(firstCell, rowIndex) {
647
617
  this._gridOptions.api.ensureColumnVisible(firstCell);
@@ -681,14 +651,6 @@ export default class AgGridController {
681
651
  this._gridOptions.api.setColumnDefs(this._colDefs);
682
652
  }
683
653
  }
684
- hideSelectionColumn() {
685
- var _a, _b;
686
- (_b = (_a = this._gridOptions) === null || _a === void 0 ? void 0 : _a.columnApi) === null || _b === void 0 ? void 0 : _b.setColumnVisible(this.CHECK_BOX_COL_ID, false);
687
- }
688
- showSelectionColumn() {
689
- var _a, _b;
690
- (_b = (_a = this._gridOptions) === null || _a === void 0 ? void 0 : _a.columnApi) === null || _b === void 0 ? void 0 : _b.setColumnVisible(this.CHECK_BOX_COL_ID, true);
691
- }
692
654
  getColumnsDef() {
693
655
  if (this._grid === undefined) {
694
656
  throw new Error('Erro interno: Grid ainda não inicializado.');
@@ -973,24 +935,18 @@ export default class AgGridController {
973
935
  return false;
974
936
  }
975
937
  onSelectionChange(event) {
976
- var _a, _b;
977
- const selectedRowId = (_b = (_a = event.api.getSelectedNodes()) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.id;
978
- const isNewRecord = this._dataUnit.isNewRecord(selectedRowId);
979
938
  if (!this._selectionChangeCallback)
980
939
  return;
981
940
  clearTimeout(this._selectionChangeDeboucing);
982
- this._selectionChangeDeboucing = window.setTimeout(async () => {
983
- const saveSuccess = (!isNewRecord && selectedRowId) ? await this.handleExecuteProceedAutosave() : true;
984
- if (!saveSuccess)
985
- return;
941
+ this._selectionChangeDeboucing = window.setTimeout(() => {
942
+ this.handleExecuteProceedAutosave();
986
943
  this.processBuildSelectionChangeCallback(event);
987
944
  }, 0);
988
945
  }
989
- async handleExecuteProceedAutosave() {
946
+ handleExecuteProceedAutosave() {
990
947
  if (this._gridShowDom) {
991
- return await this._editionManager.proceedAutoSave();
948
+ this._editionManager.proceedAutoSave();
992
949
  }
993
- return true;
994
950
  }
995
951
  processBuildSelectionChangeCallback(event) {
996
952
  if (this._dataUnit) {
@@ -1015,7 +971,7 @@ export default class AgGridController {
1015
971
  });
1016
972
  }
1017
973
  onRowDoubleClick(evt) {
1018
- if (this._doubleClickCallBack && (!this._options.enableGridInsert || !this._dataUnit.hasNewRecord())) {
974
+ if (this._doubleClickCallBack) {
1019
975
  this._doubleClickCallBack(evt.data);
1020
976
  }
1021
977
  }
@@ -1031,11 +987,13 @@ export default class AgGridController {
1031
987
  }
1032
988
  }
1033
989
  setCellEditors(customEditors) {
990
+ var _a;
1034
991
  if (!this._editionManager) {
1035
992
  this._customEditors = customEditors;
1036
993
  return;
1037
994
  }
1038
995
  this._editionManager.setCellEditors(customEditors);
996
+ (_a = this._gridOptions) === null || _a === void 0 ? void 0 : _a.api.redrawRows();
1039
997
  }
1040
998
  setCellRenders(customRenders) {
1041
999
  var _a;
@@ -1056,19 +1014,6 @@ export default class AgGridController {
1056
1014
  this._editionManager.processContinuousInsert();
1057
1015
  }
1058
1016
  destroy() {
1059
- var _a;
1060
1017
  this.observer.disconnect();
1061
- (_a = this._dataSource) === null || _a === void 0 ? void 0 : _a.destroy();
1062
- }
1063
- registryListeners() {
1064
- var _a;
1065
- (_a = this._dataSource) === null || _a === void 0 ? void 0 : _a.registryListeners();
1066
- }
1067
- resetPaginationState() {
1068
- var _a, _b;
1069
- (_b = (_a = this._gridOptions) === null || _a === void 0 ? void 0 : _a.api) === null || _b === void 0 ? void 0 : _b.clearRangeSelection();
1070
- }
1071
- stopEdit() {
1072
- this._gridOptions.api.stopEditing();
1073
1018
  }
1074
1019
  }
@@ -6,14 +6,12 @@ export default class DataSource {
6
6
  this._controller.clearInvalidCells();
7
7
  this.handleRefreshOrReload(action);
8
8
  this._controller.processContinuousInsert();
9
- this._controller.showSelectionColumn();
10
9
  }
11
10
  handleEditionCanceled(action) {
12
11
  if (this._options.enableGridInsert) {
13
12
  this._controller.processEditionCanceled();
14
13
  }
15
14
  this.handleRefreshOrReload(action);
16
- this._controller.showSelectionColumn();
17
15
  }
18
16
  handleSavingCanceled(action) {
19
17
  var _a, _b, _c, _d;
@@ -68,7 +66,6 @@ export default class DataSource {
68
66
  }
69
67
  handleRecordsAdded() {
70
68
  if (this._options.enableGridInsert) {
71
- this._controller.hideSelectionColumn();
72
69
  this._controller.refresh();
73
70
  this.focusOnNewRecord();
74
71
  }
@@ -216,11 +213,6 @@ export default class DataSource {
216
213
  destroy() {
217
214
  this._dataUnit.unsubscribe(this.duObserver);
218
215
  }
219
- registryListeners() {
220
- var _a, _b;
221
- (_a = this._dataUnit) === null || _a === void 0 ? void 0 : _a.unsubscribe(this.duObserver);
222
- (_b = this._dataUnit) === null || _b === void 0 ? void 0 : _b.subscribe(this.duObserver);
223
- }
224
216
  buildColumnDefs() {
225
217
  const gridConfig = this._controller.getGridConfig() || [];
226
218
  const columnDefs = [];
@@ -1,16 +1,15 @@
1
- import { LockManager, LockManagerOperation, UserInterface } from '@sankhyalabs/core';
2
- import { KeyCode, } from "@ag-grid-community/core";
1
+ import { UserInterface } from '@sankhyalabs/core';
2
+ import { KeyCode, } from 'ag-grid-community';
3
3
  import { RecordValidationProcessor } from '../../../../utils/validators/recordvalidator/RecordValidationProcessor';
4
4
  import EzCellEditor from './editor/EzCellEditor';
5
5
  import EzGridCustomCellEditor from './components/EzGridCustomCellEditor';
6
6
  import EzGridCustomCellRender from './components/EzGridCustomCellRender';
7
- import { DataBinder } from '../../../../utils';
8
7
  export default class GridEditionManager {
9
- constructor(dataUnit, useEnterLikeTab, recordsValidator, editionIsDisabled, customEditors, customRenders, enableContinuousInsert, enableGridInsert, lockerId) {
8
+ constructor(dataUnit, useEnterLikeTab, recordsValidator, editionIsDisabled, customEditors, customRenders, enableContinuousInsert, enableGridInsert) {
10
9
  this._dataUnit = dataUnit;
11
10
  this._recordValidationProcessor = new RecordValidationProcessor(this._dataUnit, {
12
11
  getRequiredFields: () => this.getRequiredFields(),
13
- markAsInvalid: (invalidField, recordId) => { this.pushInvalidCell(invalidField, recordId); },
12
+ markAsInvalid: (invalidField, recordId) => { this.setInvalidCell(invalidField, recordId); },
14
13
  getMessageForField: () => null,
15
14
  }, recordsValidator);
16
15
  this._useEnterLikeTab = useEnterLikeTab;
@@ -19,34 +18,16 @@ export default class GridEditionManager {
19
18
  this._enableGridInsert = enableGridInsert;
20
19
  this._customEditors = customEditors;
21
20
  this._customRenders = customRenders;
22
- this._lockerId = lockerId;
23
21
  }
24
22
  configureGrid(options) {
25
23
  this._gridOptions = options;
26
24
  options.readOnlyEdit = true;
27
25
  options.onCellEditRequest = evt => this.onCellEditRequest(evt);
28
- options.onCellEditingStarted = async (evt) => {
29
- var _a;
30
- if (this._dataUnit.hasNewRecord()) {
31
- this.handleCellEditingStartedRowAdd(evt);
32
- }
33
- else {
34
- this._lastCellOpened = this._lastCellEdited = { rowIndex: evt.rowIndex, column: evt.column, rowPinned: undefined };
35
- }
36
- (_a = this._currentEditLock) === null || _a === void 0 ? void 0 : _a.call(this);
37
- this._currentEditLock = LockManager.lock(this._lockerId, LockManagerOperation.TASKBAR_CLICK);
38
- };
39
- options.onCellEditingStopped = () => {
40
- var _a;
41
- (_a = this._currentEditLock) === null || _a === void 0 ? void 0 : _a.call(this);
42
- };
43
26
  options.onCellKeyDown = evt => {
44
27
  if (evt.event && evt["column"]) {
45
28
  this.onCellKeyDown(evt);
46
29
  }
47
30
  };
48
- options.isRowSelectable = (node) => this.isSelectableRow(node);
49
- options.onCellFocused = () => this.lockFocusWhenAddRow();
50
31
  return options;
51
32
  }
52
33
  updateCurrentEditorGuiValue(updatedRowValue) {
@@ -59,82 +40,37 @@ export default class GridEditionManager {
59
40
  const value = updatedRowValue[fieldName];
60
41
  currentEditor.setGuiValue(value);
61
42
  }
62
- lockFocusWhenAddRow() {
63
- var _a, _b, _c, _d;
64
- const api = this._gridOptions.api;
65
- const newFocusCell = api.getFocusedCell();
66
- const rowIndex = newFocusCell === null || newFocusCell === void 0 ? void 0 : newFocusCell.rowIndex;
67
- const recordId = (_b = (_a = this._dataUnit.getAddedRecords()) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.__record__id__;
68
- const rowNode = api.getRowNode(recordId);
69
- if (!this._dataUnit.hasNewRecord() || rowIndex == (rowNode === null || rowNode === void 0 ? void 0 : rowNode.rowIndex)) {
70
- return;
71
- }
72
- const lastCell = (_d = (_c = this._lastCellOpened) !== null && _c !== void 0 ? _c : this._lastCellEdited) !== null && _d !== void 0 ? _d : this._lastCellClicked;
73
- if ((lastCell === null || lastCell === void 0 ? void 0 : lastCell.rowIndex) < (rowNode === null || rowNode === void 0 ? void 0 : rowNode.rowIndex)) {
74
- return;
75
- }
76
- api.clearFocusedCell();
77
- if (!lastCell || (rowNode === null || rowNode === void 0 ? void 0 : rowNode.rowIndex) == undefined) {
78
- return;
79
- }
80
- lastCell.rowIndex = rowNode === null || rowNode === void 0 ? void 0 : rowNode.rowIndex;
81
- this.focusOnCell(lastCell);
82
- }
83
- handleCellEditingStartedRowAdd(evt) {
84
- var _a, _b, _c, _d, _e;
85
- const nodeId = (_a = evt.node) === null || _a === void 0 ? void 0 : _a.id;
86
- const addedRecordId = (_c = (_b = this._dataUnit.getAddedRecords()) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.__record__id__;
87
- if (nodeId == addedRecordId) {
88
- this._lastCellOpened = this._lastCellEdited = { rowIndex: evt.rowIndex, column: evt === null || evt === void 0 ? void 0 : evt.column, rowPinned: undefined };
89
- return;
90
- }
91
- evt.api.stopEditing();
92
- const rowIndex = (_d = evt.api.getRowNode(addedRecordId)) === null || _d === void 0 ? void 0 : _d.rowIndex;
93
- this._lastCellOpened = this._lastCellEdited = { rowIndex: rowIndex, column: (_e = this._lastCellEdited) === null || _e === void 0 ? void 0 : _e.column, rowPinned: undefined };
94
- }
95
- isSelectableRow(node) {
96
- if (!this._dataUnit.hasNewRecord()) {
97
- return true;
98
- }
99
- if (!this._dataUnit.isNewRecord(node.id)) {
100
- return false;
101
- }
102
- return true;
103
- }
104
43
  canContinuousInsert() {
105
44
  var _a;
106
45
  return this._enableContinuousInsert && (this._dataUnit.records.length - 1) === ((_a = this._lastCellEdited) === null || _a === void 0 ? void 0 : _a.rowIndex);
107
46
  }
108
- async proceedAutoSave() {
47
+ proceedAutoSave() {
109
48
  if (!this._dataUnit.isDirty()) {
110
49
  this.saveSuccess();
111
- return true;
112
- }
113
- const currentRecord = this._dataUnit.getSelectedRecord();
114
- if (currentRecord == undefined) {
115
- return true;
50
+ return;
116
51
  }
117
- this.clearInvalidCells(false);
118
- try {
119
- await this._recordValidationProcessor.validate(true);
120
- await this.saveDataUnit();
121
- this.saveSuccess();
122
- return true;
52
+ if (!this._isGridEdition) {
53
+ return;
123
54
  }
124
- catch (reason) {
125
- this.saveFail(reason);
126
- return false;
55
+ const currentRercord = this._dataUnit.getSelectedRecord();
56
+ if (currentRercord == undefined) {
57
+ return;
127
58
  }
128
- }
129
- async saveDataUnit() {
130
- await this._dataUnit.saveData();
131
- return true;
59
+ this._invalidCell = undefined;
60
+ this._recordValidationProcessor
61
+ .validate(true)
62
+ .then(() => {
63
+ this._dataUnit.saveData()
64
+ .then(() => this.saveSuccess())
65
+ .catch(reason => this.saveFail(reason));
66
+ })
67
+ .catch(reason => this.saveFail(reason));
132
68
  }
133
69
  async recordValidate() {
134
70
  if (!this._dataUnit.isDirty())
135
71
  return;
136
72
  try {
137
- this.clearInvalidCells(false);
73
+ this._invalidCell = undefined;
138
74
  await this._recordValidationProcessor.validate(false);
139
75
  }
140
76
  catch (error) { }
@@ -162,13 +98,6 @@ export default class GridEditionManager {
162
98
  return { ezCellEditor: EzCellEditor };
163
99
  }
164
100
  verifyClickToEdition(api, cellClicked) {
165
- var _a, _b;
166
- const selectedRecordID = (_a = this._dataUnit.getSelectedRecord()) === null || _a === void 0 ? void 0 : _a.__record__id__;
167
- if (this._dataUnit.hasNewRecord() && selectedRecordID) {
168
- const dataUnitRecordIndex = (_b = api.getRowNode(selectedRecordID)) === null || _b === void 0 ? void 0 : _b.rowIndex;
169
- if (dataUnitRecordIndex != cellClicked.rowIndex)
170
- return;
171
- }
172
101
  if (this.isSecondClick(cellClicked)) {
173
102
  api.startEditingCell({ rowIndex: cellClicked.rowIndex, colKey: cellClicked.column.getColId() });
174
103
  }
@@ -178,9 +107,6 @@ export default class GridEditionManager {
178
107
  col.cellEditor = 'ezCellEditor';
179
108
  col.editable = params => this.canEdit(params);
180
109
  col.suppressKeyboardEvent = (params) => {
181
- if (params.event.key === KeyCode.ESCAPE && params.editing) {
182
- return this._dataUnit.isDirty();
183
- }
184
110
  return params.event.key === KeyCode.ENTER;
185
111
  };
186
112
  col.cellEditorSelector = (params) => {
@@ -210,21 +136,10 @@ export default class GridEditionManager {
210
136
  return col;
211
137
  }
212
138
  getRequiredFields() {
213
- const formRequiredFields = this.getFormRequiredFields();
214
- return this._gridOptions.columnApi.getAllDisplayedColumns()
215
- .filter(column => {
216
- const fieldDefinition = this._dataUnit.getField(column.getColId());
217
- return (fieldDefinition && fieldDefinition.required) || formRequiredFields.includes(column.getColId());
218
- })
219
- .map(column => column.getColId());
220
- }
221
- getFormRequiredFields() {
222
- const formRequiredFields = [];
223
- const dataBinders = DataBinder.getDataBindersByDataUnit(this._dataUnit);
224
- dataBinders.forEach(dataBinder => {
225
- formRequiredFields.push(...dataBinder.getFormRequiredFields());
226
- });
227
- return formRequiredFields;
139
+ return this._gridOptions.columnApi.getAllDisplayedColumns().filter(c => {
140
+ const fieldDefinition = this._dataUnit.getField(c.getColId());
141
+ return fieldDefinition && fieldDefinition.required;
142
+ }).map(c => c.getColId());
228
143
  }
229
144
  saveSuccess() {
230
145
  var _a;
@@ -237,11 +152,10 @@ export default class GridEditionManager {
237
152
  this._isGridEdition = false;
238
153
  }
239
154
  saveFail(reason) {
240
- var _a;
241
- this.focusOnCell((_a = this._lastCellOpened) !== null && _a !== void 0 ? _a : this._lastCellEdited);
155
+ this.focusOnCell(this._lastCellEdited);
242
156
  this._isGridEdition = false;
243
157
  if (reason) {
244
- throw reason;
158
+ Promise.reject(reason);
245
159
  }
246
160
  }
247
161
  focusOnCell(cell) {
@@ -306,9 +220,6 @@ export default class GridEditionManager {
306
220
  this.moveEditionVertically(api, 1);
307
221
  }
308
222
  moveEditionVertically(api, offset) {
309
- if (this._dataUnit.hasNewRecord() && this._isGridEdition) {
310
- return;
311
- }
312
223
  const editionCell = api.getEditingCells()[0];
313
224
  if (!editionCell) {
314
225
  return;
@@ -353,66 +264,41 @@ export default class GridEditionManager {
353
264
  return true;
354
265
  }
355
266
  onCellEditRequest(event) {
356
- var _a;
357
- const value = event.newValue;
358
- if (event.oldValue == value) {
359
- (_a = this._currentEditLock) === null || _a === void 0 ? void 0 : _a.call(this);
360
- return;
361
- }
362
- if (value instanceof Promise) {
363
- this.handlePromiseValue(event, value);
364
- return;
365
- }
366
- this.updateCellValue(event, value);
367
- }
368
- async handlePromiseValue(event, value) {
369
267
  const fieldName = event.colDef.field;
370
- const fieldDescriptor = this._dataUnit.getField(event.colDef.colId);
371
- const initialValue = (fieldDescriptor === null || fieldDescriptor === void 0 ? void 0 : fieldDescriptor.userInterface) === UserInterface.SEARCH ? value : event.oldValue;
372
- event.node.setData(Object.assign(Object.assign({}, event.data), { [fieldName]: initialValue }));
373
- const resolved = await value;
374
- return this.updateCellValue(event, resolved);
375
- }
376
- updateCellValue(event, newValue) {
377
- var _a;
378
- const fieldName = event.colDef.field;
379
- event.node.setData(Object.assign(Object.assign({}, event.data), { [fieldName]: newValue }));
380
- (_a = this._currentEditLock) === null || _a === void 0 ? void 0 : _a.call(this);
381
- if (event.oldValue !== newValue) {
268
+ const value = event.newValue;
269
+ if (event.oldValue != value) {
270
+ if (value instanceof Promise) {
271
+ const fieldDescriptor = this._dataUnit.getField(event.colDef.colId);
272
+ event.node.setData(Object.assign(Object.assign({}, event.data), { [fieldName]: (fieldDescriptor === null || fieldDescriptor === void 0 ? void 0 : fieldDescriptor.userInterface) === UserInterface.SEARCH ? value : event.oldValue }));
273
+ value.then(resolved => event.node.setData(Object.assign(Object.assign({}, event.data), { [fieldName]: resolved })));
274
+ }
275
+ else {
276
+ event.node.setData(Object.assign(Object.assign({}, event.data), { [fieldName]: value }));
277
+ }
382
278
  this._isGridEdition = true;
383
- this._dataUnit.setFieldValue(fieldName, newValue, [event.data.__record__id__], { suppressCreateNewRecord: true });
279
+ this._dataUnit.setFieldValue(fieldName, value, [event.data.__record__id__], { suppressCreateNewRecord: true });
384
280
  this._lastCellEdited = { rowIndex: event.rowIndex, column: event.column, rowPinned: undefined };
385
281
  }
386
282
  }
387
283
  setCellEditors(customEditors) {
388
- var _a, _b;
389
284
  this._customEditors = customEditors;
390
- if (!customEditors.has((_b = (_a = this._lastCellOpened) === null || _a === void 0 ? void 0 : _a.column) === null || _b === void 0 ? void 0 : _b.getColId()))
391
- return;
392
- this._gridOptions.api.stopEditing();
393
- window.requestAnimationFrame(() => this.focusOnCell(this._lastCellOpened));
394
285
  }
395
286
  setCellRenders(customRenders) {
396
287
  this._customRenders = customRenders;
397
288
  }
398
- pushInvalidCell(invalidField, recordId) {
399
- this._invalidCells.push({ field: invalidField, recordId });
400
- this._nextInvalidCell = this._invalidCells[0];
401
- }
402
- getInvalidCells() {
403
- return this._invalidCells;
289
+ setInvalidCell(invalidCell, recordId) {
290
+ this._invalidCell = { field: invalidCell, recordId };
404
291
  }
405
- getNextInvalidCell() {
406
- return this._nextInvalidCell;
292
+ getInvalidCell() {
293
+ return this._invalidCell;
407
294
  }
408
- async processContinuousInsert() {
295
+ processContinuousInsert() {
409
296
  if (!this.canContinuousInsert())
410
297
  return;
411
298
  this._dataUnit.addRecord();
412
299
  }
413
300
  clearInvalidCells(stopEdition) {
414
- this._invalidCells = [];
415
- this._nextInvalidCell = undefined;
301
+ this._invalidCell = undefined;
416
302
  if (stopEdition) {
417
303
  this._isGridEdition = false;
418
304
  }
@@ -423,17 +309,10 @@ export default class GridEditionManager {
423
309
  hasInvalidField(fieldName, recordId) {
424
310
  if (!this.hasInvalidCell())
425
311
  return false;
426
- this._nextInvalidCell = this._invalidCells[0];
427
- const containsFieldName = this._nextInvalidCell.field.name === fieldName;
428
- const containsRecordId = this._nextInvalidCell.recordId === recordId;
429
- return containsFieldName && containsRecordId;
312
+ return this._invalidCell.field.name === fieldName && this._invalidCell.recordId === recordId;
430
313
  }
431
314
  hasInvalidCell() {
432
- var _a, _b, _c;
433
- const hasInvalidCell = ((_a = this._invalidCells) === null || _a === void 0 ? void 0 : _a.length) > 0;
434
- const hasField = (_b = this._invalidCells) === null || _b === void 0 ? void 0 : _b.filter(invalidCell => { invalidCell.field; });
435
- const hasRecordId = (_c = this._invalidCells) === null || _c === void 0 ? void 0 : _c.filter(invalidCell => { invalidCell.recordId; });
436
- if (!hasInvalidCell || !hasField || !hasRecordId)
315
+ if (!this._invalidCell || !this._invalidCell.field || !this._invalidCell.recordId)
437
316
  return false;
438
317
  return true;
439
318
  }
@@ -2,7 +2,6 @@ import { HTMLBuilder } from "@sankhyalabs/core";
2
2
  import { CustomEditorSource } from "../../../../../utils/customEditor/interfaces/ICustomEditor";
3
3
  import EzCellEditor from "../editor/EzCellEditor";
4
4
  import { getViewPortHeight } from "../editor/GridEditorUtils";
5
- import FocusResolver from "../../../../../utils/FocusResolver";
6
5
  export default class EzGridCustomCellEditor extends EzCellEditor {
7
6
  init(params) {
8
7
  var _a, _b;
@@ -66,10 +65,4 @@ export default class EzGridCustomCellEditor extends EzCellEditor {
66
65
  return this._customGui.value;
67
66
  return this._value;
68
67
  }
69
- afterGuiAttached() {
70
- this.focusIn();
71
- }
72
- focusIn() {
73
- FocusResolver.resolveFocus(this._customGui);
74
- }
75
68
  }
@@ -19,7 +19,6 @@ export const buildComboBox = ({ required, props, eGridCell }) => {
19
19
  combo.options = options;
20
20
  combo.stopPropagateEnterKeyEvent = true;
21
21
  combo.listOptionsPosition = { verticalPosition: 29, bottomLimit: getViewPortHeight(eGridCell), hardPosition: true };
22
- combo.autoFocus = true;
23
22
  return combo;
24
23
  };
25
24
  export const buildSwitch = (fieldMetadata) => {
@@ -7,7 +7,6 @@ export const buildDate = () => {
7
7
  data-is-fixed="true"
8
8
  />`);
9
9
  dateInput.valueGetter = () => dateInput.getValueAsync();
10
- dateInput.autoFocus = true;
11
10
  return dateInput;
12
11
  };
13
12
  export const buildTime = ({ readOnly }) => {
@@ -17,6 +17,5 @@ function buildNumeric(readOnly, precision, prettyPrecision) {
17
17
  mode="slim"
18
18
  />`);
19
19
  input.valueGetter = () => input.getValueAsync();
20
- input.autoFocus = true;
21
20
  return input;
22
21
  }
@@ -13,7 +13,6 @@ export const buildSearch = ({ name, required, readOnly, eGridCell, dataUnit }) =
13
13
  ezSearch.suppressPreLoad = true;
14
14
  ezSearch.listOptionsPosition = { verticalPosition: 29, bottomLimit: getViewPortHeight(eGridCell), hardPosition: true };
15
15
  ezSearch.stopPropagateEnterKeyEvent = true;
16
- ezSearch.autoFocus = true;
17
16
  ezSearch.valueGetter = () => ezSearch.getValueAsync();
18
17
  return ezSearch;
19
18
  };