@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
@@ -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, h, H as Host, c as createEvent, g as getElement } from './index-baa5e267.js';
2
2
  import { C as CustomEditorSource } from './ICustomRender-875b5a40.js';
3
- import { HTMLBuilder, StringUtils, ElementIDUtils } from '@sankhyalabs/core';
3
+ import { ObjectUtils, HTMLBuilder, StringUtils, ElementIDUtils } from '@sankhyalabs/core';
4
4
  import { A as ApplicationUtils } from './ApplicationUtils-eaf91331.js';
5
5
  import './DialogType-54a62731.js';
6
6
  import './CheckMode-bdb2ec19.js';
@@ -37,6 +37,27 @@ const EzCustomFormInput = class {
37
37
  var _a, _b;
38
38
  return ((_b = (_a = this.gui) === null || _a === void 0 ? void 0 : _a["isInvalid"]) === null || _b === void 0 ? void 0 : _b.call(_a)) || false;
39
39
  }
40
+ watchValue() {
41
+ this.handleValue(this.gui);
42
+ }
43
+ watchCustomEditor() {
44
+ this.getContent();
45
+ }
46
+ watchFormViewField(newValue, oldValue) {
47
+ if (!ObjectUtils.equals(newValue, oldValue))
48
+ this.getContent();
49
+ }
50
+ watchDetailContext() {
51
+ this.getContent();
52
+ }
53
+ watchBuilderFallback() {
54
+ this.getContent();
55
+ }
56
+ watchSelectedRecord(newValue, oldValue) {
57
+ if (newValue['__record__id__'] !== oldValue['__record__id__']) {
58
+ this.getContent();
59
+ }
60
+ }
40
61
  getContent() {
41
62
  var _a, _b;
42
63
  const fieldProps = new Map();
@@ -76,9 +97,7 @@ const EzCustomFormInput = class {
76
97
  if (typeof gui === 'string') {
77
98
  gui = HTMLBuilder.parseElement(gui);
78
99
  }
79
- if (this.value) {
80
- gui.setAttribute('value', typeof this.value === 'object' ? this.value.value : this.value);
81
- }
100
+ gui.setAttribute('value', this.value);
82
101
  this.gui = h("div", { key: StringUtils.generateUUID(), ref: el => el && el.appendChild(gui) });
83
102
  }
84
103
  setValue(value) {
@@ -94,12 +113,20 @@ const EzCustomFormInput = class {
94
113
  child.$attrs$.value = this.value;
95
114
  });
96
115
  }
97
- componentWillRender() {
116
+ componentWillLoad() {
98
117
  this.getContent();
99
118
  }
100
119
  render() {
101
120
  return (h(Host, null, this.gui));
102
121
  }
122
+ static get watchers() { return {
123
+ "value": ["watchValue"],
124
+ "customEditor": ["watchCustomEditor"],
125
+ "formViewField": ["watchFormViewField"],
126
+ "detailContext": ["watchDetailContext"],
127
+ "builderFallback": ["watchBuilderFallback"],
128
+ "selectedRecord": ["watchSelectedRecord"]
129
+ }; }
103
130
  };
104
131
 
105
132
  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}";
@@ -68,9 +68,10 @@ function buildNumeric(fieldName, fieldLabel, readOnly, precision, prettyPrecisio
68
68
  h("ez-number-input", { enabled: !readOnly, label: fieldLabel, precision: precision, prettyPrecision: prettyPrecision, "data-field-name": fieldName, "data-context-name": contextName, key: fieldName, canShowError: canShowError })));
69
69
  }
70
70
 
71
- const buildSearch = ({ name, label, readOnly, required, contextName, canShowError, optionLoader }) => {
71
+ const buildSearch = ({ name, label, readOnly, required, contextName, canShowError, optionLoader, props }) => {
72
+ var _a;
72
73
  return (h("div", { class: "ez-col ez-col--sd-12 ez-padding-horizontal--small" },
73
- h("ez-search", { enabled: !readOnly, suppressEmptyOption: required, label: label, "data-field-name": name, "data-context-name": contextName, key: name, canShowError: canShowError, optionLoader: optionLoader })));
74
+ 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 })));
74
75
  };
75
76
 
76
77
  const buildTextArea = ({ name, label, readOnly, contextName, rows, canShowError }) => {
@@ -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
- import { DateUtils, Action, ApplicationContext, WaitingChangeException, DataUnitAction, StringUtils, DataUnit, ElementIDUtils } from '@sankhyalabs/core';
3
- import { b as buildFieldMetadata, R as RecordValidationProcessor } from './RecordValidationProcessor-b00b8b77.js';
2
+ import { DateUtils, Action, StringUtils, ApplicationContext, WaitingChangeException, DataUnitAction, DataUnit, ElementIDUtils } from '@sankhyalabs/core';
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
 
@@ -209,6 +209,7 @@ class DataBinder {
209
209
  break;
210
210
  }
211
211
  };
