@sankhyalabs/ezui 5.22.0-dev.20 → 5.22.0-dev.21

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 (33) hide show
  1. package/dist/cjs/{RecordValidationProcessor-4c893e04.js → RecordValidationProcessor-10846595.js} +7 -1
  2. package/dist/cjs/ez-form.cjs.entry.js +2 -2
  3. package/dist/cjs/ez-grid.cjs.entry.js +252 -15
  4. package/dist/cjs/ezui.cjs.js +1 -1
  5. package/dist/cjs/loader.cjs.js +1 -1
  6. package/dist/collection/components/ez-grid/controller/ag-grid/AgGridController.js +106 -4
  7. package/dist/collection/components/ez-grid/controller/ag-grid/DataSource.js +83 -5
  8. package/dist/collection/components/ez-grid/controller/ag-grid/GridEditionManager.js +57 -6
  9. package/dist/collection/components/ez-grid/controller/ag-grid/test/constants/GridEditionMock.js +1 -0
  10. package/dist/collection/components/ez-grid/ez-grid.js +42 -0
  11. package/dist/collection/utils/form/DataBinder.js +1 -1
  12. package/dist/collection/utils/validators/recordvalidator/IInvalidCells.js +1 -0
  13. package/dist/collection/utils/validators/recordvalidator/RecordValidationProcessor.js +7 -1
  14. package/dist/custom-elements/index.js +260 -17
  15. package/dist/esm/{RecordValidationProcessor-b00b8b77.js → RecordValidationProcessor-9c6cc267.js} +7 -1
  16. package/dist/esm/ez-form.entry.js +2 -2
  17. package/dist/esm/ez-grid.entry.js +252 -15
  18. package/dist/esm/ezui.js +1 -1
  19. package/dist/esm/loader.js +1 -1
  20. package/dist/ezui/ezui.esm.js +1 -1
  21. package/dist/ezui/{p-fcf0acce.entry.js → p-4d64a3e4.entry.js} +1 -1
  22. package/dist/ezui/{p-5ee2dc4e.entry.js → p-a9156fef.entry.js} +2 -2
  23. package/dist/ezui/p-f42855b9.js +1 -0
  24. package/dist/types/components/ez-grid/controller/EzGridController.d.ts +32 -4
  25. package/dist/types/components/ez-grid/controller/ag-grid/AgGridController.d.ts +19 -3
  26. package/dist/types/components/ez-grid/controller/ag-grid/DataSource.d.ts +18 -0
  27. package/dist/types/components/ez-grid/controller/ag-grid/GridEditionManager.d.ts +13 -2
  28. package/dist/types/components/ez-grid/ez-grid.d.ts +9 -0
  29. package/dist/types/components.d.ts +16 -0
  30. package/dist/types/utils/validators/recordvalidator/IInvalidCells.d.ts +5 -0
  31. package/dist/types/utils/validators/recordvalidator/RecordValidationProcessor.d.ts +1 -1
  32. package/package.json +1 -1
  33. package/dist/ezui/p-04f24913.js +0 -1
@@ -513,7 +513,7 @@ class RecordValidationProcessor {
513
513
  this._validationSource = validationSource;
514
514
  this._validator = validator;
515
515
  }
