@sankhyalabs/ezui 5.22.0-dev.2 → 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 (87) hide show
  1. package/dist/cjs/{RecordValidationProcessor-4c893e04.js → RecordValidationProcessor-10846595.js} +7 -1
  2. package/dist/cjs/ez-custom-form-input_2.cjs.entry.js +31 -4
  3. package/dist/cjs/ez-form-view.cjs.entry.js +3 -2
  4. package/dist/cjs/ez-form.cjs.entry.js +7 -3
  5. package/dist/cjs/ez-grid.cjs.entry.js +264 -20
  6. package/dist/cjs/ez-modal-container.cjs.entry.js +2 -1
  7. package/dist/cjs/ez-modal.cjs.entry.js +7 -1
  8. package/dist/cjs/ez-multi-selection-list.cjs.entry.js +1 -1
  9. package/dist/cjs/ez-popup.cjs.entry.js +9 -2
  10. package/dist/cjs/ez-search.cjs.entry.js +6 -3
  11. package/dist/cjs/ez-tabselector.cjs.entry.js +8 -2
  12. package/dist/cjs/ezui.cjs.js +1 -1
  13. package/dist/cjs/loader.cjs.js +1 -1
  14. package/dist/collection/components/ez-form-view/custom-input/ez-custom-form-input.js +45 -5
  15. package/dist/collection/components/ez-form-view/fieldbuilder/templates/SearchInput.tpl.js +3 -2
  16. package/dist/collection/components/ez-grid/controller/ag-grid/AgGridController.js +106 -8
  17. package/dist/collection/components/ez-grid/controller/ag-grid/DataSource.js +83 -5
  18. package/dist/collection/components/ez-grid/controller/ag-grid/GridEditionManager.js +58 -7
  19. package/dist/collection/components/ez-grid/controller/ag-grid/components/EzGridCustomCellEditor.js +8 -0
  20. package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/Search.tpl.js +1 -0
  21. package/dist/collection/components/ez-grid/controller/ag-grid/test/constants/GridEditionMock.js +1 -0
  22. package/dist/collection/components/ez-grid/ez-grid.js +45 -0
  23. package/dist/collection/components/ez-modal/ez-modal.js +25 -1
  24. package/dist/collection/components/ez-modal-container/ez-modal-container.js +20 -1
  25. package/dist/collection/components/ez-multi-selection-list/ez-multi-selection-list.js +1 -1
  26. package/dist/collection/components/ez-popup/ez-popup.css +5 -1
  27. package/dist/collection/components/ez-popup/ez-popup.js +26 -1
  28. package/dist/collection/components/ez-search/ez-search.js +24 -3
  29. package/dist/collection/components/ez-tabselector/ez-tabselector.js +34 -2
  30. package/dist/collection/utils/form/DataBinder.js +7 -3
  31. package/dist/collection/utils/validators/recordvalidator/IInvalidCells.js +1 -0
  32. package/dist/collection/utils/validators/recordvalidator/RecordValidationProcessor.js +7 -1
  33. package/dist/custom-elements/index.js +349 -44
  34. package/dist/esm/{RecordValidationProcessor-b00b8b77.js → RecordValidationProcessor-9c6cc267.js} +7 -1
  35. package/dist/esm/ez-custom-form-input_2.entry.js +32 -5
  36. package/dist/esm/ez-form-view.entry.js +3 -2
  37. package/dist/esm/ez-form.entry.js +8 -4
  38. package/dist/esm/ez-grid.entry.js +264 -20
  39. package/dist/esm/ez-modal-container.entry.js +2 -1
  40. package/dist/esm/ez-modal.entry.js +7 -1
  41. package/dist/esm/ez-multi-selection-list.entry.js +1 -1
  42. package/dist/esm/ez-popup.entry.js +9 -2
  43. package/dist/esm/ez-search.entry.js +6 -3
  44. package/dist/esm/ez-tabselector.entry.js +8 -2
  45. package/dist/esm/ezui.js +1 -1
  46. package/dist/esm/loader.js +1 -1
  47. package/dist/ezui/ezui.esm.js +1 -1
  48. package/dist/ezui/p-08061683.entry.js +1 -0
  49. package/dist/ezui/p-34b6916c.entry.js +1 -0
  50. package/dist/ezui/p-42533ea4.entry.js +1 -0
  51. package/dist/ezui/p-4d64a3e4.entry.js +1 -0
  52. package/dist/ezui/{p-816cece6.entry.js → p-a9156fef.entry.js} +2 -2
  53. package/dist/ezui/p-c0d9c4f8.entry.js +1 -0
  54. package/dist/ezui/p-c36b7c56.entry.js +1 -0
  55. package/dist/ezui/p-cdc472cc.entry.js +1 -0
  56. package/dist/ezui/p-e26f12dd.entry.js +1 -0
  57. package/dist/ezui/p-f42855b9.js +1 -0
  58. package/dist/ezui/p-f9e551de.entry.js +1 -0
  59. package/dist/types/components/ez-form-view/custom-input/ez-custom-form-input.d.ts +7 -1
  60. package/dist/types/components/ez-form-view/fieldbuilder/templates/SearchInput.tpl.d.ts +1 -1
  61. package/dist/types/components/ez-grid/controller/EzGridController.d.ts +32 -4
  62. package/dist/types/components/ez-grid/controller/ag-grid/AgGridController.d.ts +19 -3
  63. package/dist/types/components/ez-grid/controller/ag-grid/DataSource.d.ts +18 -0
  64. package/dist/types/components/ez-grid/controller/ag-grid/GridEditionManager.d.ts +13 -2
  65. package/dist/types/components/ez-grid/controller/ag-grid/components/EzGridCustomCellEditor.d.ts +1 -0
  66. package/dist/types/components/ez-grid/ez-grid.d.ts +9 -0
  67. package/dist/types/components/ez-modal/ez-modal.d.ts +5 -0
  68. package/dist/types/components/ez-modal-container/ez-modal-container.d.ts +4 -0
  69. package/dist/types/components/ez-popup/ez-popup.d.ts +6 -0
  70. package/dist/types/components/ez-search/ez-search.d.ts +4 -0
  71. package/dist/types/components/ez-tabselector/ez-tabselector.d.ts +2 -1
  72. package/dist/types/components.d.ts +49 -0
  73. package/dist/types/utils/customEditor/interfaces/ICustomEditor.d.ts +2 -0
  74. package/dist/types/utils/form/DataBinder.d.ts +2 -0
  75. package/dist/types/utils/validators/recordvalidator/IInvalidCells.d.ts +5 -0
  76. package/dist/types/utils/validators/recordvalidator/RecordValidationProcessor.d.ts +1 -1
  77. package/package.json +1 -1
  78. package/dist/ezui/p-04f24913.js +0 -1
  79. package/dist/ezui/p-12ae1104.entry.js +0 -1
  80. package/dist/ezui/p-2dcb50d4.entry.js +0 -1
  81. package/dist/ezui/p-30775e7f.entry.js +0 -1
  82. package/dist/ezui/p-4d5235f1.entry.js +0 -1
  83. package/dist/ezui/p-5056284a.entry.js +0 -1
  84. package/dist/ezui/p-784fe207.entry.js +0 -1
  85. package/dist/ezui/p-9ab22a07.entry.js +0 -1
  86. package/dist/ezui/p-d9401ea0.entry.js +0 -1
  87. package/dist/ezui/p-f3c526cc.entry.js +0 -1