212
+ this._uuid = StringUtils.generateUUID();
212
213
  this._fields = new Map();
213
214
  this._dataUnit = dataUnit;
214
215
  this.applyDefaultValues();
@@ -216,6 +217,9 @@ class DataBinder {
216
217
  this._dataUnit.addInterceptor(this);
217
218
  this.setContextDataBinder(dataUnit);
218
219
  }
220
+ get dataBinderId() {
221
+ return this._uuid;
222
+ }
219
223
  setContextDataBinder(dataUnit) {
220
224
  const dataBindersByDataUnit = ApplicationContext.getContextValue("__DATABINDER_BY_DATAUNIT__") || new Map();
221
225
  const dataBinders = [...(dataBindersByDataUnit.get(dataUnit.dataUnitId) || []), this];
@@ -244,13 +248,13 @@ class DataBinder {
244
248
  this._recordValidatorProcessor = new RecordValidationProcessor(this._dataUnit, {
245
249
  getRequiredFields: () => this._formMetadata.getRequiredFields(),
246
250
  markAsInvalid: field => this.markInvalid(field),
247
- getMessageForField: field => this.getErrorMessage(field)
251
+ getMessageForField: field => this.getErrorMessage(field),
248
252
  }, recordsValidator);
249
253
  }
250
254
  disconnectDataUnit() {
251
255
  const dataBindersByDataUnit = ApplicationContext.getContextValue("__DATABINDER_BY_DATAUNIT__") || new Map();
252
256
  const dataBinders = dataBindersByDataUnit.get(this._dataUnit.dataUnitId);
253
- const dataBindersFiltered = dataBinders.filter((dataBinder) => JSON.stringify(dataBinder) !== JSON.stringify(this));
257
+ const dataBindersFiltered = dataBinders.filter((dataBinder) => dataBinder.dataBinderId !== this.dataBinderId);
254
258
  dataBindersByDataUnit.set(this._dataUnit.dataUnitId, dataBindersFiltered);
255
259
  ApplicationContext.setContextValue("__DATABINDER_BY_DATAUNIT__", dataBindersByDataUnit);
256
260
  }
@@ -6,7 +6,7 @@ import './DialogType-54a62731.js';
6
6
  import './CheckMode-bdb2ec19.js';
7
7
  import { C as CustomEditorSource, a as CustomRenderSource } from './ICustomRender-875b5a40.js';
8
8
  import { D as DISTINCT_FILTER_NAME_PREFIX, E as EZ_GRID_LOADING_SOURCE } from './constants-4e0d35b7.js';
9
- import { b as buildFieldMetadata, R as RecordValidationProcessor } from './RecordValidationProcessor-b00b8b77.js';
9
+ import { b as buildFieldMetadata, R as RecordValidationProcessor } from './RecordValidationProcessor-9c6cc267.js';
10
10
 
11
11
  /**
12
12
  * @ag-grid-community/all-modules - Advanced Data Grid / Data Table supporting Javascript / Typescript / React / Angular / Vue * @version v28.2.1
@@ -118849,6 +118849,73 @@ class DataSourceInterceptor {
118849
118849
  }
118850
118850
 
118851
118851
  class DataSource {
118852
+ handleSavingCanceled(action) {
118853
+ var _a, _b, _c, _d;
118854
+ if (!((_a = action.payload) === null || _a === void 0 ? void 0 : _a.fields) || !((_b = action.payload) === null || _b === void 0 ? void 0 : _b.recordId))
118855
+ return;
118856
+ 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);
118857
+ }
118858
+ handleDataChanged(action) {
118859
+ var _a, _b;
118860
+ if (!this._options.enableGridInsert) {
118861
+ this.handleRefresh(action);
118862
+ return;
118863
+ }
118864
+ this.updateGridRowNodes((_b = (_a = action.payload) === null || _a === void 0 ? void 0 : _a.records) !== null && _b !== void 0 ? _b : []);
118865
+ }
118866
+ /**
118867
+ * Nesse ponto, o registro já se encontra atualizado no DU,
118868
+ * basta então passar seu valor para que a garde possa atualizar sua linha.
118869
+ */
118870
+ updateGridRowNodes(recordIDList) {
118871
+ const recordsToUpdate = recordIDList === null || recordIDList === void 0 ? void 0 : recordIDList.map(id => this.getRecordById(id));
118872
+ this._controller.updateRows(recordsToUpdate);
118873
+ }
118874
+ getRecordById(recordId) {
118875
+ return this._dataUnit.records.find(record => record['__record__id__'] === recordId);
118876
+ }
118877
+ /**
118878
+ * Em caso de necessidade de reload (isWaitingToReload), eh preciso chamar o dataUnit.gotoPage, pois ele aplica tambem a ordenacao dos registros,
118879
+ * enquanto que o _controller.refresh apenas recarrega os dados na ordem que atua.
118880
+ */
118881
+ handleRefreshOrReload(action) {
118882
+ if (this._dataUnit.isWaitingToReload()) {
118883
+ this.handleReload();
118884
+ return;
118885
+ }
118886
+ this.handleRefresh(action);
118887
+ }
118888
+ handleReload() {
118889
+ this._dataUnit.setWaitingToReload(false);
118890
+ this._dataUnit.gotoPage(0);
118891
+ }
118892
+ handleRefresh(action) {
118893
+ if (this.isSilentChange(action)) {
118894
+ return;
118895
+ }
118896
+ this._controller.refresh(action.type === Action.DATA_SAVED);
118897
+ }
118898
+ handleRecordsAdded() {
118899
+ if (this._options.enableGridInsert) {
118900
+ this._controller.refresh();
118901
+ this.focusOnNewRecord();
118902
+ }
118903
+ }
118904
+ focusOnNewRecord() {
118905
+ /**
118906
+ * O SetTimeout eh utilizado pois é preciso aguardar que o novo registro seja renderizado na grade.
118907
+ * Tentamos utilizar a api da grade para adicionar um event listener, porém na versão que utilizamos, não existe
118908
+ * algo que resolva nosso cenário.
118909
+ *
118910
+ * Sugiro no futuro utilizar algo como o applyServerSideTransaction, porém será preciso lidar com os handlers
118911
+ * e callbacks implementados no AgGridController e GridEditionManager.
118912
+ */
118913
+ setTimeout(() => {
118914
+ var _a;
118915
+ const newRowIndex = ((_a = this._dataUnit.records) === null || _a === void 0 ? void 0 : _a.length) - 1;
118916
+ this._controller.startEditionOnRowByIndex(newRowIndex);
118917
+ }, 500);
118918
+ }
118852
118919
  updateLoadedRecords(action) {
118853
118920
  const records = action.payload;
118854
118921
  if ((records === null || records === void 0 ? void 0 : records.length) > 0) {
@@ -118900,15 +118967,20 @@ class DataSource {
118900
118967
  this._options.onPaginationUpdate(this._dataUnit.getPaginationInfo());
118901
118968
  }
118902
118969
  break;
118903
- case Action.RECORDS_REMOVED:
118970
+ case Action.RECORDS_ADDED:
118971
+ this.handleRecordsAdded();
118972
+ break;
118904
118973
  case Action.DATA_SAVED:
118905
118974
  case Action.EDITION_CANCELED:
118975
+ this._controller.clearInvalidCells(action.type);
118976
+ this.handleRefreshOrReload(action);
118977
+ break;
118906
118978
  case Action.DATA_CHANGED:
118907
118979
  case Action.DATA_RESOLVED:
118908
- if (this.isSilentChange(action)) {
118909
- return;
118910
- }
118911
- this._controller.refresh();
118980
+ this.handleDataChanged(action);
118981
+ break;
118982
+ case Action.RECORDS_REMOVED:
118983
+ this.handleRefresh(action);
118912
118984
  break;
118913
118985
  case Action.SELECTION_CHANGED:
118914
118986
  case Action.NEXT_SELECTED:
@@ -118918,6 +118990,9 @@ class DataSource {
118918
118990
  case Action.RECORD_LOADED:
118919
118991
  this.updateLoadedRecords(action);
118920
118992
  break;
118993
+ case Action.SAVING_CANCELED:
118994
+ this.handleSavingCanceled(action);
118995
+ break;
118921
118996
  }
118922
118997
  };
118923
118998
  this._dataUnit = dataUnit;
@@ -118939,6 +119014,9 @@ class DataSource {
118939
119014
  setAutoFocus(autoFocus) {
118940
119015
  this._options.autoFocus = autoFocus;
118941
119016
  }
119017
+ setEnableGridInsert(enable) {
119018
+ this._options.enableGridInsert = enable;
119019
+ }
118942
119020
  getRows(params) {
118943
119021
  if (this.needReload(params)) {
118944
119022
  this._lastLoadingParams = params;
@@ -119401,6 +119479,7 @@ const buildSearch = ({ name, required, readOnly, eGridCell, dataUnit }) => {
119401
119479
  />`);
119402
119480
  const loader = ApplicationContext.getContextValue("__EZUI__SEARCH__OPTION__LOADER__");
119403
119481
  ezSearch.optionLoader = (argument) => loader(argument, name, dataUnit);
119482
+ ezSearch.fromGrid = true;
119404
119483
  ezSearch.listOptionsPosition = { verticalPosition: 29, bottomLimit: getViewPortHeight(eGridCell), hardPosition: true };
119405
119484
  ezSearch.valueGetter = () => ezSearch.getValueAsync();
119406
119485
  return ezSearch;
@@ -119466,6 +119545,8 @@ class EzGridCustomCellEditor extends EzCellEditor {
119466
119545
  this._defaultGui = this.getDefaultGui();
119467
119546
  const fieldMetadata = super.getFieldMetadata();
119468
119547
  this._params = {
119548
+ cellPossition: getViewPortHeight(params.eGridCell),
119549
+ eGridCell: params.eGridCell,
119469
119550
  value: params.value,
119470
119551
  charPress: params.charPress,
119471
119552
  currentEditor: this._defaultGui,
@@ -119503,12 +119584,17 @@ class EzGridCustomCellEditor extends EzCellEditor {
119503
119584
  const element = HTMLBuilder.parseElement(editorElement);
119504
119585
  return element;
119505
119586
  }
119587
+ this._customGui = editorElement;
119506
119588
  return editorElement;
119507
119589
  }
119508
119590
  setValue(value) {
119509
119591
  this._value = value;
119510
119592
  }
119511
119593
  getValue() {
119594
+ if (this._customGui.getValue)
119595
+ return this._customGui.getValue();
119596
+ if (this._customGui.hasAttribute('value'))
119597
+ return this._customGui.value;
119512
119598
  return this._value;
119513
119599
  }
119514
119600
  }
@@ -119592,15 +119678,16 @@ class EzGridCustomCellRender extends EzCellRender {
119592
119678
  }
119593
119679
 
119594
119680
  class GridEditionManager {
119595
- constructor(dataUnit, useEnterLikeTab, recordsValidator, editionIsDisabled, customEditors, customRenders) {
119681
+ constructor(dataUnit, useEnterLikeTab, recordsValidator, editionIsDisabled, customEditors, customRenders, enableContinuousInsert) {
119596
119682
  this._dataUnit = dataUnit;
119597
119683
  this._recordValidationProcessor = new RecordValidationProcessor(this._dataUnit, {
119598
119684
  getRequiredFields: () => this.getRequiredFields(),
119599
- markAsInvalid: () => { },
119600
- getMessageForField: () => null
119685
+ markAsInvalid: (invalidField, recordId) => { this.setInvalidCell(invalidField, recordId); },
119686
+ getMessageForField: () => null,
119601
119687
  }, recordsValidator);
119602
119688
  this._useEnterLikeTab = useEnterLikeTab;
119603
119689
  this._editionIsDisabled = editionIsDisabled;
119690
+ this._enableContinuousInsert = enableContinuousInsert;
119604
119691
  this._customEditors = customEditors;
119605
119692
  this._customRenders = customRenders;
119606
119693
  }
@@ -119615,27 +119702,49 @@ class GridEditionManager {
119615
119702
  };
119616
119703
  return options;
119617
119704
  }
119705
+ canContinuousInsert() {
119706
+ var _a;
119707
+ return this._enableContinuousInsert && (this._dataUnit.records.length - 1) === ((_a = this._lastCellEdited) === null || _a === void 0 ? void 0 : _a.rowIndex);
119708
+ }
119618
119709
  proceedAutoSave() {
119619
119710
  if (!this._dataUnit.isDirty()) {
119620
119711
  this.saveSuccess();
119621
119712
  return;
119622
119713
  }
119623
- if (!this._isGridEdition) {
119714
+ if (!this._isGridEdition || this._dataUnit.hasNewRecord()) {
119624
119715
  return;
119625
119716
  }
119626
119717
  const currentRercord = this._dataUnit.getSelectedRecord();
119627
119718
  if (currentRercord == undefined) {
119628
119719
  return;
119629
119720
  }
119721
+ this._invalidCell = undefined;
119630
119722
  this._recordValidationProcessor
119631
- .validate()
119723
+ .validate(true)
119632
119724
  .then(() => {
119633
119725
  this._dataUnit.saveData()
119634
- .then(() => this.saveSuccess())
119726
+ .then(() => {
119727
+ if (this.canContinuousInsert()) {
119728
+ this._dataUnit.addRecord();
119729
+ }
119730
+ else {
119731
+ this.saveSuccess();
119732
+ }
119733
+ })
119635
119734
  .catch(reason => this.saveFail(reason));
119636
119735
  })
119637
119736
  .catch(reason => this.saveFail(reason));
119638
119737
  }
119738
+ async recordValidate() {
119739
+ if (!this._dataUnit.isDirty())
119740
+ return;
119741
+ try {
119742
+ this._invalidCell = undefined;
119743
+ await this._recordValidationProcessor.validate(false);
119744
+ }
119745
+ catch (error) { }
119746
+ this._gridOptions.api.refreshCells({ force: true });
119747
+ }
119639
119748
  navigateByEnterKey(keyboardEvent) {
119640
119749
  const backwards = keyboardEvent.shiftKey;
119641
119750
  if (this._useEnterLikeTab) {
@@ -119844,6 +119953,34 @@ class GridEditionManager {
119844
119953
  setCellRenders(customRenders) {
119845
119954
  this._customRenders = customRenders;
119846
119955
  }
119956
+ setInvalidCell(invalidCell, recordId) {
119957
+ this._invalidCell = { field: invalidCell, recordId };
119958
+ }
119959
+ getInvalidCell() {
119960
+ return this._invalidCell;
119961
+ }
119962
+ clearInvalidCells(action) {
119963
+ this._invalidCell = undefined;
119964
+ if (action === Action.EDITION_CANCELED) {
119965
+ this._isGridEdition = false;
119966
+ }
119967
+ else if (action === Action.DATA_SAVED && this.canContinuousInsert()) {
119968
+ this._dataUnit.addRecord();
119969
+ }
119970
+ }
119971
+ setEnableContinuousInsert(enable) {
119972
+ this._enableContinuousInsert = enable;
119973
+ }
119974
+ hasInvalidField(fieldName, recordId) {
119975
+ if (!this.hasInvalidCell())
119976
+ return false;
119977
+ return this._invalidCell.field.name === fieldName && this._invalidCell.recordId === recordId;
119978
+ }
119979
+ hasInvalidCell() {
119980
+ if (!this._invalidCell || !this._invalidCell.field || !this._invalidCell.recordId)
119981
+ return false;
119982
+ return true;
119983
+ }
119847
119984
  }
119848
119985
  class TargetEdition {
119849
119986
  constructor(rowIndex, column, backwards) {
@@ -119887,6 +120024,8 @@ class AgGridController {
119887
120024
  this._filteredColumns = new Map();
119888
120025
  this._filterColumnleftPosition = 0;
119889
120026
  this._customFormatters = new Map();
120027
+ this._gridShowDom = false;
120028
+ this.peddingExecutionsOnGridShow = [];
119890
120029
  this._enterprise = enterprise;
119891
120030
  }
119892
120031
  getGridConfig() {
@@ -119972,7 +120111,7 @@ class AgGridController {
119972
120111
  this._doubleClickCallBack = options.onDoubleClick;
119973
120112
  this._multipleSelection = options.allowMultipleSelection;
119974
120113
  this._dataUnit = options.dataUnit;
119975
- this._editionManager = new GridEditionManager(this._dataUnit, options.useEnterLikeTab, options.recordsValidator, options.editionIsDisabled, options.customEditors || this._customEditors, options.customRenders || this._customRenders);
120114
+ this._editionManager = new GridEditionManager(this._dataUnit, options.useEnterLikeTab, options.recordsValidator, options.editionIsDisabled, options.customEditors || this._customEditors, options.customRenders || this._customRenders, options.enableContinuousInsert);
119976
120115
  this._statusResolver = options.statusResolver;
119977
120116
  if (this._dataUnit) {
119978
120117
  this._dataUnit.sortingProvider = this;
@@ -119992,6 +120131,9 @@ class AgGridController {
119992
120131
  defaultColDef: {
119993
120132
  headerClass: 'ez-grid__cell-header',
119994
120133
  cellClass: 'ez-grid__cell-body',
120134
+ cellClassRules: {
120135
+ 'invalidValue': (params) => this._editionManager.hasInvalidField(params.colDef.field, params.data["__record__id__"]),
120136
+ },
119995
120137
  cellStyle: {
119996
120138
  height: '100%'
119997
120139
  }
@@ -120022,10 +120164,6 @@ class AgGridController {
120022
120164
  else {
120023
120165
  this._grid = new Grid(container, this._gridOptions);
120024
120166
  }
120025
- container.addEventListener('focusout', (event) => {
120026
- if (!container.contains(event.relatedTarget))
120027
- this._gridOptions.api.clearFocusedCell();
120028
- });
120029
120167
  const selection = (_a = this._dataUnit) === null || _a === void 0 ? void 0 : _a.getSelectionInfo();
120030
120168
  if (selection === null || selection === void 0 ? void 0 : selection.isAllRecords()) {
120031
120169
  this.selectAll(true);
@@ -120035,6 +120173,23 @@ class AgGridController {
120035
120173
  }
120036
120174
  this._gridOptions.api.setHeaderHeight(this.getHeaderRowHeight());
120037
120175
  this._customFormatters = options.customFormatters;
120176
+ const observerCallback = (entries) => {
120177
+ entries.forEach(entry => {
120178
+ if (entry.isIntersecting) {
120179
+ this._gridShowDom = true;
120180
+ this.peddingExecutionsOnGridShow.forEach(func => func());
120181
+ this.peddingExecutionsOnGridShow = [];
120182
+ }
120183
+ else {
120184
+ this._gridShowDom = false;
120185
+ }
120186
+ });
120187
+ };
120188
+ this.observer = new IntersectionObserver(observerCallback, {
120189
+ root: null,
120190
+ threshold: 0.1
120191
+ });
120192
+ this.observer.observe(container);
120038
120193
  }
120039
120194
  }
120040
120195
  processFormatterCellCallback(params) {
@@ -120225,10 +120380,16 @@ class AgGridController {
120225
120380
  throw new Error('Erro interno: Grid ainda não inicializado.');
120226
120381
  }
120227
120382
  }
120228
- updateRows() {
120383
+ updateRows(rows) {
120229
120384
  if (this._grid === undefined) {
120230
120385
  throw new Error('Erro interno: Grid ainda não inicializado.');
120231
120386
  }
120387
+ rows === null || rows === void 0 ? void 0 : rows.forEach(row => this.updateRowData(row));
120388
+ }
120389
+ updateRowData(row) {
120390
+ const node = this._gridOptions.api.getRowNode(row[this._idAttribName]);
120391
+ node.setData(Object.assign({}, row));
120392
+ this._editionManager.recordValidate();
120232
120393
  }
120233
120394
  selectAll(quietly = false) {
120234
120395
  try {
@@ -120311,14 +120472,42 @@ class AgGridController {
120311
120472
  });
120312
120473
  r.setData(data);
120313
120474
  });
120475
+ this._gridOptions.api.refreshCells({ force: true });
120476
+ const invalidCell = this._editionManager.getInvalidCell();
120477
+ if (invalidCell) {
120478
+ const rowNode = this._gridOptions.api.getRowNode(invalidCell.recordId);
120479
+ if (rowNode && invalidCell.field) {
120480
+ this.startEdition(rowNode.rowIndex, this._gridOptions.columnApi.getColumn(invalidCell.field.name));
120481
+ }
120482
+ }
120314
120483
  }
120315
120484
  }
120316
- refresh() {
120485
+ savingCanceled(fields, recordId) {
120486
+ const displayedColumns = this._gridOptions.columnApi.getAllDisplayedColumns();
120487
+ const rowIndex = this._gridOptions.api.getRowNode(recordId).rowIndex;
120488
+ const columnFocus = displayedColumns.find(column => this.isColumnEditable(rowIndex, column) && fields.find(field => field.name === column.getColId()));
120489
+ this.focusByCollAndRow(columnFocus, rowIndex);
120490
+ this.startEdition(rowIndex, columnFocus);
120491
+ }
120492
+ refresh(scrollToSelectedRow = false) {
120317
120493
  if (this._grid === undefined) {
120318
120494
  throw new Error('Erro interno: Grid ainda não inicializado.');
120319
120495
  }
120320
120496
  this._gridOptions.api.refreshServerSide({ purge: true });
120321
120497
  this._options.onRefresh();
120498
+ if (scrollToSelectedRow)
120499
+ this.scrollToSelectedRow();
120500
+ }
120501
+ scrollToSelectedRow() {
120502
+ const rowNode = this._gridOptions.api.getSelectedNodes();
120503
+ if (!rowNode || rowNode.length === 0)
120504
+ return;
120505
+ if (this._gridShowDom) {
120506
+ this._gridOptions.api.ensureNodeVisible(rowNode[0]);
120507
+ }
120508
+ else {
120509
+ this.peddingExecutionsOnGridShow.push(() => this._gridOptions.api.ensureNodeVisible(rowNode[0]));
120510
+ }
120322
120511
  }
120323
120512
  focusOnGridContainer() {
120324
120513
  this._container.setAttribute('tabindex', '-1');
@@ -120337,6 +120526,14 @@ class AgGridController {
120337
120526
  var _a;
120338
120527
  (_a = this._dataSource) === null || _a === void 0 ? void 0 : _a.setAutoFocus(autoFocus);
120339
120528
  }
120529
+ setEnableGridInsert(enable) {
120530
+ var _a;
120531
+ (_a = this._dataSource) === null || _a === void 0 ? void 0 : _a.setEnableGridInsert(enable);
120532
+ }
120533
+ setEnableContinuousInsert(enable) {
120534
+ var _a;
120535
+ (_a = this._editionManager) === null || _a === void 0 ? void 0 : _a.setEnableContinuousInsert(enable);
120536
+ }
120340
120537
  setFocusFirstRow() {
120341
120538
  const firstRow = this._gridOptions.api.getDisplayedRowAtIndex(0);
120342
120539
  if (firstRow) {
@@ -120352,9 +120549,38 @@ class AgGridController {
120352
120549
  this.setFocusOnRow(lastRow.rowIndex);
120353
120550
  }
120354
120551
  }
120552
+ startEditionOnRowByIndex(rowIndex) {
120553
+ const firstCol = this.getFirstEditableColl(rowIndex);
120554
+ this.focusByCollAndRow(firstCol, rowIndex);
120555
+ this.startEdition(rowIndex, firstCol);
120556
+ }
120557
+ startEdition(rowIndex, firstCol) {
120558
+ this._gridOptions.api.clearRangeSelection();
120559
+ this._gridOptions.api.addCellRange({ rowStartIndex: rowIndex, rowEndIndex: rowIndex, columns: [firstCol] });
120560
+ this._gridOptions.api.setFocusedCell(rowIndex, firstCol);
120561
+ this._gridOptions.api.startEditingCell({ rowIndex, colKey: firstCol });
120562
+ const cellEditor = this._gridOptions.api.getCellEditorInstances()[0];
120563
+ if (cellEditor) {
120564
+ cellEditor.focusIn();
120565
+ }
120566
+ }
120567
+ getFirstEditableColl(rowIndex) {
120568
+ const displayedColumns = this._gridOptions.columnApi.getAllDisplayedColumns();
120569
+ return displayedColumns.find(column => this.isColumnEditable(rowIndex, column));
120570
+ }
120571
+ isColumnEditable(rowIndex, column) {
120572
+ if (column.getColDef().headerName === '' || rowIndex === -1)
120573
+ return false;
120574
+ const rowId = this._dataUnit.records[rowIndex][this._idAttribName];
120575
+ const rowNode = this._gridOptions.api.getRowNode(rowId);
120576
+ return column.isCellEditable(rowNode);
120577
+ }
120355
120578
  setFocusOnRow(rowIndex) {
120356
120579
  let displayedColumns = this._gridOptions.columnApi.getAllDisplayedColumns();
120357
- let firstCell = displayedColumns.find(column => column.getColDef().headerName !== '');
120580
+ let firstColl = displayedColumns.find(column => column.getColDef().headerName !== '');
120581
+ this.focusByCollAndRow(firstColl, rowIndex);
120582
+ }
120583
+ focusByCollAndRow(firstCell, rowIndex) {
120358
120584
  this._gridOptions.api.ensureColumnVisible(firstCell);
120359
120585
  this._gridOptions.api.ensureIndexVisible(rowIndex);
120360
120586
  this._gridOptions.api.setFocusedCell(rowIndex, firstCell);
@@ -120734,6 +120960,15 @@ class AgGridController {
120734
120960
  this._editionManager.setCellRenders(customRenders);
120735
120961
  (_a = this._gridOptions) === null || _a === void 0 ? void 0 : _a.api.redrawRows();
120736
120962
  }
120963
+ clearInvalidCells(action) {
120964
+ if (!this._editionManager)
120965
+ return;
120966
+ this._editionManager.clearInvalidCells(action);
120967
+ this._gridOptions.api.refreshCells({ force: true });
120968
+ }
120969
+ destroy() {
120970
+ this.observer.disconnect();
120971
+ }
120737
120972
  }
120738
120973
 
120739
120974
  function enableSelectAll(total) {
@@ -120980,6 +121215,8 @@ const EzGrid = class {
120980
121215
  this.recordsValidator = undefined;
120981
121216
  this.canEdit = true;
120982
121217
  this.autoFocus = true;
121218
+ this.enableGridInsert = false;
121219
+ this.enableContinuousInsert = true;
120983
121220
  }
120984
121221
  /**
120985
121222
  * Aplica a definição de colunas.
@@ -121306,6 +121543,8 @@ const EzGrid = class {
121306
121543
  editionIsDisabled: () => !this.canEdit,
121307
121544
  customFormatters: this._customFormatters,
121308
121545
  autoFocus: this.autoFocus,
121546
+ enableGridInsert: this.enableGridInsert,
121547
+ enableContinuousInsert: this.enableContinuousInsert,
121309
121548
  onRefresh: () => {
121310
121549
  if (this.dataUnit) {
121311
121550
  this.setSelection(this.dataUnit.getSelectionInfo());
@@ -121398,6 +121637,11 @@ const EzGrid = class {
121398
121637
  }
121399
121638
  componentDidUpdate() {
121400
121639
  this._gridController.setAutoFocus(this.autoFocus);
121640
+ this._gridController.setEnableGridInsert(this.enableGridInsert);
121641
+ this._gridController.setEnableContinuousInsert(this.enableContinuousInsert);
121642
+ if (this.dataUnit) {
121643
+ this.setSelection(this.dataUnit.getSelectionInfo());
121644
+ }
121401
121645
  }
121402
121646
  getDataSource() {
121403
121647
  var _a;
@@ -31,6 +31,7 @@ const EzModalContainer = class {
31
31
  this.okButtonLabel = undefined;
32
32
  this.cancelButtonStatus = undefined;
33
33
  this.okButtonStatus = undefined;
34
+ this.showCloseButton = true;
34
35
  }
35
36
  async handleEzModalAction(event) {
36
37
  var _a;
@@ -67,7 +68,7 @@ const EzModalContainer = class {
67
68
  this._closeButton.focus();
68
69
  }
69
70
  render() {
70
- return (h(Host, null, h("button", { class: "ez-modal-container__focus-ctrl", onFocusin: () => this.focusLast() }), h("div", { ref: ref => this._modalRef = ref, tabIndex: -1, class: "ez-modal-container__header-container" }, this.showTitleBar && (h("div", { class: "ez-modal-container__header ez-margin-bottom--large" }, h("div", { class: "ez-col ez-align--middle ez-modal-container__title" }, h("h2", { class: "ez-text ez-title--large ez-title--primary ez-text--bold ez-margin-vertical--extra-small" }, this.modalTitle), this.modalSubTitle && (h("div", { class: "ez-text ez-text--medium ez-text--primary ez-margin-vertical--extra-small" }, this.modalSubTitle))), h("button", { ref: ref => this._closeButton = ref, class: "ez-modal-container__close-button", onClick: () => this.ezModalAction.emit(ModalAction$1.CLOSE) }, h("ez-icon", { class: "ez-modal-container__close-icon", size: "medium", iconName: "close" }))))), h("div", { class: "ez-modal-container__content" }, h("slot", null)), h("div", { class: "ez-modal-container__footer" }, this.cancelIsVisible() && (h("ez-button", { label: this.cancelButtonLabel, enabled: this.cancelButtonStatus !== ModalButtonStatus$1.DISABLED, onClick: () => this.ezModalAction.emit(ModalAction$1.CANCEL) })), this.okIsVisible() && (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) }))), h("button", { class: "ez-modal-container__focus-ctrl", onFocusin: () => this.focusFirst() })));
71
+ return (h(Host, null, h("button", { class: "ez-modal-container__focus-ctrl", onFocusin: () => this.focusLast() }), h("div", { ref: ref => this._modalRef = ref, tabIndex: -1, class: "ez-modal-container__header-container" }, this.showTitleBar && (h("div", { class: "ez-modal-container__header ez-margin-bottom--large" }, h("div", { class: "ez-col ez-align--middle ez-modal-container__title" }, h("h2", { class: "ez-text ez-title--large ez-title--primary ez-text--bold ez-margin-vertical--extra-small" }, this.modalTitle), this.modalSubTitle && (h("div", { class: "ez-text ez-text--medium ez-text--primary ez-margin-vertical--extra-small" }, this.modalSubTitle))), (this.showCloseButton && h("button", { ref: ref => this._closeButton = ref, class: "ez-modal-container__close-button", onClick: () => this.ezModalAction.emit(ModalAction$1.CLOSE) }, h("ez-icon", { class: "ez-modal-container__close-icon", size: "medium", iconName: "close" })))))), h("div", { class: "ez-modal-container__content" }, h("slot", null)), h("div", { class: "ez-modal-container__footer" }, this.cancelIsVisible() && (h("ez-button", { label: this.cancelButtonLabel, enabled: this.cancelButtonStatus !== ModalButtonStatus$1.DISABLED, onClick: () => this.ezModalAction.emit(ModalAction$1.CANCEL) })), this.okIsVisible() && (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) }))), h("button", { class: "ez-modal-container__focus-ctrl", onFocusin: () => this.focusFirst() })));
71
72
  }
72
73
  get _element() { return getElement(this); }
73
74
  };