516
- validate() {
516
+ validate(isSaving = true) {
517
517
  return new Promise((accept, reject) => {
518
518
  const records = this._dataUnit.getModifiedRecords();
519
519
  for (let i = 0; i < records.length; i++) {
@@ -530,6 +530,11 @@ class RecordValidationProcessor {
530
530
  }
531
531
  }
532
532
  if (invalidResults.length > 0) {
533
+ if (!isSaving && invalidResults[0].invalidFields.length > 0) {
534
+ this._validationSource.markAsInvalid(invalidResults[0].invalidFields[0], record.__record__id__);
535
+ reject();
536
+ break;
537
+ }
533
538
  this.processValidationResult(invalidResults, record.__record__id__);
534
539
  reject();
535
540
  break;
@@ -561,6 +566,7 @@ class RecordValidationProcessor {
561
566
  processValidationResult(validationResult, recordId) {
562
567
  validationResult.forEach(invalidResult => {
563
568
  const invalidFields = invalidResult.invalidFields;
569
+ this._dataUnit.savingCanceled(invalidFields, recordId);
564
570
  if (invalidFields) {
565
571
  invalidFields.forEach(field => {
566
572
  this.markAsInvalid(field, recordId);
@@ -650,7 +656,7 @@ class DataBinder {
650
656
  this._recordValidatorProcessor = new RecordValidationProcessor(this._dataUnit, {
651
657
  getRequiredFields: () => this._formMetadata.getRequiredFields(),
652
658
  markAsInvalid: field => this.markInvalid(field),
653
- getMessageForField: field => this.getErrorMessage(field)
659
+ getMessageForField: field => this.getErrorMessage(field),
654
660
  }, recordsValidator);
655
661
  }
656
662
  disconnectDataUnit() {
@@ -124456,6 +124462,73 @@ class DataSourceInterceptor {
124456
124462
  }
124457
124463
 
124458
124464
  class DataSource {
124465
+ handleSavingCanceled(action) {
124466
+ var _a, _b, _c, _d;
124467
+ if (!((_a = action.payload) === null || _a === void 0 ? void 0 : _a.fields) || !((_b = action.payload) === null || _b === void 0 ? void 0 : _b.recordId))
124468
+ return;
124469
+ this._controller.savingCanceled((_c = action.payload) === null || _c === void 0 ? void 0 : _c.fields, (_d = action.payload) === null || _d === void 0 ? void 0 : _d.recordId);
124470
+ }
124471
+ handleDataChanged(action) {
124472
+ var _a, _b;
124473
+ if (!this._options.enableGridInsert) {
124474
+ this.handleRefresh(action);
124475
+ return;
124476
+ }
124477
+ this.updateGridRowNodes((_b = (_a = action.payload) === null || _a === void 0 ? void 0 : _a.records) !== null && _b !== void 0 ? _b : []);
124478
+ }
124479
+ /**
124480
+ * Nesse ponto, o registro já se encontra atualizado no DU,
124481
+ * basta então passar seu valor para que a garde possa atualizar sua linha.
124482
+ */
124483
+ updateGridRowNodes(recordIDList) {
124484
+ const recordsToUpdate = recordIDList === null || recordIDList === void 0 ? void 0 : recordIDList.map(id => this.getRecordById(id));
124485
+ this._controller.updateRows(recordsToUpdate);
124486
+ }
124487
+ getRecordById(recordId) {
124488
+ return this._dataUnit.records.find(record => record['__record__id__'] === recordId);
124489
+ }
124490
+ /**
124491
+ * Em caso de necessidade de reload (isWaitingToReload), eh preciso chamar o dataUnit.gotoPage, pois ele aplica tambem a ordenacao dos registros,
124492
+ * enquanto que o _controller.refresh apenas recarrega os dados na ordem que atua.
124493
+ */
124494
+ handleRefreshOrReload(action) {
124495
+ if (this._dataUnit.isWaitingToReload()) {
124496
+ this.handleReload();
124497
+ return;
124498
+ }
124499
+ this.handleRefresh(action);
124500
+ }
124501
+ handleReload() {
124502
+ this._dataUnit.setWaitingToReload(false);
124503
+ this._dataUnit.gotoPage(0);
124504
+ }
124505
+ handleRefresh(action) {
124506
+ if (this.isSilentChange(action)) {
124507
+ return;
124508
+ }
124509
+ this._controller.refresh(action.type === Action.DATA_SAVED);
124510
+ }
124511
+ handleRecordsAdded() {
124512
+ if (this._options.enableGridInsert) {
124513
+ this._controller.refresh();
124514
+ this.focusOnNewRecord();
124515
+ }
124516
+ }
124517
+ focusOnNewRecord() {
124518
+ /**
124519
+ * O SetTimeout eh utilizado pois é preciso aguardar que o novo registro seja renderizado na grade.
124520
+ * Tentamos utilizar a api da grade para adicionar um event listener, porém na versão que utilizamos, não existe
124521
+ * algo que resolva nosso cenário.
124522
+ *
124523
+ * Sugiro no futuro utilizar algo como o applyServerSideTransaction, porém será preciso lidar com os handlers
124524
+ * e callbacks implementados no AgGridController e GridEditionManager.
124525
+ */
124526
+ setTimeout(() => {
124527
+ var _a;
124528
+ const newRowIndex = ((_a = this._dataUnit.records) === null || _a === void 0 ? void 0 : _a.length) - 1;
124529
+ this._controller.startEditionOnRowByIndex(newRowIndex);
124530
+ }, 500);
124531
+ }
124459
124532
  updateLoadedRecords(action) {
124460
124533
  const records = action.payload;
124461
124534
  if ((records === null || records === void 0 ? void 0 : records.length) > 0) {
@@ -124507,15 +124580,20 @@ class DataSource {
124507
124580
  this._options.onPaginationUpdate(this._dataUnit.getPaginationInfo());
124508
124581
  }
124509
124582
  break;
124510
- case Action.RECORDS_REMOVED:
124583
+ case Action.RECORDS_ADDED:
124584
+ this.handleRecordsAdded();
124585
+ break;
124511
124586
  case Action.DATA_SAVED:
124512
124587
  case Action.EDITION_CANCELED:
124588
+ this._controller.clearInvalidCells(action.type);
124589
+ this.handleRefreshOrReload(action);
124590
+ break;
124513
124591
  case Action.DATA_CHANGED:
124514
124592
  case Action.DATA_RESOLVED:
124515
- if (this.isSilentChange(action)) {
124516
- return;
124517
- }
124518
- this._controller.refresh();
124593
+ this.handleDataChanged(action);
124594
+ break;
124595
+ case Action.RECORDS_REMOVED:
124596
+ this.handleRefresh(action);
124519
124597
  break;
124520
124598
  case Action.SELECTION_CHANGED:
124521
124599
  case Action.NEXT_SELECTED:
@@ -124525,6 +124603,9 @@ class DataSource {
124525
124603
  case Action.RECORD_LOADED:
124526
124604
  this.updateLoadedRecords(action);
124527
124605
  break;
124606
+ case Action.SAVING_CANCELED:
124607
+ this.handleSavingCanceled(action);
124608
+ break;
124528
124609
  }
124529
124610
  };
124530
124611
  this._dataUnit = dataUnit;
@@ -124546,6 +124627,9 @@ class DataSource {
124546
124627
  setAutoFocus(autoFocus) {
124547
124628
  this._options.autoFocus = autoFocus;
124548
124629
  }
124630
+ setEnableGridInsert(enable) {
124631
+ this._options.enableGridInsert = enable;
124632
+ }
124549
124633
  getRows(params) {
124550
124634
  if (this.needReload(params)) {
124551
124635
  this._lastLoadingParams = params;
@@ -125207,15 +125291,16 @@ class EzGridCustomCellRender extends EzCellRender {
125207
125291
  }
125208
125292
 
125209
125293
  class GridEditionManager {
125210
- constructor(dataUnit, useEnterLikeTab, recordsValidator, editionIsDisabled, customEditors, customRenders) {
125294
+ constructor(dataUnit, useEnterLikeTab, recordsValidator, editionIsDisabled, customEditors, customRenders, enableContinuousInsert) {
125211
125295
  this._dataUnit = dataUnit;
125212
125296
  this._recordValidationProcessor = new RecordValidationProcessor(this._dataUnit, {
125213
125297
  getRequiredFields: () => this.getRequiredFields(),
125214
- markAsInvalid: () => { },
125215
- getMessageForField: () => null
125298
+ markAsInvalid: (invalidField, recordId) => { this.setInvalidCell(invalidField, recordId); },
125299
+ getMessageForField: () => null,
125216
125300
  }, recordsValidator);
125217
125301
  this._useEnterLikeTab = useEnterLikeTab;
125218
125302
  this._editionIsDisabled = editionIsDisabled;
125303
+ this._enableContinuousInsert = enableContinuousInsert;
125219
125304
  this._customEditors = customEditors;
125220
125305
  this._customRenders = customRenders;
125221
125306
  }
@@ -125230,6 +125315,10 @@ class GridEditionManager {
125230
125315
  };
125231
125316
  return options;
125232
125317
  }
125318
+ canContinuousInsert() {
125319
+ var _a;
125320
+ return this._enableContinuousInsert && (this._dataUnit.records.length - 1) === ((_a = this._lastCellEdited) === null || _a === void 0 ? void 0 : _a.rowIndex);
125321
+ }
125233
125322
  proceedAutoSave() {
125234
125323
  if (!this._dataUnit.isDirty()) {
125235
125324
  this.saveSuccess();
@@ -125242,15 +125331,33 @@ class GridEditionManager {
125242
125331
  if (currentRercord == undefined) {
125243
125332
  return;
125244
125333
  }
125334
+ this._invalidCell = undefined;
125245
125335
  this._recordValidationProcessor
125246
- .validate()
125336
+ .validate(true)
125247
125337
  .then(() => {
125248
125338
  this._dataUnit.saveData()
125249
- .then(() => this.saveSuccess())
125339
+ .then(() => {
125340
+ if (this.canContinuousInsert()) {
125341
+ this._dataUnit.addRecord();
125342
+ }
125343
+ else {
125344
+ this.saveSuccess();
125345
+ }
125346
+ })
125250
125347
  .catch(reason => this.saveFail(reason));
125251
125348
  })
125252
125349
  .catch(reason => this.saveFail(reason));
125253
125350
  }
125351
+ async recordValidate() {
125352
+ if (!this._dataUnit.isDirty())
125353
+ return;
125354
+ try {
125355
+ this._invalidCell = undefined;
125356
+ await this._recordValidationProcessor.validate(false);
125357
+ }
125358
+ catch (error) { }
125359
+ this._gridOptions.api.refreshCells({ force: true });
125360
+ }
125254
125361
  navigateByEnterKey(keyboardEvent) {
125255
125362
  const backwards = keyboardEvent.shiftKey;
125256
125363
  if (this._useEnterLikeTab) {
@@ -125459,6 +125566,34 @@ class GridEditionManager {
125459
125566
  setCellRenders(customRenders) {
125460
125567
  this._customRenders = customRenders;
125461
125568
  }
125569
+ setInvalidCell(invalidCell, recordId) {
125570
+ this._invalidCell = { field: invalidCell, recordId };
125571
+ }
125572
+ getInvalidCell() {
125573
+ return this._invalidCell;
125574
+ }
125575
+ clearInvalidCells(action) {
125576
+ this._invalidCell = undefined;
125577
+ if (action === Action.EDITION_CANCELED) {
125578
+ this._isGridEdition = false;
125579
+ }
125580
+ else if (action === Action.DATA_SAVED && this.canContinuousInsert()) {
125581
+ this._dataUnit.addRecord();
125582
+ }
125583
+ }
125584
+ setEnableContinuousInsert(enable) {
125585
+ this._enableContinuousInsert = enable;
125586
+ }
125587
+ hasInvalidField(fieldName, recordId) {
125588
+ if (!this.hasInvalidCell())
125589
+ return false;
125590
+ return this._invalidCell.field.name === fieldName && this._invalidCell.recordId === recordId;
125591
+ }
125592
+ hasInvalidCell() {
125593
+ if (!this._invalidCell || !this._invalidCell.field || !this._invalidCell.recordId)
125594
+ return false;
125595
+ return true;
125596
+ }
125462
125597
  }
125463
125598
  class TargetEdition {
125464
125599
  constructor(rowIndex, column, backwards) {
@@ -125502,6 +125637,8 @@ class AgGridController {
125502
125637
  this._filteredColumns = new Map();
125503
125638
  this._filterColumnleftPosition = 0;
125504
125639
  this._customFormatters = new Map();
125640
+ this._gridShowDom = false;
125641
+ this.peddingExecutionsOnGridShow = [];
125505
125642
  this._enterprise = enterprise;
125506
125643
  }
125507
125644
  getGridConfig() {
@@ -125587,7 +125724,7 @@ class AgGridController {
125587
125724
  this._doubleClickCallBack = options.onDoubleClick;
125588
125725
  this._multipleSelection = options.allowMultipleSelection;
125589
125726
  this._dataUnit = options.dataUnit;
125590
- this._editionManager = new GridEditionManager(this._dataUnit, options.useEnterLikeTab, options.recordsValidator, options.editionIsDisabled, options.customEditors || this._customEditors, options.customRenders || this._customRenders);
125727
+ this._editionManager = new GridEditionManager(this._dataUnit, options.useEnterLikeTab, options.recordsValidator, options.editionIsDisabled, options.customEditors || this._customEditors, options.customRenders || this._customRenders, options.enableContinuousInsert);
125591
125728
  this._statusResolver = options.statusResolver;
125592
125729
  if (this._dataUnit) {
125593
125730
  this._dataUnit.sortingProvider = this;
@@ -125607,6 +125744,9 @@ class AgGridController {
125607
125744
  defaultColDef: {
125608
125745
  headerClass: 'ez-grid__cell-header',
125609
125746
  cellClass: 'ez-grid__cell-body',
125747
+ cellClassRules: {
125748
+ 'invalidValue': (params) => this._editionManager.hasInvalidField(params.colDef.field, params.data["__record__id__"]),
125749
+ },
125610
125750
  cellStyle: {
125611
125751
  height: '100%'
125612
125752
  }
@@ -125646,6 +125786,23 @@ class AgGridController {
125646
125786
  }
125647
125787
  this._gridOptions.api.setHeaderHeight(this.getHeaderRowHeight());
125648
125788
  this._customFormatters = options.customFormatters;
125789
+ const observerCallback = (entries) => {
125790
+ entries.forEach(entry => {
125791
+ if (entry.isIntersecting) {
125792
+ this._gridShowDom = true;
125793
+ this.peddingExecutionsOnGridShow.forEach(func => func());
125794
+ this.peddingExecutionsOnGridShow = [];
125795
+ }
125796
+ else {
125797
+ this._gridShowDom = false;
125798
+ }
125799
+ });
125800
+ };
125801
+ this.observer = new IntersectionObserver(observerCallback, {
125802
+ root: null,
125803
+ threshold: 0.1
125804
+ });
125805
+ this.observer.observe(container);
125649
125806
  }
125650
125807
  }
125651
125808
  processFormatterCellCallback(params) {
@@ -125836,10 +125993,16 @@ class AgGridController {
125836
125993
  throw new Error('Erro interno: Grid ainda não inicializado.');
125837
125994
  }
125838
125995
  }
125839
- updateRows() {
125996
+ updateRows(rows) {
125840
125997
  if (this._grid === undefined) {
125841
125998
  throw new Error('Erro interno: Grid ainda não inicializado.');
125842
125999
  }
126000
+ rows === null || rows === void 0 ? void 0 : rows.forEach(row => this.updateRowData(row));
126001
+ }
126002
+ updateRowData(row) {
126003
+ const node = this._gridOptions.api.getRowNode(row[this._idAttribName]);
126004
+ node.setData(Object.assign({}, row));
126005
+ this._editionManager.recordValidate();
125843
126006
  }
125844
126007
  selectAll(quietly = false) {
125845
126008
  try {
@@ -125922,14 +126085,42 @@ class AgGridController {
125922
126085
  });
125923
126086
  r.setData(data);
125924
126087
  });
126088
+ this._gridOptions.api.refreshCells({ force: true });
126089
+ const invalidCell = this._editionManager.getInvalidCell();
126090
+ if (invalidCell) {
126091
+ const rowNode = this._gridOptions.api.getRowNode(invalidCell.recordId);
126092
+ if (rowNode && invalidCell.field) {
126093
+ this.startEdition(rowNode.rowIndex, this._gridOptions.columnApi.getColumn(invalidCell.field.name));
126094
+ }
126095
+ }
125925
126096
  }
125926
126097
  }
125927
- refresh() {
126098
+ savingCanceled(fields, recordId) {
126099
+ const displayedColumns = this._gridOptions.columnApi.getAllDisplayedColumns();
126100
+ const rowIndex = this._gridOptions.api.getRowNode(recordId).rowIndex;
126101
+ const columnFocus = displayedColumns.find(column => this.isColumnEditable(rowIndex, column) && fields.find(field => field.name === column.getColId()));
126102
+ this.focusByCollAndRow(columnFocus, rowIndex);
126103
+ this.startEdition(rowIndex, columnFocus);
126104
+ }
126105
+ refresh(scrollToSelectedRow = false) {
125928
126106
  if (this._grid === undefined) {
125929
126107
  throw new Error('Erro interno: Grid ainda não inicializado.');
125930
126108
  }
125931
126109
  this._gridOptions.api.refreshServerSide({ purge: true });
125932
126110
  this._options.onRefresh();
126111
+ if (scrollToSelectedRow)
126112
+ this.scrollToSelectedRow();
126113
+ }
126114
+ scrollToSelectedRow() {
126115
+ const rowNode = this._gridOptions.api.getSelectedNodes();
126116
+ if (!rowNode || rowNode.length === 0)
126117
+ return;
126118
+ if (this._gridShowDom) {
126119
+ this._gridOptions.api.ensureNodeVisible(rowNode[0]);
126120
+ }
126121
+ else {
126122
+ this.peddingExecutionsOnGridShow.push(() => this._gridOptions.api.ensureNodeVisible(rowNode[0]));
126123
+ }
125933
126124
  }
125934
126125
  focusOnGridContainer() {
125935
126126
  this._container.setAttribute('tabindex', '-1');
@@ -125948,6 +126139,14 @@ class AgGridController {
125948
126139
  var _a;
125949
126140
  (_a = this._dataSource) === null || _a === void 0 ? void 0 : _a.setAutoFocus(autoFocus);
125950
126141
  }
126142
+ setEnableGridInsert(enable) {
126143
+ var _a;
126144
+ (_a = this._dataSource) === null || _a === void 0 ? void 0 : _a.setEnableGridInsert(enable);
126145
+ }
126146
+ setEnableContinuousInsert(enable) {
126147
+ var _a;
126148
+ (_a = this._editionManager) === null || _a === void 0 ? void 0 : _a.setEnableContinuousInsert(enable);
126149
+ }
125951
126150
  setFocusFirstRow() {
125952
126151
  const firstRow = this._gridOptions.api.getDisplayedRowAtIndex(0);
125953
126152
  if (firstRow) {
@@ -125963,9 +126162,38 @@ class AgGridController {
125963
126162
  this.setFocusOnRow(lastRow.rowIndex);
125964
126163
  }
125965
126164
  }
126165
+ startEditionOnRowByIndex(rowIndex) {
126166
+ const firstCol = this.getFirstEditableColl(rowIndex);
126167
+ this.focusByCollAndRow(firstCol, rowIndex);
126168
+ this.startEdition(rowIndex, firstCol);
126169
+ }
126170
+ startEdition(rowIndex, firstCol) {
126171
+ this._gridOptions.api.clearRangeSelection();
126172
+ this._gridOptions.api.addCellRange({ rowStartIndex: rowIndex, rowEndIndex: rowIndex, columns: [firstCol] });
126173
+ this._gridOptions.api.setFocusedCell(rowIndex, firstCol);
126174
+ this._gridOptions.api.startEditingCell({ rowIndex, colKey: firstCol });
126175
+ const cellEditor = this._gridOptions.api.getCellEditorInstances()[0];
126176
+ if (cellEditor) {
126177
+ cellEditor.focusIn();
126178
+ }
126179
+ }
126180
+ getFirstEditableColl(rowIndex) {
126181
+ const displayedColumns = this._gridOptions.columnApi.getAllDisplayedColumns();
126182
+ return displayedColumns.find(column => this.isColumnEditable(rowIndex, column));
126183
+ }
126184
+ isColumnEditable(rowIndex, column) {
126185
+ if (column.getColDef().headerName === '' || rowIndex === -1)
126186
+ return false;
126187
+ const rowId = this._dataUnit.records[rowIndex][this._idAttribName];
126188
+ const rowNode = this._gridOptions.api.getRowNode(rowId);
126189
+ return column.isCellEditable(rowNode);
126190
+ }
125966
126191
  setFocusOnRow(rowIndex) {
125967
126192
  let displayedColumns = this._gridOptions.columnApi.getAllDisplayedColumns();
125968
- let firstCell = displayedColumns.find(column => column.getColDef().headerName !== '');
126193
+ let firstColl = displayedColumns.find(column => column.getColDef().headerName !== '');
126194
+ this.focusByCollAndRow(firstColl, rowIndex);
126195
+ }
126196
+ focusByCollAndRow(firstCell, rowIndex) {
125969
126197
  this._gridOptions.api.ensureColumnVisible(firstCell);
125970
126198
  this._gridOptions.api.ensureIndexVisible(rowIndex);
125971
126199
  this._gridOptions.api.setFocusedCell(rowIndex, firstCell);
@@ -126345,6 +126573,15 @@ class AgGridController {
126345
126573
  this._editionManager.setCellRenders(customRenders);
126346
126574
  (_a = this._gridOptions) === null || _a === void 0 ? void 0 : _a.api.redrawRows();
126347
126575
  }
126576
+ clearInvalidCells(action) {
126577
+ if (!this._editionManager)
126578
+ return;
126579
+ this._editionManager.clearInvalidCells(action);
126580
+ this._gridOptions.api.refreshCells({ force: true });
126581
+ }
126582
+ destroy() {
126583
+ this.observer.disconnect();
126584
+ }
126348
126585
  }
126349
126586
 
126350
126587
  function enableSelectAll(total) {
@@ -126592,6 +126829,8 @@ const EzGrid$1 = class extends HTMLElement$1 {
126592
126829
  this.recordsValidator = undefined;
126593
126830
  this.canEdit = true;
126594
126831
  this.autoFocus = true;
126832
+ this.enableGridInsert = false;
126833
+ this.enableContinuousInsert = true;
126595
126834
  }
126596
126835
  /**
126597
126836
  * Aplica a definição de colunas.
@@ -126918,6 +127157,8 @@ const EzGrid$1 = class extends HTMLElement$1 {
126918
127157
  editionIsDisabled: () => !this.canEdit,
126919
127158
  customFormatters: this._customFormatters,
126920
127159
  autoFocus: this.autoFocus,
127160
+ enableGridInsert: this.enableGridInsert,
127161
+ enableContinuousInsert: this.enableContinuousInsert,
126921
127162
  onRefresh: () => {
126922
127163
  if (this.dataUnit) {
126923
127164
  this.setSelection(this.dataUnit.getSelectionInfo());
@@ -127010,6 +127251,8 @@ const EzGrid$1 = class extends HTMLElement$1 {
127010
127251
  }
127011
127252
  componentDidUpdate() {
127012
127253
  this._gridController.setAutoFocus(this.autoFocus);
127254
+ this._gridController.setEnableGridInsert(this.enableGridInsert);
127255
+ this._gridController.setEnableContinuousInsert(this.enableContinuousInsert);
127013
127256
  if (this.dataUnit) {
127014
127257
  this.setSelection(this.dataUnit.getSelectionInfo());
127015
127258
  }
@@ -132861,7 +133104,7 @@ const EzFileItem = /*@__PURE__*/proxyCustomElement(EzFileItem$1, [1,"ez-file-ite
132861
133104
  const EzFilterInput = /*@__PURE__*/proxyCustomElement(EzFilterInput$1, [1,"ez-filter-input",{"label":[1],"value":[1537],"enabled":[4],"errorMessage":[1537,"error-message"],"restrict":[1],"mode":[513],"asyncSearch":[516,"async-search"],"canShowError":[516,"can-show-error"]}]);
132862
133105
  const EzForm = /*@__PURE__*/proxyCustomElement(EzForm$1, [2,"ez-form",{"dataUnit":[1040],"config":[16],"recordsValidator":[16],"fieldToFocus":[1,"field-to-focus"],"onlyStaticFields":[4,"only-static-fields"],"_fieldsProps":[32]}]);
132863
133106
  const EzFormView = /*@__PURE__*/proxyCustomElement(EzFormView$1, [2,"ez-form-view",{"fields":[16],"selectedRecord":[16],"_customEditors":[32]}]);
132864
- const EzGrid = /*@__PURE__*/proxyCustomElement(EzGrid$1, [6,"ez-grid",{"multipleSelection":[4,"multiple-selection"],"config":[1040],"selectionToastConfig":[16],"serverUrl":[1,"server-url"],"dataUnit":[16],"statusResolver":[16],"columnfilterDataSource":[16],"useEnterLikeTab":[4,"use-enter-like-tab"],"recordsValidator":[16],"canEdit":[4,"can-edit"],"autoFocus":[4,"auto-focus"],"_paginationInfo":[32],"_paginationChangedByKeyboard":[32],"_showSelectionCounter":[32],"_isAllSelection":[32],"_currentPageSelected":[32],"_selectionCount":[32],"_hasLeftButtons":[32],"_customFormatters":[32]},[[0,"ezSelectionChange","onSelectionChange"]]]);
133107
+ const EzGrid = /*@__PURE__*/proxyCustomElement(EzGrid$1, [6,"ez-grid",{"multipleSelection":[4,"multiple-selection"],"config":[1040],"selectionToastConfig":[16],"serverUrl":[1,"server-url"],"dataUnit":[16],"statusResolver":[16],"columnfilterDataSource":[16],"useEnterLikeTab":[4,"use-enter-like-tab"],"recordsValidator":[16],"canEdit":[4,"can-edit"],"autoFocus":[4,"auto-focus"],"enableGridInsert":[4,"enable-grid-insert"],"enableContinuousInsert":[4,"enable-continuous-insert"],"_paginationInfo":[32],"_paginationChangedByKeyboard":[32],"_showSelectionCounter":[32],"_isAllSelection":[32],"_currentPageSelected":[32],"_selectionCount":[32],"_hasLeftButtons":[32],"_customFormatters":[32]},[[0,"ezSelectionChange","onSelectionChange"]]]);
132865
133108
  const EzGuideNavigator = /*@__PURE__*/proxyCustomElement(EzGuideNavigator$1, [1,"ez-guide-navigator",{"open":[1540],"selectedId":[1537,"selected-id"],"items":[16],"tooltipResolver":[16],"filterText":[32]}]);
132866
133109
  const EzIcon = /*@__PURE__*/proxyCustomElement(EzIcon$1, [1,"ez-icon",{"size":[513],"href":[513],"iconName":[513,"icon-name"]}]);
132867
133110
  const EzList = /*@__PURE__*/proxyCustomElement(EzList$1, [1,"ez-list",{"dataSource":[1040],"listMode":[1,"list-mode"],"useGroups":[1540,"use-groups"],"ezDraggable":[1028,"ez-draggable"],"ezSelectable":[1028,"ez-selectable"],"itemSlotBuilder":[1040],"itemLeftSlotBuilder":[1040],"hoverFeedback":[1028,"hover-feedback"],"_listItems":[32],"_listGroupItems":[32]}]);
@@ -28,7 +28,7 @@ class RecordValidationProcessor {
28
28
  this._validationSource = validationSource;
29
29
  this._validator = validator;
30
30
  }
31
- validate() {
31
+ validate(isSaving = true) {
32
32
  return new Promise((accept, reject) => {
33
33
  const records = this._dataUnit.getModifiedRecords();
34
34
  for (let i = 0; i < records.length; i++) {
@@ -45,6 +45,11 @@ class RecordValidationProcessor {
45
45
  }
46
46
  }
47
47
  if (invalidResults.length > 0) {
48
+ if (!isSaving && invalidResults[0].invalidFields.length > 0) {
49
+ this._validationSource.markAsInvalid(invalidResults[0].invalidFields[0], record.__record__id__);
50
+ reject();
51
+ break;
52
+ }
48
53
  this.processValidationResult(invalidResults, record.__record__id__);
49
54
  reject();
50
55
  break;
@@ -76,6 +81,7 @@ class RecordValidationProcessor {
76
81
  processValidationResult(validationResult, recordId) {
77
82
  validationResult.forEach(invalidResult => {
78
83
  const invalidFields = invalidResult.invalidFields;
84
+ this._dataUnit.savingCanceled(invalidFields, recordId);
79
85
  if (invalidFields) {
80
86
  invalidFields.forEach(field => {
81
87
  this.markAsInvalid(field, recordId);
@@ -1,6 +1,6 @@
1
1
  import { r as registerInstance, c as createEvent, h, f as forceUpdate, H as Host, g as getElement } from './index-baa5e267.js';
2
2
  import { DateUtils, Action, StringUtils, ApplicationContext, WaitingChangeException, DataUnitAction, DataUnit, ElementIDUtils } from '@sankhyalabs/core';
3
- import { b as buildFieldMetadata, R as RecordValidationProcessor } from './RecordValidationProcessor-b00b8b77.js';
3
+ import { b as buildFieldMetadata, R as RecordValidationProcessor } from './RecordValidationProcessor-9c6cc267.js';
4
4
  import './ApplicationUtils-eaf91331.js';
5
5
  import './DialogType-54a62731.js';
6
6
 
@@ -248,7 +248,7 @@ class DataBinder {
248
248
  this._recordValidatorProcessor = new RecordValidationProcessor(this._dataUnit, {
249
249
  getRequiredFields: () => this._formMetadata.getRequiredFields(),
250
250
  markAsInvalid: field => this.markInvalid(field),
251
- getMessageForField: field => this.getErrorMessage(field)
251
+ getMessageForField: field => this.getErrorMessage(field),
252
252
  }, recordsValidator);
253
253
  }
254
254
  disconnectDataUnit() {