@@ -30,7 +30,7 @@ class RecordValidationProcessor {
30
30
  this._validationSource = validationSource;
31
31
  this._validator = validator;
32
32
  }
33
- validate() {
33
+ validate(isSaving = true) {
34
34
  return new Promise((accept, reject) => {
35
35
  const records = this._dataUnit.getModifiedRecords();
36
36
  for (let i = 0; i < records.length; i++) {
@@ -47,6 +47,11 @@ class RecordValidationProcessor {
47
47
  }
48
48
  }
49
49
  if (invalidResults.length > 0) {
50
+ if (!isSaving && invalidResults[0].invalidFields.length > 0) {
51
+ this._validationSource.markAsInvalid(invalidResults[0].invalidFields[0], record.__record__id__);
52
+ reject();
53
+ break;
54
+ }
50
55
  this.processValidationResult(invalidResults, record.__record__id__);
51
56
  reject();
52
57
  break;
@@ -78,6 +83,7 @@ class RecordValidationProcessor {
78
83
  processValidationResult(validationResult, recordId) {
79
84
  validationResult.forEach(invalidResult => {
80
85
  const invalidFields = invalidResult.invalidFields;
86
+ this._dataUnit.savingCanceled(invalidFields, recordId);
81
87
  if (invalidFields) {
82
88
  invalidFields.forEach(field => {
83
89
  this.markAsInvalid(field, recordId);
@@ -41,6 +41,27 @@ const EzCustomFormInput = class {
41
41
  var _a, _b;
42
42
  return ((_b = (_a = this.gui) === null || _a === void 0 ? void 0 : _a["isInvalid"]) === null || _b === void 0 ? void 0 : _b.call(_a)) || false;
43
43
  }
44
+ watchValue() {
45
+ this.handleValue(this.gui);
46
+ }
47
+ watchCustomEditor() {
48
+ this.getContent();
49
+ }
50
+ watchFormViewField(newValue, oldValue) {
51
+ if (!core.ObjectUtils.equals(newValue, oldValue))
52
+ this.getContent();
53
+ }
54
+ watchDetailContext() {
55
+ this.getContent();
56
+ }
57
+ watchBuilderFallback() {
58
+ this.getContent();
59
+ }
60
+ watchSelectedRecord(newValue, oldValue) {
61
+ if (newValue['__record__id__'] !== oldValue['__record__id__']) {
62
+ this.getContent();
63
+ }
64
+ }
44
65
  getContent() {
45
66
  var _a, _b;
46
67
  const fieldProps = new Map();
@@ -80,9 +101,7 @@ const EzCustomFormInput = class {
80
101
  if (typeof gui === 'string') {
81
102
  gui = core.HTMLBuilder.parseElement(gui);
82
103
  }
83
- if (this.value) {
84
- gui.setAttribute('value', typeof this.value === 'object' ? this.value.value : this.value);
85
- }
104
+ gui.setAttribute('value', this.value);
86
105
  this.gui = index.h("div", { key: core.StringUtils.generateUUID(), ref: el => el && el.appendChild(gui) });
87
106
  }
88
107
  setValue(value) {
@@ -98,12 +117,20 @@ const EzCustomFormInput = class {
98
117
  child.$attrs$.value = this.value;
99
118
  });
100
119
  }
101
- componentWillRender() {
120
+ componentWillLoad() {
102
121
  this.getContent();
103
122
  }
104
123
  render() {
105
124
  return (index.h(index.Host, null, this.gui));
106
125
  }
126
+ static get watchers() { return {
127
+ "value": ["watchValue"],
128
+ "customEditor": ["watchCustomEditor"],
129
+ "formViewField": ["watchFormViewField"],
130
+ "detailContext": ["watchDetailContext"],
131
+ "builderFallback": ["watchBuilderFallback"],
132
+ "selectedRecord": ["watchSelectedRecord"]
133
+ }; }
107
134
  };
108
135
 
109
136
  const ezTextEditCss = ":host{display:flex;align-items:center;gap:5px}.text-edit__form-input{width:auto;--ez-text-input__input--padding:0px}.text-edit__hidden-value{visibility:hidden;position:absolute;white-space:nowrap;z-index:-1;top:0;left:0}";
@@ -72,9 +72,10 @@ function buildNumeric(fieldName, fieldLabel, readOnly, precision, prettyPrecisio
72
72
  index.h("ez-number-input", { enabled: !readOnly, label: fieldLabel, precision: precision, prettyPrecision: prettyPrecision, "data-field-name": fieldName, "data-context-name": contextName, key: fieldName, canShowError: canShowError })));
73
73
  }
74
74
 
75
- const buildSearch = ({ name, label, readOnly, required, contextName, canShowError, optionLoader }) => {
75
+ const buildSearch = ({ name, label, readOnly, required, contextName, canShowError, optionLoader, props }) => {
76
+ var _a;
76
77
  return (index.h("div", { class: "ez-col ez-col--sd-12 ez-padding-horizontal--small" },
77
- index.h("ez-search", { enabled: !readOnly, suppressEmptyOption: required, label: label, "data-field-name": name, "data-context-name": contextName, key: name, canShowError: canShowError, optionLoader: optionLoader })));
78
+ index.h("ez-search", { enabled: !readOnly, suppressEmptyOption: required, label: label, "data-field-name": name, "data-context-name": contextName, key: name, canShowError: canShowError, optionLoader: optionLoader, ignoreLimitCharsToSearch: (_a = props.ignoreLimitCharsToSearch) !== null && _a !== void 0 ? _a : false })));
78
79
  };
79
80
 
80
81
  const buildTextArea = ({ name, label, readOnly, contextName, rows, canShowError }) => {
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-a7b0c73d.js');
6
6
  const core = require('@sankhyalabs/core');
7
- const RecordValidationProcessor = require('./RecordValidationProcessor-4c893e04.js');
7
+ const RecordValidationProcessor = require('./RecordValidationProcessor-10846595.js');
8
8
  require('./ApplicationUtils-c9d1205c.js');
9
9
  require('./DialogType-2114c337.js');
10
10
 
@@ -213,6 +213,7 @@ class DataBinder {
213
213
  break;
214
214
  }
215
215
  };
216
+ this._uuid = core.StringUtils.generateUUID();
216
217
  this._fields = new Map();
217
218
  this._dataUnit = dataUnit;
218
219
  this.applyDefaultValues();
@@ -220,6 +221,9 @@ class DataBinder {
220
221
  this._dataUnit.addInterceptor(this);
221
222
  this.setContextDataBinder(dataUnit);
222
223
  }
224
+ get dataBinderId() {
225
+ return this._uuid;
226
+ }
223
227
  setContextDataBinder(dataUnit) {
224
228
  const dataBindersByDataUnit = core.ApplicationContext.getContextValue("__DATABINDER_BY_DATAUNIT__") || new Map();
225
229
  const dataBinders = [...(dataBindersByDataUnit.get(dataUnit.dataUnitId) || []), this];
@@ -248,13 +252,13 @@ class DataBinder {
248
252
  this._recordValidatorProcessor = new RecordValidationProcessor.RecordValidationProcessor(this._dataUnit, {
249
253
  getRequiredFields: () => this._formMetadata.getRequiredFields(),
250
254
  markAsInvalid: field => this.markInvalid(field),
251
- getMessageForField: field => this.getErrorMessage(field)
255
+ getMessageForField: field => this.getErrorMessage(field),
252
256
  }, recordsValidator);
253
257
  }
254
258
  disconnectDataUnit() {
255
259
  const dataBindersByDataUnit = core.ApplicationContext.getContextValue("__DATABINDER_BY_DATAUNIT__") || new Map();
256
260
  const dataBinders = dataBindersByDataUnit.get(this._dataUnit.dataUnitId);
257
- const dataBindersFiltered = dataBinders.filter((dataBinder) => JSON.stringify(dataBinder) !== JSON.stringify(this));
261
+ const dataBindersFiltered = dataBinders.filter((dataBinder) => dataBinder.dataBinderId !== this.dataBinderId);
258
262
  dataBindersByDataUnit.set(this._dataUnit.dataUnitId, dataBindersFiltered);
259
263
  core.ApplicationContext.setContextValue("__DATABINDER_BY_DATAUNIT__", dataBindersByDataUnit);
260
264
  }
@@ -10,7 +10,7 @@ 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-4c893e04.js');
13
+ const RecordValidationProcessor = require('./RecordValidationProcessor-10846595.js');
14
14
 
15
15
  /**
16
16
  * @ag-grid-community/all-modules - Advanced Data Grid / Data Table supporting Javascript / Typescript / React / Angular / Vue * @version v28.2.1
@@ -118853,6 +118853,73 @@ class DataSourceInterceptor {
118853
118853
  }
118854
118854
 
118855
118855
  class DataSource {
118856
+ handleSavingCanceled(action) {
118857
+ var _a, _b, _c, _d;
118858
+ if (!((_a = action.payload) === null || _a === void 0 ? void 0 : _a.fields) || !((_b = action.payload) === null || _b === void 0 ? void 0 : _b.recordId))
118859
+ return;
118860
+ 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);
118861
+ }
118862
+ handleDataChanged(action) {
118863
+ var _a, _b;
118864
+ if (!this._options.enableGridInsert) {
118865
+ this.handleRefresh(action);
118866
+ return;
118867
+ }
118868
+ this.updateGridRowNodes((_b = (_a = action.payload) === null || _a === void 0 ? void 0 : _a.records) !== null && _b !== void 0 ? _b : []);
118869
+ }
118870
+ /**
118871
+ * Nesse ponto, o registro já se encontra atualizado no DU,
118872
+ * basta então passar seu valor para que a garde possa atualizar sua linha.
118873
+ */
118874
+ updateGridRowNodes(recordIDList) {
118875
+ const recordsToUpdate = recordIDList === null || recordIDList === void 0 ? void 0 : recordIDList.map(id => this.getRecordById(id));
118876
+ this._controller.updateRows(recordsToUpdate);
118877
+ }
118878
+ getRecordById(recordId) {
118879
+ return this._dataUnit.records.find(record => record['__record__id__'] === recordId);
118880
+ }
118881
+ /**
118882
+ * Em caso de necessidade de reload (isWaitingToReload), eh preciso chamar o dataUnit.gotoPage, pois ele aplica tambem a ordenacao dos registros,
118883
+ * enquanto que o _controller.refresh apenas recarrega os dados na ordem que atua.
118884
+ */
118885
+ handleRefreshOrReload(action) {
118886
+ if (this._dataUnit.isWaitingToReload()) {
118887
+ this.handleReload();
118888
+ return;
118889
+ }
118890
+ this.handleRefresh(action);
118891
+ }
118892
+ handleReload() {
118893
+ this._dataUnit.setWaitingToReload(false);
118894
+ this._dataUnit.gotoPage(0);
118895
+ }
118896
+ handleRefresh(action) {
118897
+ if (this.isSilentChange(action)) {
118898
+ return;
118899
+ }
118900
+ this._controller.refresh(action.type === core.Action.DATA_SAVED);
118901
+ }
118902
+ handleRecordsAdded() {
118903
+ if (this._options.enableGridInsert) {
118904
+ this._controller.refresh();
118905
+ this.focusOnNewRecord();
118906
+ }
118907
+ }
118908
+ focusOnNewRecord() {
118909
+ /**
118910
+ * O SetTimeout eh utilizado pois é preciso aguardar que o novo registro seja renderizado na grade.
118911
+ * Tentamos utilizar a api da grade para adicionar um event listener, porém na versão que utilizamos, não existe
118912
+ * algo que resolva nosso cenário.
118913
+ *
118914
+ * Sugiro no futuro utilizar algo como o applyServerSideTransaction, porém será preciso lidar com os handlers
118915
+ * e callbacks implementados no AgGridController e GridEditionManager.
118916
+ */
118917
+ setTimeout(() => {
118918
+ var _a;
118919
+ const newRowIndex = ((_a = this._dataUnit.records) === null || _a === void 0 ? void 0 : _a.length) - 1;
118920
+ this._controller.startEditionOnRowByIndex(newRowIndex);
118921
+ }, 500);
118922
+ }
118856
118923
  updateLoadedRecords(action) {
118857
118924
  const records = action.payload;
118858
118925
  if ((records === null || records === void 0 ? void 0 : records.length) > 0) {
@@ -118904,15 +118971,20 @@ class DataSource {
118904
118971
  this._options.onPaginationUpdate(this._dataUnit.getPaginationInfo());
118905
118972
  }
118906
118973
  break;
118907
- case core.Action.RECORDS_REMOVED:
118974
+ case core.Action.RECORDS_ADDED:
118975
+ this.handleRecordsAdded();
118976
+ break;
118908
118977
  case core.Action.DATA_SAVED:
118909
118978
  case core.Action.EDITION_CANCELED:
118979
+ this._controller.clearInvalidCells(action.type);
118980
+ this.handleRefreshOrReload(action);
118981
+ break;
118910
118982
  case core.Action.DATA_CHANGED:
118911
118983
  case core.Action.DATA_RESOLVED:
118912
- if (this.isSilentChange(action)) {
118913
- return;
118914
- }
118915
- this._controller.refresh();
118984
+ this.handleDataChanged(action);
118985
+ break;
118986
+ case core.Action.RECORDS_REMOVED:
118987
+ this.handleRefresh(action);
118916
118988
  break;
118917
118989
  case core.Action.SELECTION_CHANGED:
118918
118990
  case core.Action.NEXT_SELECTED:
@@ -118922,6 +118994,9 @@ class DataSource {
118922
118994
  case core.Action.RECORD_LOADED:
118923
118995
  this.updateLoadedRecords(action);
118924
118996
  break;
118997
+ case core.Action.SAVING_CANCELED:
118998
+ this.handleSavingCanceled(action);
118999
+ break;
118925
119000
  }
118926
119001
  };
118927
119002
  this._dataUnit = dataUnit;
@@ -118943,6 +119018,9 @@ class DataSource {
118943
119018
  setAutoFocus(autoFocus) {
118944
119019
  this._options.autoFocus = autoFocus;
118945
119020
  }
119021
+ setEnableGridInsert(enable) {
119022
+ this._options.enableGridInsert = enable;
119023
+ }
118946
119024
  getRows(params) {
118947
119025
  if (this.needReload(params)) {
118948
119026
  this._lastLoadingParams = params;
@@ -119405,6 +119483,7 @@ const buildSearch = ({ name, required, readOnly, eGridCell, dataUnit }) => {
119405
119483
  />`);
119406
119484
  const loader = core.ApplicationContext.getContextValue("__EZUI__SEARCH__OPTION__LOADER__");
119407
119485
  ezSearch.optionLoader = (argument) => loader(argument, name, dataUnit);
119486
+ ezSearch.fromGrid = true;
119408
119487
  ezSearch.listOptionsPosition = { verticalPosition: 29, bottomLimit: getViewPortHeight(eGridCell), hardPosition: true };
119409
119488
  ezSearch.valueGetter = () => ezSearch.getValueAsync();
119410
119489
  return ezSearch;
@@ -119470,6 +119549,8 @@ class EzGridCustomCellEditor extends EzCellEditor {
119470
119549
  this._defaultGui = this.getDefaultGui();
119471
119550
  const fieldMetadata = super.getFieldMetadata();
119472
119551
  this._params = {
119552
+ cellPossition: getViewPortHeight(params.eGridCell),
119553
+ eGridCell: params.eGridCell,
119473
119554
  value: params.value,
119474
119555
  charPress: params.charPress,
119475
119556
  currentEditor: this._defaultGui,
@@ -119507,12 +119588,17 @@ class EzGridCustomCellEditor extends EzCellEditor {
119507
119588
  const element = core.HTMLBuilder.parseElement(editorElement);
119508
119589
  return element;
119509
119590
  }
119591
+ this._customGui = editorElement;
119510
119592
  return editorElement;
119511
119593
  }
119512
119594
  setValue(value) {
119513
119595
  this._value = value;
119514
119596
  }
119515
119597
  getValue() {
119598
+ if (this._customGui.getValue)
119599
+ return this._customGui.getValue();
119600
+ if (this._customGui.hasAttribute('value'))
119601
+ return this._customGui.value;
119516
119602
  return this._value;
119517
119603
  }
119518
119604
  }
@@ -119596,15 +119682,16 @@ class EzGridCustomCellRender extends EzCellRender {
119596
119682
  }
119597
119683
 
119598
119684
  class GridEditionManager {
119599
- constructor(dataUnit, useEnterLikeTab, recordsValidator, editionIsDisabled, customEditors, customRenders) {
119685
+ constructor(dataUnit, useEnterLikeTab, recordsValidator, editionIsDisabled, customEditors, customRenders, enableContinuousInsert) {
119600
119686
  this._dataUnit = dataUnit;
119601
119687
  this._recordValidationProcessor = new RecordValidationProcessor.RecordValidationProcessor(this._dataUnit, {
119602
119688
  getRequiredFields: () => this.getRequiredFields(),
119603
- markAsInvalid: () => { },
119604
- getMessageForField: () => null
119689
+ markAsInvalid: (invalidField, recordId) => { this.setInvalidCell(invalidField, recordId); },
119690
+ getMessageForField: () => null,
119605
119691
  }, recordsValidator);
119606
119692
  this._useEnterLikeTab = useEnterLikeTab;
119607
119693
  this._editionIsDisabled = editionIsDisabled;
119694
+ this._enableContinuousInsert = enableContinuousInsert;
119608
119695
  this._customEditors = customEditors;
119609
119696
  this._customRenders = customRenders;
119610
119697
  }
@@ -119619,27 +119706,49 @@ class GridEditionManager {
119619
119706
  };
119620
119707
  return options;
119621
119708
  }
119709
+ canContinuousInsert() {
119710
+ var _a;
119711
+ return this._enableContinuousInsert && (this._dataUnit.records.length - 1) === ((_a = this._lastCellEdited) === null || _a === void 0 ? void 0 : _a.rowIndex);
119712
+ }
119622
119713
  proceedAutoSave() {
119623
119714
  if (!this._dataUnit.isDirty()) {
119624
119715
  this.saveSuccess();
119625
119716
  return;
119626
119717
  }
119627
- if (!this._isGridEdition) {
119718
+ if (!this._isGridEdition || this._dataUnit.hasNewRecord()) {
119628
119719
  return;
119629
119720
  }
119630
119721
  const currentRercord = this._dataUnit.getSelectedRecord();
119631
119722
  if (currentRercord == undefined) {
119632
119723
  return;
119633
119724
  }
119725
+ this._invalidCell = undefined;
119634
119726
  this._recordValidationProcessor
119635
- .validate()
119727
+ .validate(true)
119636
119728
  .then(() => {
119637
119729
  this._dataUnit.saveData()
119638
- .then(() => this.saveSuccess())
119730
+ .then(() => {
119731
+ if (this.canContinuousInsert()) {
119732
+ this._dataUnit.addRecord();
119733
+ }
119734
+ else {
119735
+ this.saveSuccess();
119736
+ }
119737
+ })
119639
119738
  .catch(reason => this.saveFail(reason));
119640
119739
  })
119641
119740
  .catch(reason => this.saveFail(reason));
119642
119741
  }
119742
+ async recordValidate() {
119743
+ if (!this._dataUnit.isDirty())
119744
+ return;
119745
+ try {
119746
+ this._invalidCell = undefined;
119747
+ await this._recordValidationProcessor.validate(false);
119748
+ }
119749
+ catch (error) { }
119750
+ this._gridOptions.api.refreshCells({ force: true });
119751
+ }
119643
119752
  navigateByEnterKey(keyboardEvent) {
119644
119753
  const backwards = keyboardEvent.shiftKey;
119645
119754
  if (this._useEnterLikeTab) {
@@ -119848,6 +119957,34 @@ class GridEditionManager {
119848
119957
  setCellRenders(customRenders) {
119849
119958
  this._customRenders = customRenders;
119850
119959
  }
119960
+ setInvalidCell(invalidCell, recordId) {
119961
+ this._invalidCell = { field: invalidCell, recordId };
119962
+ }
119963
+ getInvalidCell() {
119964
+ return this._invalidCell;
119965
+ }
119966
+ clearInvalidCells(action) {
119967
+ this._invalidCell = undefined;
119968
+ if (action === core.Action.EDITION_CANCELED) {
119969
+ this._isGridEdition = false;
119970
+ }
119971
+ else if (action === core.Action.DATA_SAVED && this.canContinuousInsert()) {
119972
+ this._dataUnit.addRecord();
119973
+ }
119974
+ }
119975
+ setEnableContinuousInsert(enable) {
119976
+ this._enableContinuousInsert = enable;
119977
+ }
119978
+ hasInvalidField(fieldName, recordId) {
119979
+ if (!this.hasInvalidCell())
119980
+ return false;
119981
+ return this._invalidCell.field.name === fieldName && this._invalidCell.recordId === recordId;
119982
+ }
119983
+ hasInvalidCell() {
119984
+ if (!this._invalidCell || !this._invalidCell.field || !this._invalidCell.recordId)
119985
+ return false;
119986
+ return true;
119987
+ }
119851
119988
  }
119852
119989
  class TargetEdition {
119853
119990
  constructor(rowIndex, column, backwards) {
@@ -119891,6 +120028,8 @@ class AgGridController {
119891
120028
  this._filteredColumns = new Map();
119892
120029
  this._filterColumnleftPosition = 0;
119893
120030
  this._customFormatters = new Map();
120031
+ this._gridShowDom = false;
120032
+ this.peddingExecutionsOnGridShow = [];
119894
120033
  this._enterprise = enterprise;
119895
120034
  }
119896
120035
  getGridConfig() {
@@ -119976,7 +120115,7 @@ class AgGridController {
119976
120115
  this._doubleClickCallBack = options.onDoubleClick;
119977
120116
  this._multipleSelection = options.allowMultipleSelection;
119978
120117
  this._dataUnit = options.dataUnit;
119979
- this._editionManager = new GridEditionManager(this._dataUnit, options.useEnterLikeTab, options.recordsValidator, options.editionIsDisabled, options.customEditors || this._customEditors, options.customRenders || this._customRenders);
120118
+ this._editionManager = new GridEditionManager(this._dataUnit, options.useEnterLikeTab, options.recordsValidator, options.editionIsDisabled, options.customEditors || this._customEditors, options.customRenders || this._customRenders, options.enableContinuousInsert);
119980
120119
  this._statusResolver = options.statusResolver;
119981
120120
  if (this._dataUnit) {
119982
120121
  this._dataUnit.sortingProvider = this;
@@ -119996,6 +120135,9 @@ class AgGridController {
119996
120135
  defaultColDef: {
119997
120136
  headerClass: 'ez-grid__cell-header',
119998
120137
  cellClass: 'ez-grid__cell-body',
120138
+ cellClassRules: {
120139
+ 'invalidValue': (params) => this._editionManager.hasInvalidField(params.colDef.field, params.data["__record__id__"]),
120140
+ },
119999
120141
  cellStyle: {
120000
120142
  height: '100%'
120001
120143
  }
@@ -120026,10 +120168,6 @@ class AgGridController {
120026
120168
  else {
120027
120169
  this._grid = new Grid(container, this._gridOptions);
120028
120170
  }
120029
- container.addEventListener('focusout', (event) => {
120030
- if (!container.contains(event.relatedTarget))
120031
- this._gridOptions.api.clearFocusedCell();
120032
- });
120033
120171
  const selection = (_a = this._dataUnit) === null || _a === void 0 ? void 0 : _a.getSelectionInfo();
120034
120172
  if (selection === null || selection === void 0 ? void 0 : selection.isAllRecords()) {
120035
120173
  this.selectAll(true);
@@ -120039,6 +120177,23 @@ class AgGridController {
120039
120177
  }
120040
120178
  this._gridOptions.api.setHeaderHeight(this.getHeaderRowHeight());
120041
120179
  this._customFormatters = options.customFormatters;
120180
+ const observerCallback = (entries) => {
120181
+ entries.forEach(entry => {
120182
+ if (entry.isIntersecting) {
120183
+ this._gridShowDom = true;
120184
+ this.peddingExecutionsOnGridShow.forEach(func => func());
120185
+ this.peddingExecutionsOnGridShow = [];
120186
+ }
120187
+ else {
120188
+ this._gridShowDom = false;
120189
+ }
120190
+ });
120191
+ };
120192
+ this.observer = new IntersectionObserver(observerCallback, {
120193
+ root: null,
120194
+ threshold: 0.1
120195
+ });
120196
+ this.observer.observe(container);
120042
120197
  }
120043
120198
  }
120044
120199
  processFormatterCellCallback(params) {
@@ -120229,10 +120384,16 @@ class AgGridController {
120229
120384
  throw new Error('Erro interno: Grid ainda não inicializado.');
120230
120385
  }
120231
120386
  }
120232
- updateRows() {
120387
+ updateRows(rows) {
120233
120388
  if (this._grid === undefined) {
120234
120389
  throw new Error('Erro interno: Grid ainda não inicializado.');
120235
120390
  }
120391
+ rows === null || rows === void 0 ? void 0 : rows.forEach(row => this.updateRowData(row));
120392
+ }
120393
+ updateRowData(row) {
120394
+ const node = this._gridOptions.api.getRowNode(row[this._idAttribName]);
120395
+ node.setData(Object.assign({}, row));
120396
+ this._editionManager.recordValidate();
120236
120397
  }
120237
120398
  selectAll(quietly = false) {
120238
120399
  try {
@@ -120315,14 +120476,42 @@ class AgGridController {
120315
120476
  });
120316
120477
  r.setData(data);
120317
120478
  });
120479
+ this._gridOptions.api.refreshCells({ force: true });
120480
+ const invalidCell = this._editionManager.getInvalidCell();
120481
+ if (invalidCell) {
120482
+ const rowNode = this._gridOptions.api.getRowNode(invalidCell.recordId);
120483
+ if (rowNode && invalidCell.field) {
120484
+ this.startEdition(rowNode.rowIndex, this._gridOptions.columnApi.getColumn(invalidCell.field.name));
120485
+ }
120486
+ }
120318
120487
  }
120319
120488
  }
120320
- refresh() {
120489
+ savingCanceled(fields, recordId) {
120490
+ const displayedColumns = this._gridOptions.columnApi.getAllDisplayedColumns();
120491
+ const rowIndex = this._gridOptions.api.getRowNode(recordId).rowIndex;
120492
+ const columnFocus = displayedColumns.find(column => this.isColumnEditable(rowIndex, column) && fields.find(field => field.name === column.getColId()));
120493
+ this.focusByCollAndRow(columnFocus, rowIndex);
120494
+ this.startEdition(rowIndex, columnFocus);
120495
+ }
120496
+ refresh(scrollToSelectedRow = false) {
120321
120497
  if (this._grid === undefined) {
120322
120498
  throw new Error('Erro interno: Grid ainda não inicializado.');
120323
120499
  }
120324
120500
  this._gridOptions.api.refreshServerSide({ purge: true });
120325
120501
  this._options.onRefresh();
120502
+ if (scrollToSelectedRow)
120503
+ this.scrollToSelectedRow();
120504
+ }
120505
+ scrollToSelectedRow() {
120506
+ const rowNode = this._gridOptions.api.getSelectedNodes();
120507
+ if (!rowNode || rowNode.length === 0)
120508
+ return;
120509
+ if (this._gridShowDom) {
120510
+ this._gridOptions.api.ensureNodeVisible(rowNode[0]);
120511
+ }
120512
+ else {
120513
+ this.peddingExecutionsOnGridShow.push(() => this._gridOptions.api.ensureNodeVisible(rowNode[0]));
120514
+ }
120326
120515
  }
120327
120516
  focusOnGridContainer() {
120328
120517
  this._container.setAttribute('tabindex', '-1');
@@ -120341,6 +120530,14 @@ class AgGridController {
120341
120530
  var _a;
120342
120531
  (_a = this._dataSource) === null || _a === void 0 ? void 0 : _a.setAutoFocus(autoFocus);
120343
120532
  }
120533
+ setEnableGridInsert(enable) {
120534
+ var _a;
120535
+ (_a = this._dataSource) === null || _a === void 0 ? void 0 : _a.setEnableGridInsert(enable);
120536
+ }
120537
+ setEnableContinuousInsert(enable) {
120538
+ var _a;
120539
+ (_a = this._editionManager) === null || _a === void 0 ? void 0 : _a.setEnableContinuousInsert(enable);
120540
+ }
120344
120541
  setFocusFirstRow() {
120345
120542
  const firstRow = this._gridOptions.api.getDisplayedRowAtIndex(0);
120346
120543
  if (firstRow) {
@@ -120356,9 +120553,38 @@ class AgGridController {
120356
120553
  this.setFocusOnRow(lastRow.rowIndex);
120357
120554
  }
120358
120555
  }
120556
+ startEditionOnRowByIndex(rowIndex) {
120557
+ const firstCol = this.getFirstEditableColl(rowIndex);
120558
+ this.focusByCollAndRow(firstCol, rowIndex);
120559
+ this.startEdition(rowIndex, firstCol);
120560
+ }
120561
+ startEdition(rowIndex, firstCol) {
120562
+ this._gridOptions.api.clearRangeSelection();
120563
+ this._gridOptions.api.addCellRange({ rowStartIndex: rowIndex, rowEndIndex: rowIndex, columns: [firstCol] });
120564
+ this._gridOptions.api.setFocusedCell(rowIndex, firstCol);
120565
+ this._gridOptions.api.startEditingCell({ rowIndex, colKey: firstCol });
120566
+ const cellEditor = this._gridOptions.api.getCellEditorInstances()[0];
120567
+ if (cellEditor) {
120568
+ cellEditor.focusIn();
120569
+ }
120570
+ }
120571
+ getFirstEditableColl(rowIndex) {
120572
+ const displayedColumns = this._gridOptions.columnApi.getAllDisplayedColumns();
120573
+ return displayedColumns.find(column => this.isColumnEditable(rowIndex, column));
120574
+ }
120575
+ isColumnEditable(rowIndex, column) {
120576
+ if (column.getColDef().headerName === '' || rowIndex === -1)
120577
+ return false;
120578
+ const rowId = this._dataUnit.records[rowIndex][this._idAttribName];
120579
+ const rowNode = this._gridOptions.api.getRowNode(rowId);
120580
+ return column.isCellEditable(rowNode);
120581
+ }
120359
120582
  setFocusOnRow(rowIndex) {
120360
120583
  let displayedColumns = this._gridOptions.columnApi.getAllDisplayedColumns();
120361
- let firstCell = displayedColumns.find(column => column.getColDef().headerName !== '');
120584
+ let firstColl = displayedColumns.find(column => column.getColDef().headerName !== '');
120585
+ this.focusByCollAndRow(firstColl, rowIndex);
120586
+ }
120587
+ focusByCollAndRow(firstCell, rowIndex) {
120362
120588
  this._gridOptions.api.ensureColumnVisible(firstCell);
120363
120589
  this._gridOptions.api.ensureIndexVisible(rowIndex);
120364
120590
  this._gridOptions.api.setFocusedCell(rowIndex, firstCell);
@@ -120738,6 +120964,15 @@ class AgGridController {
120738
120964
  this._editionManager.setCellRenders(customRenders);
120739
120965
  (_a = this._gridOptions) === null || _a === void 0 ? void 0 : _a.api.redrawRows();
120740
120966
  }
120967
+ clearInvalidCells(action) {
120968
+ if (!this._editionManager)
120969
+ return;
120970
+ this._editionManager.clearInvalidCells(action);
120971
+ this._gridOptions.api.refreshCells({ force: true });
120972
+ }
120973
+ destroy() {
120974
+ this.observer.disconnect();
120975
+ }
120741
120976
  }
120742
120977
 
120743
120978
  function enableSelectAll(total) {
@@ -120984,6 +121219,8 @@ const EzGrid = class {
120984
121219
  this.recordsValidator = undefined;
120985
121220
  this.canEdit = true;
120986
121221
  this.autoFocus = true;
121222
+ this.enableGridInsert = false;
121223
+ this.enableContinuousInsert = true;
120987
121224
  }
120988
121225
  /**
120989
121226
  * Aplica a definição de colunas.
@@ -121310,6 +121547,8 @@ const EzGrid = class {
121310
121547
  editionIsDisabled: () => !this.canEdit,
121311
121548
  customFormatters: this._customFormatters,
121312
121549
  autoFocus: this.autoFocus,
121550
+ enableGridInsert: this.enableGridInsert,
121551
+ enableContinuousInsert: this.enableContinuousInsert,
121313
121552
  onRefresh: () => {
121314
121553
  if (this.dataUnit) {
121315
121554
  this.setSelection(this.dataUnit.getSelectionInfo());
@@ -121402,6 +121641,11 @@ const EzGrid = class {
121402
121641
  }
121403
121642
  componentDidUpdate() {
121404
121643
  this._gridController.setAutoFocus(this.autoFocus);
121644
+ this._gridController.setEnableGridInsert(this.enableGridInsert);
121645
+ this._gridController.setEnableContinuousInsert(this.enableContinuousInsert);
121646
+ if (this.dataUnit) {
121647
+ this.setSelection(this.dataUnit.getSelectionInfo());
121648
+ }
121405
121649
  }
121406
121650
  getDataSource() {
121407
121651
  var _a;
@@ -35,6 +35,7 @@ const EzModalContainer = class {
35
35
  this.okButtonLabel = undefined;
36
36
  this.cancelButtonStatus = undefined;
37
37
  this.okButtonStatus = undefined;
38
+ this.showCloseButton = true;
38
39
  }
39
40
  async handleEzModalAction(event) {
40
41
  var _a;
@@ -71,7 +72,7 @@ const EzModalContainer = class {
71
72
  this._closeButton.focus();
72
73
  }
73
74
  render() {
74
- return (index.h(index.Host, null, index.h("button", { class: "ez-modal-container__focus-ctrl", onFocusin: () => this.focusLast() }), index.h("div", { ref: ref => this._modalRef = ref, tabIndex: -1, class: "ez-modal-container__header-container" }, this.showTitleBar && (index.h("div", { class: "ez-modal-container__header ez-margin-bottom--large" }, index.h("div", { class: "ez-col ez-align--middle ez-modal-container__title" }, index.h("h2", { class: "ez-text ez-title--large ez-title--primary ez-text--bold ez-margin-vertical--extra-small" }, this.modalTitle), this.modalSubTitle && (index.h("div", { class: "ez-text ez-text--medium ez-text--primary ez-margin-vertical--extra-small" }, this.modalSubTitle))), index.h("button", { ref: ref => this._closeButton = ref, class: "ez-modal-container__close-button", onClick: () => this.ezModalAction.emit(ModalAction$1.CLOSE) }, index.h("ez-icon", { class: "ez-modal-container__close-icon", size: "medium", iconName: "close" }))))), index.h("div", { class: "ez-modal-container__content" }, index.h("slot", null)), index.h("div", { class: "ez-modal-container__footer" }, this.cancelIsVisible() && (index.h("ez-button", { label: this.cancelButtonLabel, enabled: this.cancelButtonStatus !== ModalButtonStatus$1.DISABLED, onClick: () => this.ezModalAction.emit(ModalAction$1.CANCEL) })), this.okIsVisible() && (index.h("ez-button", { ref: ref => this._okButton = ref, class: "ez-button--primary", label: this.okButtonLabel, enabled: this.okButtonStatus !== ModalButtonStatus$1.DISABLED, onClick: () => this.ezModalAction.emit(ModalAction$1.OK) }))), index.h("button", { class: "ez-modal-container__focus-ctrl", onFocusin: () => this.focusFirst() })));
75
+ return (index.h(index.Host, null, index.h("button", { class: "ez-modal-container__focus-ctrl", onFocusin: () => this.focusLast() }), index.h("div", { ref: ref => this._modalRef = ref, tabIndex: -1, class: "ez-modal-container__header-container" }, this.showTitleBar && (index.h("div", { class: "ez-modal-container__header ez-margin-bottom--large" }, index.h("div", { class: "ez-col ez-align--middle ez-modal-container__title" }, index.h("h2", { class: "ez-text ez-title--large ez-title--primary ez-text--bold ez-margin-vertical--extra-small" }, this.modalTitle), this.modalSubTitle && (index.h("div", { class: "ez-text ez-text--medium ez-text--primary ez-margin-vertical--extra-small" }, this.modalSubTitle))), (this.showCloseButton && index.h("button", { ref: ref => this._closeButton = ref, class: "ez-modal-container__close-button", onClick: () => this.ezModalAction.emit(ModalAction$1.CLOSE) }, index.h("ez-icon", { class: "ez-modal-container__close-icon", size: "medium", iconName: "close" })))))), index.h("div", { class: "ez-modal-container__content" }, index.h("slot", null)), index.h("div", { class: "ez-modal-container__footer" }, this.cancelIsVisible() && (index.h("ez-button", { label: this.cancelButtonLabel, enabled: this.cancelButtonStatus !== ModalButtonStatus$1.DISABLED, onClick: () => this.ezModalAction.emit(ModalAction$1.CANCEL) })), this.okIsVisible() && (index.h("ez-button", { ref: ref => this._okButton = ref, class: "ez-button--primary", label: this.okButtonLabel, enabled: this.okButtonStatus !== ModalButtonStatus$1.DISABLED, onClick: () => this.ezModalAction.emit(ModalAction$1.OK) }))), index.h("button", { class: "ez-modal-container__focus-ctrl", onFocusin: () => this.focusFirst() })));
75
76
  }
76
77
  get _element() { return index.getElement(this); }
77
78
  };