@sankhyalabs/ezui 0.0.0-bugfix-dev-KB-76362.0 → 0.0.0-bugfix-dev-KB-75609.1

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 (129) hide show
  1. package/dist/cjs/DataBinder-aff1dcc7.js +445 -0
  2. package/dist/cjs/FocusResolver-885f2173.js +35 -0
  3. package/dist/cjs/ez-card-item_3.cjs.entry.js +12 -19
  4. package/dist/cjs/ez-combo-box.cjs.entry.js +46 -10
  5. package/dist/cjs/ez-date-input.cjs.entry.js +8 -2
  6. package/dist/cjs/ez-date-time-input.cjs.entry.js +8 -2
  7. package/dist/cjs/ez-dialog.cjs.entry.js +9 -1
  8. package/dist/cjs/ez-form.cjs.entry.js +3 -324
  9. package/dist/cjs/ez-grid.cjs.entry.js +254 -62
  10. package/dist/cjs/ez-list.cjs.entry.js +151 -100
  11. package/dist/cjs/ez-number-input.cjs.entry.js +7 -0
  12. package/dist/cjs/ez-popover.cjs.entry.js +1 -1
  13. package/dist/cjs/ez-popup.cjs.entry.js +2 -9
  14. package/dist/cjs/ez-search.cjs.entry.js +28 -12
  15. package/dist/cjs/ez-text-area.cjs.entry.js +66 -4
  16. package/dist/cjs/ez-text-input.cjs.entry.js +8 -3
  17. package/dist/cjs/ez-time-input.cjs.entry.js +6 -0
  18. package/dist/cjs/ezui.cjs.js +1 -1
  19. package/dist/cjs/loader.cjs.js +1 -1
  20. package/dist/collection/collection-manifest.json +1 -1
  21. package/dist/collection/components/ez-card-item/ez-card-item.css +14 -5
  22. package/dist/collection/components/ez-combo-box/ez-combo-box.js +75 -14
  23. package/dist/collection/components/ez-date-input/ez-date-input.js +35 -4
  24. package/dist/collection/components/ez-date-time-input/ez-date-time-input.js +35 -4
  25. package/dist/collection/components/ez-dialog/ez-dialog.js +9 -1
  26. package/dist/collection/components/ez-filter-input/ez-filter-input.css +0 -11
  27. package/dist/collection/components/ez-filter-input/ez-filter-input.js +22 -52
  28. package/dist/collection/components/ez-grid/controller/ag-grid/AgGridController.js +52 -14
  29. package/dist/collection/components/ez-grid/controller/ag-grid/DataSource.js +3 -0
  30. package/dist/collection/components/ez-grid/controller/ag-grid/GridEditionManager.js +166 -45
  31. package/dist/collection/components/ez-grid/controller/ag-grid/components/EzGridCustomCellEditor.js +7 -0
  32. package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/ComboBox.tpl.js +1 -0
  33. package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/DateInput.tpl.js +1 -0
  34. package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/NumberInput.tpl.js +1 -0
  35. package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/Search.tpl.js +1 -0
  36. package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/TextInput.tpl.js +4 -1
  37. package/dist/collection/components/ez-grid/ez-grid.js +83 -1
  38. package/dist/collection/components/ez-list/ez-list.css +5 -5
  39. package/dist/collection/components/ez-list/ez-list.js +152 -170
  40. package/dist/collection/components/ez-number-input/ez-number-input.js +25 -0
  41. package/dist/collection/components/ez-popover/ez-popover.css +3 -10
  42. package/dist/collection/components/ez-popup/ez-popup.css +2 -6
  43. package/dist/collection/components/ez-popup/ez-popup.js +3 -10
  44. package/dist/collection/components/ez-search/ez-search.css +1 -1
  45. package/dist/collection/components/ez-search/ez-search.js +55 -14
  46. package/dist/collection/components/ez-text-area/ez-text-area.css +49 -0
  47. package/dist/collection/components/ez-text-area/ez-text-area.js +102 -2
  48. package/dist/collection/components/ez-text-input/ez-text-input.css +27 -53
  49. package/dist/collection/components/ez-text-input/ez-text-input.js +25 -2
  50. package/dist/collection/components/ez-time-input/ez-time-input.js +24 -0
  51. package/dist/collection/utils/FocusResolver.js +31 -0
  52. package/dist/collection/utils/form/DataBinder.js +18 -3
  53. package/dist/custom-elements/index.js +663 -237
  54. package/dist/esm/DataBinder-bd240826.js +441 -0
  55. package/dist/esm/FocusResolver-1ccbf850.js +33 -0
  56. package/dist/esm/ez-card-item_3.entry.js +12 -19
  57. package/dist/esm/ez-combo-box.entry.js +47 -11
  58. package/dist/esm/ez-date-input.entry.js +8 -2
  59. package/dist/esm/ez-date-time-input.entry.js +8 -2
  60. package/dist/esm/ez-dialog.entry.js +9 -1
  61. package/dist/esm/ez-form.entry.js +2 -323
  62. package/dist/esm/ez-grid.entry.js +253 -61
  63. package/dist/esm/ez-list.entry.js +152 -101
  64. package/dist/esm/ez-number-input.entry.js +7 -0
  65. package/dist/esm/ez-popover.entry.js +1 -1
  66. package/dist/esm/ez-popup.entry.js +2 -9
  67. package/dist/esm/ez-search.entry.js +28 -12
  68. package/dist/esm/ez-text-area.entry.js +66 -4
  69. package/dist/esm/ez-text-input.entry.js +8 -3
  70. package/dist/esm/ez-time-input.entry.js +6 -0
  71. package/dist/esm/ezui.js +1 -1
  72. package/dist/esm/loader.js +1 -1
  73. package/dist/ezui/ezui.esm.js +1 -1
  74. package/dist/ezui/p-03a2c7d1.entry.js +1 -0
  75. package/dist/ezui/p-0a75bb05.entry.js +1 -0
  76. package/dist/ezui/p-0db68715.entry.js +1 -0
  77. package/dist/ezui/p-19098a3f.entry.js +1 -0
  78. package/dist/ezui/p-1f830a2f.entry.js +1 -0
  79. package/dist/ezui/p-3dd919b7.entry.js +1 -0
  80. package/dist/ezui/p-7bfae0fc.entry.js +1 -0
  81. package/dist/ezui/p-81f06699.js +1 -0
  82. package/dist/ezui/p-97af4b13.entry.js +1 -0
  83. package/dist/ezui/p-9ceefe4d.entry.js +1 -0
  84. package/dist/ezui/p-a80b1287.entry.js +1 -0
  85. package/dist/ezui/{p-c3c3d640.entry.js → p-b0a5c2cd.entry.js} +2 -2
  86. package/dist/ezui/p-b54e17d2.entry.js +1 -0
  87. package/dist/ezui/p-bfad39eb.entry.js +1 -0
  88. package/dist/ezui/p-d0ca26fe.entry.js +1 -0
  89. package/dist/ezui/p-dc628ed3.js +1 -0
  90. package/dist/ezui/p-ffd246f5.entry.js +1 -0
  91. package/dist/types/components/ez-combo-box/ez-combo-box.d.ts +7 -1
  92. package/dist/types/components/ez-date-input/ez-date-input.d.ts +6 -1
  93. package/dist/types/components/ez-date-time-input/ez-date-time-input.d.ts +6 -1
  94. package/dist/types/components/ez-dialog/ez-dialog.d.ts +2 -0
  95. package/dist/types/components/ez-filter-input/ez-filter-input.d.ts +4 -11
  96. package/dist/types/components/ez-grid/controller/EzGridController.d.ts +10 -0
  97. package/dist/types/components/ez-grid/controller/ag-grid/AgGridController.d.ts +4 -0
  98. package/dist/types/components/ez-grid/controller/ag-grid/GridEditionManager.d.ts +18 -6
  99. package/dist/types/components/ez-grid/controller/ag-grid/components/EzGridCustomCellEditor.d.ts +2 -0
  100. package/dist/types/components/ez-grid/controller/ag-grid/editor/IUICellEditor.d.ts +1 -0
  101. package/dist/types/components/ez-grid/ez-grid.d.ts +10 -0
  102. package/dist/types/components/ez-list/ez-list.d.ts +3 -26
  103. package/dist/types/components/ez-number-input/ez-number-input.d.ts +4 -0
  104. package/dist/types/components/ez-popup/ez-popup.d.ts +2 -2
  105. package/dist/types/components/ez-search/ez-search.d.ts +6 -1
  106. package/dist/types/components/ez-text-area/ez-text-area.d.ts +17 -0
  107. package/dist/types/components/ez-text-input/ez-text-input.d.ts +4 -0
  108. package/dist/types/components/ez-time-input/ez-time-input.d.ts +4 -0
  109. package/dist/types/components.d.ts +101 -44
  110. package/dist/types/utils/FocusResolver.d.ts +5 -0
  111. package/dist/types/utils/form/DataBinder.d.ts +3 -0
  112. package/package.json +1 -1
  113. package/dist/cjs/RecordValidationProcessor-10846595.js +0 -108
  114. package/dist/esm/RecordValidationProcessor-9c6cc267.js +0 -105
  115. package/dist/ezui/p-188f1c4c.entry.js +0 -1
  116. package/dist/ezui/p-25ac5376.entry.js +0 -1
  117. package/dist/ezui/p-49456b34.entry.js +0 -1
  118. package/dist/ezui/p-5a90d7d1.entry.js +0 -1
  119. package/dist/ezui/p-62732269.entry.js +0 -1
  120. package/dist/ezui/p-86b6aa01.entry.js +0 -1
  121. package/dist/ezui/p-b3b94f72.entry.js +0 -1
  122. package/dist/ezui/p-b95632e8.entry.js +0 -1
  123. package/dist/ezui/p-bcd47eda.entry.js +0 -1
  124. package/dist/ezui/p-d2c06f38.entry.js +0 -1
  125. package/dist/ezui/p-dc4ada32.entry.js +0 -1
  126. package/dist/ezui/p-e85c48d7.entry.js +0 -1
  127. package/dist/ezui/p-f299c608.entry.js +0 -1
  128. package/dist/ezui/p-f42855b9.js +0 -1
  129. package/dist/ezui/p-f80ac647.entry.js +0 -1
@@ -10,7 +10,8 @@ require('./DialogType-2114c337.js');
10
10
  require('./CheckMode-ecb90b87.js');
11
11
  const ICustomRender = require('./ICustomRender-6fafffce.js');
12
12
  const constants = require('./constants-2714478b.js');
13
- const RecordValidationProcessor = require('./RecordValidationProcessor-10846595.js');
13
+ const DataBinder = require('./DataBinder-aff1dcc7.js');
14
+ const FocusResolver = require('./FocusResolver-885f2173.js');
14
15
 
15
16
  /**
16
17
  * @ag-grid-community/all-modules - Advanced Data Grid / Data Table supporting Javascript / Typescript / React / Angular / Vue * @version v28.2.1
@@ -118857,12 +118858,14 @@ class DataSource {
118857
118858
  this._controller.clearInvalidCells();
118858
118859
  this.handleRefreshOrReload(action);
118859
118860
  this._controller.processContinuousInsert();
118861
+ this._controller.showSelectionColumn();
118860
118862
  }
118861
118863
  handleEditionCanceled(action) {
118862
118864
  if (this._options.enableGridInsert) {
118863
118865
  this._controller.processEditionCanceled();
118864
118866
  }
118865
118867
  this.handleRefreshOrReload(action);
118868
+ this._controller.showSelectionColumn();
118866
118869
  }
118867
118870
  handleSavingCanceled(action) {
118868
118871
  var _a, _b, _c, _d;
@@ -118917,6 +118920,7 @@ class DataSource {
118917
118920
  }
118918
118921
  handleRecordsAdded() {
118919
118922
  if (this._options.enableGridInsert) {
118923
+ this._controller.hideSelectionColumn();
118920
118924
  this._controller.refresh();
118921
118925
  this.focusOnNewRecord();
118922
118926
  }
@@ -119337,18 +119341,20 @@ const gridTerms = {
119337
119341
  };
119338
119342
 
119339
119343
  const buildEditorMetadata = (descriptor, eGridCell, dataUnit, editionManager) => {
119340
- return Object.assign(Object.assign({}, RecordValidationProcessor.buildFieldMetadata(descriptor)), { eGridCell, dataUnit, editionManager });
119344
+ return Object.assign(Object.assign({}, DataBinder.buildFieldMetadata(descriptor)), { eGridCell, dataUnit, editionManager });
119341
119345
  };
119342
119346
 
119343
119347
  const MINIMIUM_WIDTH_TEXTAREA = 210;
119344
119348
  const PADDING_VALUE_TEXTAREA = 12;
119345
119349
  const buildTextInput = ({ name, contextName }) => {
119346
- return core.HTMLBuilder.parseElement(`<ez-text-input
119350
+ const textInput = core.HTMLBuilder.parseElement(`<ez-text-input
119347
119351
  class="ez-grid grid_editor"
119348
119352
  data-field-name=${name}
119349
119353
  data-context-name=${contextName}
119350
119354
  mode="slim"
119351
119355
  />`);
119356
+ textInput.autoFocus = true;
119357
+ return textInput;
119352
119358
  };
119353
119359
  const buildTextAreaInput = ({ eGridCell, editionManager }) => {
119354
119360
  const element = core.HTMLBuilder.parseElement(`<ez-text-area
@@ -119358,6 +119364,7 @@ const buildTextAreaInput = ({ eGridCell, editionManager }) => {
119358
119364
  element.addEventListener('keydown', event => handlePressEnterEvent(event, element, editionManager));
119359
119365
  setElementInitialWidth(eGridCell, element);
119360
119366
  element.isPopUp = true;
119367
+ element.autoFocus = true;
119361
119368
  return element;
119362
119369
  };
119363
119370
  function setElementInitialWidth(eGridCell, element) {
@@ -119389,6 +119396,7 @@ const buildDate = () => {
119389
119396
  data-is-fixed="true"
119390
119397
  />`);
119391
119398
  dateInput.valueGetter = () => dateInput.getValueAsync();
119399
+ dateInput.autoFocus = true;
119392
119400
  return dateInput;
119393
119401
  };
119394
119402
  const buildTime = ({ readOnly }) => {
@@ -119439,6 +119447,7 @@ function buildNumeric(readOnly, precision, prettyPrecision) {
119439
119447
  mode="slim"
119440
119448
  />`);
119441
119449
  input.valueGetter = () => input.getValueAsync();
119450
+ input.autoFocus = true;
119442
119451
  return input;
119443
119452
  }
119444
119453
 
@@ -119472,6 +119481,7 @@ const buildComboBox = ({ required, props, eGridCell }) => {
119472
119481
  combo.options = options;
119473
119482
  combo.stopPropagateEnterKeyEvent = true;
119474
119483
  combo.listOptionsPosition = { verticalPosition: 29, bottomLimit: getViewPortHeight(eGridCell), hardPosition: true };
119484
+ combo.autoFocus = true;
119475
119485
  return combo;
119476
119486
  };
119477
119487
  const buildSwitch = (fieldMetadata) => {
@@ -119504,6 +119514,7 @@ const buildSearch = ({ name, required, readOnly, eGridCell, dataUnit }) => {
119504
119514
  ezSearch.suppressPreLoad = true;
119505
119515
  ezSearch.listOptionsPosition = { verticalPosition: 29, bottomLimit: getViewPortHeight(eGridCell), hardPosition: true };
119506
119516
  ezSearch.stopPropagateEnterKeyEvent = true;
119517
+ ezSearch.autoFocus = true;
119507
119518
  ezSearch.valueGetter = () => ezSearch.getValueAsync();
119508
119519
  return ezSearch;
119509
119520
  };
@@ -119629,6 +119640,12 @@ class EzGridCustomCellEditor extends EzCellEditor {
119629
119640
  return this._customGui.value;
119630
119641
  return this._value;
119631
119642
  }
119643
+ afterGuiAttached() {
119644
+ this.focusIn();
119645
+ }
119646
+ focusIn() {
119647
+ FocusResolver.FocusResolver.resolveFocus(this._customGui);
119648
+ }
119632
119649
  }
119633
119650
 
119634
119651
  class EzCellRender {
@@ -119710,11 +119727,11 @@ class EzGridCustomCellRender extends EzCellRender {
119710
119727
  }
119711
119728
 
119712
119729
  class GridEditionManager {
119713
- constructor(dataUnit, useEnterLikeTab, recordsValidator, editionIsDisabled, customEditors, customRenders, enableContinuousInsert, enableGridInsert) {
119730
+ constructor(dataUnit, useEnterLikeTab, recordsValidator, editionIsDisabled, customEditors, customRenders, enableContinuousInsert, enableGridInsert, lockerId) {
119714
119731
  this._dataUnit = dataUnit;
119715
- this._recordValidationProcessor = new RecordValidationProcessor.RecordValidationProcessor(this._dataUnit, {
119732
+ this._recordValidationProcessor = new DataBinder.RecordValidationProcessor(this._dataUnit, {
119716
119733
  getRequiredFields: () => this.getRequiredFields(),
119717
- markAsInvalid: (invalidField, recordId) => { this.setInvalidCell(invalidField, recordId); },
119734
+ markAsInvalid: (invalidField, recordId) => { this.pushInvalidCell(invalidField, recordId); },
119718
119735
  getMessageForField: () => null,
119719
119736
  }, recordsValidator);
119720
119737
  this._useEnterLikeTab = useEnterLikeTab;
@@ -119723,16 +119740,34 @@ class GridEditionManager {
119723
119740
  this._enableGridInsert = enableGridInsert;
119724
119741
  this._customEditors = customEditors;
119725
119742
  this._customRenders = customRenders;
119743
+ this._lockerId = lockerId;
119726
119744
  }
119727
119745
  configureGrid(options) {
119728
119746
  this._gridOptions = options;
119729
119747
  options.readOnlyEdit = true;
119730
119748
  options.onCellEditRequest = evt => this.onCellEditRequest(evt);
119749
+ options.onCellEditingStarted = async (evt) => {
119750
+ var _a;
119751
+ if (this._dataUnit.hasNewRecord()) {
119752
+ this.handleCellEditingStartedRowAdd(evt);
119753
+ }
119754
+ else {
119755
+ this._lastCellOpened = this._lastCellEdited = { rowIndex: evt.rowIndex, column: evt.column, rowPinned: undefined };
119756
+ }
119757
+ (_a = this._currentEditLock) === null || _a === void 0 ? void 0 : _a.call(this);
119758
+ this._currentEditLock = core.LockManager.lock(this._lockerId, core.LockManagerOperation.TASKBAR_CLICK);
119759
+ };
119760
+ options.onCellEditingStopped = () => {
119761
+ var _a;
119762
+ (_a = this._currentEditLock) === null || _a === void 0 ? void 0 : _a.call(this);
119763
+ };
119731
119764
  options.onCellKeyDown = evt => {
119732
119765
  if (evt.event && evt["column"]) {
119733
119766
  this.onCellKeyDown(evt);
119734
119767
  }
119735
119768
  };
119769
+ options.isRowSelectable = (node) => this.isSelectableRow(node);
119770
+ options.onCellFocused = () => this.lockFocusWhenAddRow();
119736
119771
  return options;
119737
119772
  }
119738
119773
  updateCurrentEditorGuiValue(updatedRowValue) {
@@ -119745,37 +119780,82 @@ class GridEditionManager {
119745
119780
  const value = updatedRowValue[fieldName];
119746
119781
  currentEditor.setGuiValue(value);
119747
119782
  }
119783
+ lockFocusWhenAddRow() {
119784
+ var _a, _b, _c, _d;
119785
+ const api = this._gridOptions.api;
119786
+ const newFocusCell = api.getFocusedCell();
119787
+ const rowIndex = newFocusCell === null || newFocusCell === void 0 ? void 0 : newFocusCell.rowIndex;
119788
+ const recordId = (_b = (_a = this._dataUnit.getAddedRecords()) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.__record__id__;
119789
+ const rowNode = api.getRowNode(recordId);
119790
+ if (!this._dataUnit.hasNewRecord() || rowIndex == (rowNode === null || rowNode === void 0 ? void 0 : rowNode.rowIndex)) {
119791
+ return;
119792
+ }
119793
+ const lastCell = (_d = (_c = this._lastCellOpened) !== null && _c !== void 0 ? _c : this._lastCellEdited) !== null && _d !== void 0 ? _d : this._lastCellClicked;
119794
+ if ((lastCell === null || lastCell === void 0 ? void 0 : lastCell.rowIndex) < (rowNode === null || rowNode === void 0 ? void 0 : rowNode.rowIndex)) {
119795
+ return;
119796
+ }
119797
+ api.clearFocusedCell();
119798
+ if (!lastCell || (rowNode === null || rowNode === void 0 ? void 0 : rowNode.rowIndex) == undefined) {
119799
+ return;
119800
+ }
119801
+ lastCell.rowIndex = rowNode === null || rowNode === void 0 ? void 0 : rowNode.rowIndex;
119802
+ this.focusOnCell(lastCell);
119803
+ }
119804
+ handleCellEditingStartedRowAdd(evt) {
119805
+ var _a, _b, _c, _d, _e;
119806
+ const nodeId = (_a = evt.node) === null || _a === void 0 ? void 0 : _a.id;
119807
+ const addedRecordId = (_c = (_b = this._dataUnit.getAddedRecords()) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.__record__id__;
119808
+ if (nodeId == addedRecordId) {
119809
+ this._lastCellOpened = this._lastCellEdited = { rowIndex: evt.rowIndex, column: evt === null || evt === void 0 ? void 0 : evt.column, rowPinned: undefined };
119810
+ return;
119811
+ }
119812
+ evt.api.stopEditing();
119813
+ const rowIndex = (_d = evt.api.getRowNode(addedRecordId)) === null || _d === void 0 ? void 0 : _d.rowIndex;
119814
+ this._lastCellOpened = this._lastCellEdited = { rowIndex: rowIndex, column: (_e = this._lastCellEdited) === null || _e === void 0 ? void 0 : _e.column, rowPinned: undefined };
119815
+ }
119816
+ isSelectableRow(node) {
119817
+ if (!this._dataUnit.hasNewRecord()) {
119818
+ return true;
119819
+ }
119820
+ if (!this._dataUnit.isNewRecord(node.id)) {
119821
+ return false;
119822
+ }
119823
+ return true;
119824
+ }
119748
119825
  canContinuousInsert() {
119749
119826
  var _a;
119750
119827
  return this._enableContinuousInsert && (this._dataUnit.records.length - 1) === ((_a = this._lastCellEdited) === null || _a === void 0 ? void 0 : _a.rowIndex);
119751
119828
  }
119752
- proceedAutoSave() {
119829
+ async proceedAutoSave() {
119753
119830
  if (!this._dataUnit.isDirty()) {
119754
119831
  this.saveSuccess();
119755
- return;
119832
+ return true;
119756
119833
  }
119757
- if (!this._isGridEdition) {
119758
- return;
119834
+ const currentRecord = this._dataUnit.getSelectedRecord();
119835
+ if (currentRecord == undefined) {
119836
+ return true;
119759
119837
  }
119760
- const currentRercord = this._dataUnit.getSelectedRecord();
119761
- if (currentRercord == undefined) {
119762
- return;
119838
+ this.clearInvalidCells(false);
119839
+ try {
119840
+ await this._recordValidationProcessor.validate(true);
119841
+ await this.saveDataUnit();
119842
+ this.saveSuccess();
119843
+ return true;
119844
+ }
119845
+ catch (reason) {
119846
+ this.saveFail(reason);
119847
+ return false;
119763
119848
  }
119764
- this._invalidCell = undefined;
119765
- this._recordValidationProcessor
119766
- .validate(true)
119767
- .then(() => {
119768
- this._dataUnit.saveData()
119769
- .then(() => this.saveSuccess())
119770
- .catch(reason => this.saveFail(reason));
119771
- })
119772
- .catch(reason => this.saveFail(reason));
119849
+ }
119850
+ async saveDataUnit() {
119851
+ await this._dataUnit.saveData();
119852
+ return true;
119773
119853
  }
119774
119854
  async recordValidate() {
119775
119855
  if (!this._dataUnit.isDirty())
119776
119856
  return;
119777
119857
  try {
119778
- this._invalidCell = undefined;
119858
+ this.clearInvalidCells(false);
119779
119859
  await this._recordValidationProcessor.validate(false);
119780
119860
  }
119781
119861
  catch (error) { }
@@ -119803,6 +119883,13 @@ class GridEditionManager {
119803
119883
  return { ezCellEditor: EzCellEditor };
119804
119884
  }
119805
119885
  verifyClickToEdition(api, cellClicked) {
119886
+ var _a, _b;
119887
+ const selectedRecordID = (_a = this._dataUnit.getSelectedRecord()) === null || _a === void 0 ? void 0 : _a.__record__id__;
119888
+ if (this._dataUnit.hasNewRecord() && selectedRecordID) {
119889
+ const dataUnitRecordIndex = (_b = api.getRowNode(selectedRecordID)) === null || _b === void 0 ? void 0 : _b.rowIndex;
119890
+ if (dataUnitRecordIndex != cellClicked.rowIndex)
119891
+ return;
119892
+ }
119806
119893
  if (this.isSecondClick(cellClicked)) {
119807
119894
  api.startEditingCell({ rowIndex: cellClicked.rowIndex, colKey: cellClicked.column.getColId() });
119808
119895
  }
@@ -119812,6 +119899,9 @@ class GridEditionManager {
119812
119899
  col.cellEditor = 'ezCellEditor';
119813
119900
  col.editable = params => this.canEdit(params);
119814
119901
  col.suppressKeyboardEvent = (params) => {
119902
+ if (params.event.key === KeyCode.ESCAPE && params.editing) {
119903
+ return this._dataUnit.isDirty();
119904
+ }
119815
119905
  return params.event.key === KeyCode.ENTER;
119816
119906
  };
119817
119907
  col.cellEditorSelector = (params) => {
@@ -119841,10 +119931,21 @@ class GridEditionManager {
119841
119931
  return col;
119842
119932
  }
119843
119933
  getRequiredFields() {
119844
- return this._gridOptions.columnApi.getAllDisplayedColumns().filter(c => {
119845
- const fieldDefinition = this._dataUnit.getField(c.getColId());
119846
- return fieldDefinition && fieldDefinition.required;
119847
- }).map(c => c.getColId());
119934
+ const formRequiredFields = this.getFormRequiredFields();
119935
+ return this._gridOptions.columnApi.getAllDisplayedColumns()
119936
+ .filter(column => {
119937
+ const fieldDefinition = this._dataUnit.getField(column.getColId());
119938
+ return (fieldDefinition && fieldDefinition.required) || formRequiredFields.includes(column.getColId());
119939
+ })
119940
+ .map(column => column.getColId());
119941
+ }
119942
+ getFormRequiredFields() {
119943
+ const formRequiredFields = [];
119944
+ const dataBinders = DataBinder.DataBinder.getDataBindersByDataUnit(this._dataUnit);
119945
+ dataBinders.forEach(dataBinder => {
119946
+ formRequiredFields.push(...dataBinder.getFormRequiredFields());
119947
+ });
119948
+ return formRequiredFields;
119848
119949
  }
119849
119950
  saveSuccess() {
119850
119951
  var _a;
@@ -119857,10 +119958,11 @@ class GridEditionManager {
119857
119958
  this._isGridEdition = false;
119858
119959
  }
119859
119960
  saveFail(reason) {
119860
- this.focusOnCell(this._lastCellEdited);
119961
+ var _a;
119962
+ this.focusOnCell((_a = this._lastCellOpened) !== null && _a !== void 0 ? _a : this._lastCellEdited);
119861
119963
  this._isGridEdition = false;
119862
119964
  if (reason) {
119863
- Promise.reject(reason);
119965
+ throw reason;
119864
119966
  }
119865
119967
  }
119866
119968
  focusOnCell(cell) {
@@ -119925,6 +120027,9 @@ class GridEditionManager {
119925
120027
  this.moveEditionVertically(api, 1);
119926
120028
  }
119927
120029
  moveEditionVertically(api, offset) {
120030
+ if (this._dataUnit.hasNewRecord() && this._isGridEdition) {
120031
+ return;
120032
+ }
119928
120033
  const editionCell = api.getEditingCells()[0];
119929
120034
  if (!editionCell) {
119930
120035
  return;
@@ -119969,41 +120074,66 @@ class GridEditionManager {
119969
120074
  return true;
119970
120075
  }
119971
120076
  onCellEditRequest(event) {
119972
- const fieldName = event.colDef.field;
120077
+ var _a;
119973
120078
  const value = event.newValue;
119974
- if (event.oldValue != value) {
119975
- if (value instanceof Promise) {
119976
- const fieldDescriptor = this._dataUnit.getField(event.colDef.colId);
119977
- event.node.setData(Object.assign(Object.assign({}, event.data), { [fieldName]: (fieldDescriptor === null || fieldDescriptor === void 0 ? void 0 : fieldDescriptor.userInterface) === core.UserInterface.SEARCH ? value : event.oldValue }));
119978
- value.then(resolved => event.node.setData(Object.assign(Object.assign({}, event.data), { [fieldName]: resolved })));
119979
- }
119980
- else {
119981
- event.node.setData(Object.assign(Object.assign({}, event.data), { [fieldName]: value }));
119982
- }
120079
+ if (event.oldValue == value) {
120080
+ (_a = this._currentEditLock) === null || _a === void 0 ? void 0 : _a.call(this);
120081
+ return;
120082
+ }
120083
+ if (value instanceof Promise) {
120084
+ this.handlePromiseValue(event, value);
120085
+ return;
120086
+ }
120087
+ this.updateCellValue(event, value);
120088
+ }
120089
+ async handlePromiseValue(event, value) {
120090
+ const fieldName = event.colDef.field;
120091
+ const fieldDescriptor = this._dataUnit.getField(event.colDef.colId);
120092
+ const initialValue = (fieldDescriptor === null || fieldDescriptor === void 0 ? void 0 : fieldDescriptor.userInterface) === core.UserInterface.SEARCH ? value : event.oldValue;
120093
+ event.node.setData(Object.assign(Object.assign({}, event.data), { [fieldName]: initialValue }));
120094
+ const resolved = await value;
120095
+ return this.updateCellValue(event, resolved);
120096
+ }
120097
+ updateCellValue(event, newValue) {
120098
+ var _a;
120099
+ const fieldName = event.colDef.field;
120100
+ event.node.setData(Object.assign(Object.assign({}, event.data), { [fieldName]: newValue }));
120101
+ (_a = this._currentEditLock) === null || _a === void 0 ? void 0 : _a.call(this);
120102
+ if (event.oldValue !== newValue) {
119983
120103
  this._isGridEdition = true;
119984
- this._dataUnit.setFieldValue(fieldName, value, [event.data.__record__id__], { suppressCreateNewRecord: true });
120104
+ this._dataUnit.setFieldValue(fieldName, newValue, [event.data.__record__id__], { suppressCreateNewRecord: true });
119985
120105
  this._lastCellEdited = { rowIndex: event.rowIndex, column: event.column, rowPinned: undefined };
119986
120106
  }
119987
120107
  }
119988
120108
  setCellEditors(customEditors) {
120109
+ var _a, _b;
119989
120110
  this._customEditors = customEditors;
120111
+ if (!customEditors.has((_b = (_a = this._lastCellOpened) === null || _a === void 0 ? void 0 : _a.column) === null || _b === void 0 ? void 0 : _b.getColId()))
120112
+ return;
120113
+ this._gridOptions.api.stopEditing();
120114
+ window.requestAnimationFrame(() => this.focusOnCell(this._lastCellOpened));
119990
120115
  }
119991
120116
  setCellRenders(customRenders) {
119992
120117
  this._customRenders = customRenders;
119993
120118
  }
119994
- setInvalidCell(invalidCell, recordId) {
119995
- this._invalidCell = { field: invalidCell, recordId };
120119
+ pushInvalidCell(invalidField, recordId) {
120120
+ this._invalidCells.push({ field: invalidField, recordId });
120121
+ this._nextInvalidCell = this._invalidCells[0];
119996
120122
  }
119997
- getInvalidCell() {
119998
- return this._invalidCell;
120123
+ getInvalidCells() {
120124
+ return this._invalidCells;
119999
120125
  }
120000
- processContinuousInsert() {
120126
+ getNextInvalidCell() {
120127
+ return this._nextInvalidCell;
120128
+ }
120129
+ async processContinuousInsert() {
120001
120130
  if (!this.canContinuousInsert())
120002
120131
  return;
120003
120132
  this._dataUnit.addRecord();
120004
120133
  }
120005
120134
  clearInvalidCells(stopEdition) {
120006
- this._invalidCell = undefined;
120135
+ this._invalidCells = [];
120136
+ this._nextInvalidCell = undefined;
120007
120137
  if (stopEdition) {
120008
120138
  this._isGridEdition = false;
120009
120139
  }
@@ -120014,10 +120144,17 @@ class GridEditionManager {
120014
120144
  hasInvalidField(fieldName, recordId) {
120015
120145
  if (!this.hasInvalidCell())
120016
120146
  return false;
120017
- return this._invalidCell.field.name === fieldName && this._invalidCell.recordId === recordId;
120147
+ this._nextInvalidCell = this._invalidCells[0];
120148
+ const containsFieldName = this._nextInvalidCell.field.name === fieldName;
120149
+ const containsRecordId = this._nextInvalidCell.recordId === recordId;
120150
+ return containsFieldName && containsRecordId;
120018
120151
  }
120019
120152
  hasInvalidCell() {
120020
- if (!this._invalidCell || !this._invalidCell.field || !this._invalidCell.recordId)
120153
+ var _a, _b, _c;
120154
+ const hasInvalidCell = ((_a = this._invalidCells) === null || _a === void 0 ? void 0 : _a.length) > 0;
120155
+ const hasField = (_b = this._invalidCells) === null || _b === void 0 ? void 0 : _b.filter(invalidCell => { });
120156
+ const hasRecordId = (_c = this._invalidCells) === null || _c === void 0 ? void 0 : _c.filter(invalidCell => { });
120157
+ if (!hasInvalidCell || !hasField || !hasRecordId)
120021
120158
  return false;
120022
120159
  return true;
120023
120160
  }
@@ -120144,6 +120281,7 @@ class AgGridController {
120144
120281
  var _a;
120145
120282
  this._options = options;
120146
120283
  this._container = container;
120284
+ const lockerId = options.enableLockManger ? core.LockManager.addLockManagerCtxId(this._container) : null;
120147
120285
  if (this._grid === undefined) {
120148
120286
  LicenseManager.setLicenseKey(core.ApplicationContext.getContextValue('__EZUI__GRID_LICENSE__'));
120149
120287
  this._columnStateChangeCallback = options.onColumnStateChange;
@@ -120151,7 +120289,7 @@ class AgGridController {
120151
120289
  this._doubleClickCallBack = options.onDoubleClick;
120152
120290
  this._multipleSelection = options.allowMultipleSelection;
120153
120291
  this._dataUnit = options.dataUnit;
120154
- this._editionManager = new GridEditionManager(this._dataUnit, options.useEnterLikeTab, options.recordsValidator, options.editionIsDisabled, options.customEditors || this._customEditors, options.customRenders || this._customRenders, options.enableContinuousInsert, options.enableGridInsert);
120292
+ 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);
120155
120293
  this._statusResolver = options.statusResolver;
120156
120294
  if (this._dataUnit) {
120157
120295
  this._dataUnit.sortingProvider = this;
@@ -120514,7 +120652,7 @@ class AgGridController {
120514
120652
  r.setData(data);
120515
120653
  });
120516
120654
  this._gridOptions.api.refreshCells({ force: true });
120517
- const invalidCell = this._editionManager.getInvalidCell();
120655
+ const invalidCell = this._editionManager.getNextInvalidCell();
120518
120656
  if (invalidCell) {
120519
120657
  const rowNode = this._gridOptions.api.getRowNode(invalidCell.recordId);
120520
120658
  if (rowNode && invalidCell.field) {
@@ -120534,6 +120672,7 @@ class AgGridController {
120534
120672
  if (this._grid === undefined) {
120535
120673
  throw new Error('Erro interno: Grid ainda não inicializado.');
120536
120674
  }
120675
+ this._gridOptions.api.clearRangeSelection();
120537
120676
  this._gridOptions.api.refreshServerSide({ purge: true });
120538
120677
  this._options.onRefresh();
120539
120678
  if (scrollToSelectedRow)
@@ -120556,12 +120695,15 @@ class AgGridController {
120556
120695
  }
120557
120696
  setFocus() {
120558
120697
  var _a, _b;
120559
- if ((_b = (_a = this._dataUnit) === null || _a === void 0 ? void 0 : _a.records) === null || _b === void 0 ? void 0 : _b.length) {
120560
- this.setFocusFirstRow();
120561
- }
120562
- else {
120698
+ if (!((_b = (_a = this._dataUnit) === null || _a === void 0 ? void 0 : _a.records) === null || _b === void 0 ? void 0 : _b.length)) {
120563
120699
  this.focusOnGridContainer();
120700
+ return;
120701
+ }
120702
+ if (!this._dataUnit.getSelectedRecord()) {
120703
+ this.setFocusFirstRow();
120704
+ return;
120564
120705
  }
120706
+ this.syncSelectWithDataUnit();
120565
120707
  }
120566
120708
  setAutoFocus(autoFocus) {
120567
120709
  var _a;
@@ -120605,6 +120747,23 @@ class AgGridController {
120605
120747
  this.startEditionOnRowByIndex(newRowIndex);
120606
120748
  }
120607
120749
  }
120750
+ syncSelectWithDataUnit() {
120751
+ const rowNode = this._gridOptions.api.getRowNode(this._dataUnit.getSelectedRecord().__record__id__);
120752
+ if ((rowNode === null || rowNode === void 0 ? void 0 : rowNode.rowIndex) < 0)
120753
+ return;
120754
+ const rowRange = this._gridOptions.api.getCellRanges().find(row => row.startRow.rowIndex === rowNode.rowIndex);
120755
+ if ((rowRange === null || rowRange === void 0 ? void 0 : rowRange.columns.length) > 0) {
120756
+ if (this._dataUnit.hasNewRecord()) {
120757
+ this.startEdition(rowNode.rowIndex, rowRange.columns[0]);
120758
+ return;
120759
+ }
120760
+ this.focusByCollAndRow(rowRange.columns[0], rowNode.rowIndex);
120761
+ this._gridOptions.api.addCellRange({ rowStartIndex: rowNode.rowIndex, rowEndIndex: rowNode.rowIndex, columns: rowRange.columns });
120762
+ return;
120763
+ }
120764
+ this._gridOptions.api.clearRangeSelection();
120765
+ this.setFocusOnRow(rowNode.rowIndex);
120766
+ }
120608
120767
  startEdition(rowIndex, firstCol) {
120609
120768
  this._gridOptions.api.clearRangeSelection();
120610
120769
  this._gridOptions.api.addCellRange({ rowStartIndex: rowIndex, rowEndIndex: rowIndex, columns: [firstCol] });
@@ -120635,6 +120794,7 @@ class AgGridController {
120635
120794
  let displayedColumns = this._gridOptions.columnApi.getAllDisplayedColumns();
120636
120795
  let firstColl = displayedColumns.find(column => column.getColDef().headerName !== '');
120637
120796
  this.focusByCollAndRow(firstColl, rowIndex);
120797
+ this._gridOptions.api.addCellRange({ rowStartIndex: rowIndex, rowEndIndex: rowIndex, columns: [firstColl] });
120638
120798
  }
120639
120799
  focusByCollAndRow(firstCell, rowIndex) {
120640
120800
  this._gridOptions.api.ensureColumnVisible(firstCell);
@@ -120674,6 +120834,14 @@ class AgGridController {
120674
120834
  this._gridOptions.api.setColumnDefs(this._colDefs);
120675
120835
  }
120676
120836
  }
120837
+ hideSelectionColumn() {
120838
+ var _a, _b;
120839
+ (_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);
120840
+ }
120841
+ showSelectionColumn() {
120842
+ var _a, _b;
120843
+ (_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);
120844
+ }
120677
120845
  getColumnsDef() {
120678
120846
  if (this._grid === undefined) {
120679
120847
  throw new Error('Erro interno: Grid ainda não inicializado.');
@@ -120958,18 +121126,24 @@ class AgGridController {
120958
121126
  return false;
120959
121127
  }
120960
121128
  onSelectionChange(event) {
121129
+ var _a, _b;
121130
+ const selectedRowId = (_b = (_a = event.api.getSelectedNodes()) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.id;
121131
+ const isNewRecord = this._dataUnit.isNewRecord(selectedRowId);
120961
121132
  if (!this._selectionChangeCallback)
120962
121133
  return;
120963
121134
  clearTimeout(this._selectionChangeDeboucing);
120964
- this._selectionChangeDeboucing = window.setTimeout(() => {
120965
- this.handleExecuteProceedAutosave();
121135
+ this._selectionChangeDeboucing = window.setTimeout(async () => {
121136
+ const saveSuccess = (!isNewRecord && selectedRowId) ? await this.handleExecuteProceedAutosave() : true;
121137
+ if (!saveSuccess)
121138
+ return;
120966
121139
  this.processBuildSelectionChangeCallback(event);
120967
121140
  }, 0);
120968
121141
  }
120969
- handleExecuteProceedAutosave() {
121142
+ async handleExecuteProceedAutosave() {
120970
121143
  if (this._gridShowDom) {
120971
- this._editionManager.proceedAutoSave();
121144
+ return await this._editionManager.proceedAutoSave();
120972
121145
  }
121146
+ return true;
120973
121147
  }
120974
121148
  processBuildSelectionChangeCallback(event) {
120975
121149
  if (this._dataUnit) {
@@ -120994,7 +121168,7 @@ class AgGridController {
120994
121168
  });
120995
121169
  }
120996
121170
  onRowDoubleClick(evt) {
120997
- if (this._doubleClickCallBack) {
121171
+ if (this._doubleClickCallBack && (!this._options.enableGridInsert || !this._dataUnit.hasNewRecord())) {
120998
121172
  this._doubleClickCallBack(evt.data);
120999
121173
  }
121000
121174
  }
@@ -121010,13 +121184,11 @@ class AgGridController {
121010
121184
  }
121011
121185
  }
121012
121186
  setCellEditors(customEditors) {
121013
- var _a;
121014
121187
  if (!this._editionManager) {
121015
121188
  this._customEditors = customEditors;
121016
121189
  return;
121017
121190
  }
121018
121191
  this._editionManager.setCellEditors(customEditors);
121019
- (_a = this._gridOptions) === null || _a === void 0 ? void 0 : _a.api.redrawRows();
121020
121192
  }
121021
121193
  setCellRenders(customRenders) {
121022
121194
  var _a;
@@ -121039,6 +121211,9 @@ class AgGridController {
121039
121211
  destroy() {
121040
121212
  this.observer.disconnect();
121041
121213
  }
121214
+ stopEdit() {
121215
+ this._gridOptions.api.stopEditing();
121216
+ }
121042
121217
  }
121043
121218
 
121044
121219
  function enableSelectAll(total) {
@@ -121288,6 +121463,7 @@ const EzGrid = class {
121288
121463
  this.paginationCounterMode = 'show';
121289
121464
  this.enableGridInsert = false;
121290
121465
  this.enableContinuousInsert = true;
121466
+ this.enableLockManger = true;
121291
121467
  }
121292
121468
  /**
121293
121469
  * Aplica a definição de colunas.
@@ -121412,6 +121588,18 @@ const EzGrid = class {
121412
121588
  async setFocus() {
121413
121589
  this._gridController.setFocus();
121414
121590
  }
121591
+ /**
121592
+ * Para a edição da grade.
121593
+ */
121594
+ async stopEdit() {
121595
+ this._gridController.stopEdit();
121596
+ }
121597
+ async checkStopEditOutsideClick(event) {
121598
+ var _a;
121599
+ if ((_a = this._container) === null || _a === void 0 ? void 0 : _a.contains(event.target))
121600
+ return;
121601
+ this._gridController.stopEdit();
121602
+ }
121415
121603
  observeConfig(config) {
121416
121604
  this._gridController.setColumnsState(config === null || config === void 0 ? void 0 : config.columns);
121417
121605
  }
@@ -121437,6 +121625,9 @@ const EzGrid = class {
121437
121625
  this.setSelection(this.dataUnit.getSelectionInfo());
121438
121626
  }
121439
121627
  }
121628
+ async handleClick(event) {
121629
+ this.checkStopEditOutsideClick(event);
121630
+ }
121440
121631
  setSelection(selectionInfo) {
121441
121632
  var _a;
121442
121633
  this._selectionCount = (_a = selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.length) !== null && _a !== void 0 ? _a : 0;
@@ -121633,7 +121824,8 @@ const EzGrid = class {
121633
121824
  if (this.dataUnit) {
121634
121825
  this.setSelection(this.dataUnit.getSelectionInfo());
121635
121826
  }
121636
- }
121827
+ },
121828
+ enableLockManger: this.enableLockManger
121637
121829
  });
121638
121830
  if (this.config) {
121639
121831
  this.observeConfig(this.config);