@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
@@ -41,6 +41,8 @@ export default class AgGridController {
41
41
  this._filteredColumns = new Map();
42
42
  this._filterColumnleftPosition = 0;
43
43
  this._customFormatters = new Map();
44
+ this._gridShowDom = false;
45
+ this.peddingExecutionsOnGridShow = [];
44
46
  this._enterprise = enterprise;
45
47
  }
46
48
  getGridConfig() {
@@ -126,7 +128,7 @@ export default class AgGridController {
126
128
  this._doubleClickCallBack = options.onDoubleClick;
127
129
  this._multipleSelection = options.allowMultipleSelection;
128
130
  this._dataUnit = options.dataUnit;
129
- this._editionManager = new GridEditionManager(this._dataUnit, options.useEnterLikeTab, options.recordsValidator, options.editionIsDisabled, options.customEditors || this._customEditors, options.customRenders || this._customRenders);
131
+ this._editionManager = new GridEditionManager(this._dataUnit, options.useEnterLikeTab, options.recordsValidator, options.editionIsDisabled, options.customEditors || this._customEditors, options.customRenders || this._customRenders, options.enableContinuousInsert);
130
132
  this._statusResolver = options.statusResolver;
131
133
  if (this._dataUnit) {
132
134
  this._dataUnit.sortingProvider = this;
@@ -146,6 +148,9 @@ export default class AgGridController {
146
148
  defaultColDef: {
147
149
  headerClass: 'ez-grid__cell-header',
148
150
  cellClass: 'ez-grid__cell-body',
151
+ cellClassRules: {
152
+ 'invalidValue': (params) => this._editionManager.hasInvalidField(params.colDef.field, params.data["__record__id__"]),
153
+ },
149
154
  cellStyle: {
150
155
  height: '100%'
151
156
  }
@@ -176,10 +181,6 @@ export default class AgGridController {
176
181
  else {
177
182
  this._grid = new Grid(container, this._gridOptions);
178
183
  }
179
- container.addEventListener('focusout', (event) => {
180
- if (!container.contains(event.relatedTarget))
181
- this._gridOptions.api.clearFocusedCell();
182
- });
183
184
  const selection = (_a = this._dataUnit) === null || _a === void 0 ? void 0 : _a.getSelectionInfo();
184
185
  if (selection === null || selection === void 0 ? void 0 : selection.isAllRecords()) {
185
186
  this.selectAll(true);
@@ -189,6 +190,23 @@ export default class AgGridController {
189
190
  }
190
191
  this._gridOptions.api.setHeaderHeight(this.getHeaderRowHeight());
191
192
  this._customFormatters = options.customFormatters;
193
+ const observerCallback = (entries) => {
194
+ entries.forEach(entry => {
195
+ if (entry.isIntersecting) {
196
+ this._gridShowDom = true;
197
+ this.peddingExecutionsOnGridShow.forEach(func => func());
198
+ this.peddingExecutionsOnGridShow = [];
199
+ }
200
+ else {
201
+ this._gridShowDom = false;
202
+ }
203
+ });
204
+ };
205
+ this.observer = new IntersectionObserver(observerCallback, {
206
+ root: null,
207
+ threshold: 0.1
208
+ });
209
+ this.observer.observe(container);
192
210
  }
193
211
  }
194
212
  processFormatterCellCallback(params) {
@@ -379,10 +397,16 @@ export default class AgGridController {
379
397
  throw new Error('Erro interno: Grid ainda não inicializado.');
380
398
  }
381
399
  }
382
- updateRows() {
400
+ updateRows(rows) {
383
401
  if (this._grid === undefined) {
384
402
  throw new Error('Erro interno: Grid ainda não inicializado.');
385
403
  }
404
+ rows === null || rows === void 0 ? void 0 : rows.forEach(row => this.updateRowData(row));
405
+ }
406
+ updateRowData(row) {
407
+ const node = this._gridOptions.api.getRowNode(row[this._idAttribName]);
408
+ node.setData(Object.assign({}, row));
409
+ this._editionManager.recordValidate();
386
410
  }
387
411
  selectAll(quietly = false) {
388
412
  try {
@@ -465,14 +489,42 @@ export default class AgGridController {
465
489
  });
466
490
  r.setData(data);
467
491
  });
492
+ this._gridOptions.api.refreshCells({ force: true });
493
+ const invalidCell = this._editionManager.getInvalidCell();
494
+ if (invalidCell) {
495
+ const rowNode = this._gridOptions.api.getRowNode(invalidCell.recordId);
496
+ if (rowNode && invalidCell.field) {
497
+ this.startEdition(rowNode.rowIndex, this._gridOptions.columnApi.getColumn(invalidCell.field.name));
498
+ }
499
+ }
468
500
  }
469
501
  }
470
- refresh() {
502
+ savingCanceled(fields, recordId) {
503
+ const displayedColumns = this._gridOptions.columnApi.getAllDisplayedColumns();
504
+ const rowIndex = this._gridOptions.api.getRowNode(recordId).rowIndex;
505
+ const columnFocus = displayedColumns.find(column => this.isColumnEditable(rowIndex, column) && fields.find(field => field.name === column.getColId()));
506
+ this.focusByCollAndRow(columnFocus, rowIndex);
507
+ this.startEdition(rowIndex, columnFocus);
508
+ }
509
+ refresh(scrollToSelectedRow = false) {
471
510
  if (this._grid === undefined) {
472
511
  throw new Error('Erro interno: Grid ainda não inicializado.');
473
512
  }
474
513
  this._gridOptions.api.refreshServerSide({ purge: true });
475
514
  this._options.onRefresh();
515
+ if (scrollToSelectedRow)
516
+ this.scrollToSelectedRow();
517
+ }
518
+ scrollToSelectedRow() {
519
+ const rowNode = this._gridOptions.api.getSelectedNodes();
520
+ if (!rowNode || rowNode.length === 0)
521
+ return;
522
+ if (this._gridShowDom) {
523
+ this._gridOptions.api.ensureNodeVisible(rowNode[0]);
524
+ }
525
+ else {
526
+ this.peddingExecutionsOnGridShow.push(() => this._gridOptions.api.ensureNodeVisible(rowNode[0]));
527
+ }
476
528
  }
477
529
  focusOnGridContainer() {
478
530
  this._container.setAttribute('tabindex', '-1');
@@ -491,6 +543,14 @@ export default class AgGridController {
491
543
  var _a;
492
544
  (_a = this._dataSource) === null || _a === void 0 ? void 0 : _a.setAutoFocus(autoFocus);
493
545
  }
546
+ setEnableGridInsert(enable) {
547
+ var _a;
548
+ (_a = this._dataSource) === null || _a === void 0 ? void 0 : _a.setEnableGridInsert(enable);
549
+ }
550
+ setEnableContinuousInsert(enable) {
551
+ var _a;
552
+ (_a = this._editionManager) === null || _a === void 0 ? void 0 : _a.setEnableContinuousInsert(enable);
553
+ }
494
554
  setFocusFirstRow() {
495
555
  const firstRow = this._gridOptions.api.getDisplayedRowAtIndex(0);
496
556
  if (firstRow) {
@@ -506,9 +566,38 @@ export default class AgGridController {
506
566
  this.setFocusOnRow(lastRow.rowIndex);
507
567
  }
508
568
  }
569
+ startEditionOnRowByIndex(rowIndex) {
570
+ const firstCol = this.getFirstEditableColl(rowIndex);
571
+ this.focusByCollAndRow(firstCol, rowIndex);
572
+ this.startEdition(rowIndex, firstCol);
573
+ }
574
+ startEdition(rowIndex, firstCol) {
575
+ this._gridOptions.api.clearRangeSelection();
576
+ this._gridOptions.api.addCellRange({ rowStartIndex: rowIndex, rowEndIndex: rowIndex, columns: [firstCol] });
577
+ this._gridOptions.api.setFocusedCell(rowIndex, firstCol);
578
+ this._gridOptions.api.startEditingCell({ rowIndex, colKey: firstCol });
579
+ const cellEditor = this._gridOptions.api.getCellEditorInstances()[0];
580
+ if (cellEditor) {
581
+ cellEditor.focusIn();
582
+ }
583
+ }
584
+ getFirstEditableColl(rowIndex) {
585
+ const displayedColumns = this._gridOptions.columnApi.getAllDisplayedColumns();
586
+ return displayedColumns.find(column => this.isColumnEditable(rowIndex, column));
587
+ }
588
+ isColumnEditable(rowIndex, column) {
589
+ if (column.getColDef().headerName === '' || rowIndex === -1)
590
+ return false;
591
+ const rowId = this._dataUnit.records[rowIndex][this._idAttribName];
592
+ const rowNode = this._gridOptions.api.getRowNode(rowId);
593
+ return column.isCellEditable(rowNode);
594
+ }
509
595
  setFocusOnRow(rowIndex) {
510
596
  let displayedColumns = this._gridOptions.columnApi.getAllDisplayedColumns();
511
- let firstCell = displayedColumns.find(column => column.getColDef().headerName !== '');
597
+ let firstColl = displayedColumns.find(column => column.getColDef().headerName !== '');
598
+ this.focusByCollAndRow(firstColl, rowIndex);
599
+ }
600
+ focusByCollAndRow(firstCell, rowIndex) {
512
601
  this._gridOptions.api.ensureColumnVisible(firstCell);
513
602
  this._gridOptions.api.ensureIndexVisible(rowIndex);
514
603
  this._gridOptions.api.setFocusedCell(rowIndex, firstCell);
@@ -888,4 +977,13 @@ export default class AgGridController {
888
977
  this._editionManager.setCellRenders(customRenders);
889
978
  (_a = this._gridOptions) === null || _a === void 0 ? void 0 : _a.api.redrawRows();
890
979
  }
980
+ clearInvalidCells(action) {
981
+ if (!this._editionManager)
982
+ return;
983
+ this._editionManager.clearInvalidCells(action);
984
+ this._gridOptions.api.refreshCells({ force: true });
985
+ }
986
+ destroy() {
987
+ this.observer.disconnect();
988
+ }
891
989
  }
@@ -2,6 +2,73 @@ import { Action, ObjectUtils } from '@sankhyalabs/core';
2
2
  import { EZ_GRID_LOADING_SOURCE } from "../../../../utils/constants";
3
3
  import { DataSourceInterceptor } from "./DataSourceInterceptor";
4
4
  export default class DataSource {
5
+ handleSavingCanceled(action) {
6
+ var _a, _b, _c, _d;
7
+ if (!((_a = action.payload) === null || _a === void 0 ? void 0 : _a.fields) || !((_b = action.payload) === null || _b === void 0 ? void 0 : _b.recordId))
8
+ return;
9
+ 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);
10
+ }
11
+ handleDataChanged(action) {
12
+ var _a, _b;
13
+ if (!this._options.enableGridInsert) {
14
+ this.handleRefresh(action);
15
+ return;
16
+ }
17
+ this.updateGridRowNodes((_b = (_a = action.payload) === null || _a === void 0 ? void 0 : _a.records) !== null && _b !== void 0 ? _b : []);
18
+ }
19
+ /**
20
+ * Nesse ponto, o registro já se encontra atualizado no DU,
21
+ * basta então passar seu valor para que a garde possa atualizar sua linha.
22
+ */
23
+ updateGridRowNodes(recordIDList) {
24
+ const recordsToUpdate = recordIDList === null || recordIDList === void 0 ? void 0 : recordIDList.map(id => this.getRecordById(id));
25
+ this._controller.updateRows(recordsToUpdate);
26
+ }
27
+ getRecordById(recordId) {
28
+ return this._dataUnit.records.find(record => record['__record__id__'] === recordId);
29
+ }
30
+ /**
31
+ * Em caso de necessidade de reload (isWaitingToReload), eh preciso chamar o dataUnit.gotoPage, pois ele aplica tambem a ordenacao dos registros,
32
+ * enquanto que o _controller.refresh apenas recarrega os dados na ordem que atua.
33
+ */
34
+ handleRefreshOrReload(action) {
35
+ if (this._dataUnit.isWaitingToReload()) {
36
+ this.handleReload();
37
+ return;
38
+ }
39
+ this.handleRefresh(action);
40
+ }
41
+ handleReload() {
42
+ this._dataUnit.setWaitingToReload(false);
43
+ this._dataUnit.gotoPage(0);
44
+ }
45
+ handleRefresh(action) {
46
+ if (this.isSilentChange(action)) {
47
+ return;
48
+ }
49
+ this._controller.refresh(action.type === Action.DATA_SAVED);
50
+ }
51
+ handleRecordsAdded() {
52
+ if (this._options.enableGridInsert) {
53
+ this._controller.refresh();
54
+ this.focusOnNewRecord();
55
+ }
56
+ }
57
+ focusOnNewRecord() {
58
+ /**
59
+ * O SetTimeout eh utilizado pois é preciso aguardar que o novo registro seja renderizado na grade.
60
+ * Tentamos utilizar a api da grade para adicionar um event listener, porém na versão que utilizamos, não existe
61
+ * algo que resolva nosso cenário.
62
+ *
63
+ * Sugiro no futuro utilizar algo como o applyServerSideTransaction, porém será preciso lidar com os handlers
64
+ * e callbacks implementados no AgGridController e GridEditionManager.
65
+ */
66
+ setTimeout(() => {
67
+ var _a;
68
+ const newRowIndex = ((_a = this._dataUnit.records) === null || _a === void 0 ? void 0 : _a.length) - 1;
69
+ this._controller.startEditionOnRowByIndex(newRowIndex);
70
+ }, 500);
71
+ }
5
72
  updateLoadedRecords(action) {
6
73
  const records = action.payload;
7
74
  if ((records === null || records === void 0 ? void 0 : records.length) > 0) {
@@ -53,15 +120,20 @@ export default class DataSource {
53
120
  this._options.onPaginationUpdate(this._dataUnit.getPaginationInfo());
54
121
  }
55
122
  break;
56
- case Action.RECORDS_REMOVED:
123
+ case Action.RECORDS_ADDED:
124
+ this.handleRecordsAdded();
125
+ break;
57
126
  case Action.DATA_SAVED:
58
127
  case Action.EDITION_CANCELED:
128
+ this._controller.clearInvalidCells(action.type);
129
+ this.handleRefreshOrReload(action);
130
+ break;
59
131
  case Action.DATA_CHANGED:
60
132
  case Action.DATA_RESOLVED:
61
- if (this.isSilentChange(action)) {
62
- return;
63
- }
64
- this._controller.refresh();
133
+ this.handleDataChanged(action);
134
+ break;
135
+ case Action.RECORDS_REMOVED:
136
+ this.handleRefresh(action);
65
137
  break;
66
138
  case Action.SELECTION_CHANGED:
67
139
  case Action.NEXT_SELECTED:
@@ -71,6 +143,9 @@ export default class DataSource {
71
143
  case Action.RECORD_LOADED:
72
144
  this.updateLoadedRecords(action);
73
145
  break;
146
+ case Action.SAVING_CANCELED:
147
+ this.handleSavingCanceled(action);
148
+ break;
74
149
  }
75
150
  };
76
151
  this._dataUnit = dataUnit;
@@ -92,6 +167,9 @@ export default class DataSource {
92
167
  setAutoFocus(autoFocus) {
93
168
  this._options.autoFocus = autoFocus;
94
169
  }
170
+ setEnableGridInsert(enable) {
171
+ this._options.enableGridInsert = enable;
172
+ }
95
173
  getRows(params) {
96
174
  if (this.needReload(params)) {
97
175
  this._lastLoadingParams = params;
@@ -1,19 +1,20 @@
1
- import { UserInterface } from "@sankhyalabs/core";
1
+ import { Action, UserInterface } from "@sankhyalabs/core";
2
2
  import { KeyCode } from "ag-grid-community";
3
3
  import { RecordValidationProcessor } from "../../../../utils/validators/recordvalidator/RecordValidationProcessor";
4
4
  import EzCellEditor from "./editor/EzCellEditor";
5
5
  import EzGridCustomCellEditor from "./components/EzGridCustomCellEditor";
6
6
  import EzGridCustomCellRender from "./components/EzGridCustomCellRender";
7
7
  export default class GridEditionManager {
8
- constructor(dataUnit, useEnterLikeTab, recordsValidator, editionIsDisabled, customEditors, customRenders) {
8
+ constructor(dataUnit, useEnterLikeTab, recordsValidator, editionIsDisabled, customEditors, customRenders, enableContinuousInsert) {
9
9
  this._dataUnit = dataUnit;
10
10
  this._recordValidationProcessor = new RecordValidationProcessor(this._dataUnit, {
11
11
  getRequiredFields: () => this.getRequiredFields(),
12
- markAsInvalid: () => { },
13
- getMessageForField: () => null
12
+ markAsInvalid: (invalidField, recordId) => { this.setInvalidCell(invalidField, recordId); },
13
+ getMessageForField: () => null,
14
14
  }, recordsValidator);
15
15
  this._useEnterLikeTab = useEnterLikeTab;
16
16
  this._editionIsDisabled = editionIsDisabled;
17
+ this._enableContinuousInsert = enableContinuousInsert;
17
18
  this._customEditors = customEditors;
18
19
  this._customRenders = customRenders;
19
20
  }
@@ -28,27 +29,49 @@ export default class GridEditionManager {
28
29
  };
29
30
  return options;
30
31
  }
32
+ canContinuousInsert() {
33
+ var _a;
34
+ return this._enableContinuousInsert && (this._dataUnit.records.length - 1) === ((_a = this._lastCellEdited) === null || _a === void 0 ? void 0 : _a.rowIndex);
35
+ }
31
36
  proceedAutoSave() {
32
37
  if (!this._dataUnit.isDirty()) {
33
38
  this.saveSuccess();
34
39
  return;
35
40
  }
36
- if (!this._isGridEdition) {
41
+ if (!this._isGridEdition || this._dataUnit.hasNewRecord()) {
37
42
  return;
38
43
  }
39
44
  const currentRercord = this._dataUnit.getSelectedRecord();
40
45
  if (currentRercord == undefined) {
41
46
  return;
42
47
  }
48
+ this._invalidCell = undefined;
43
49
  this._recordValidationProcessor
44
- .validate()
50
+ .validate(true)
45
51
  .then(() => {
46
52
  this._dataUnit.saveData()
47
- .then(() => this.saveSuccess())
53
+ .then(() => {
54
+ if (this.canContinuousInsert()) {
55
+ this._dataUnit.addRecord();
56
+ }
57
+ else {
58
+ this.saveSuccess();
59
+ }
60
+ })
48
61
  .catch(reason => this.saveFail(reason));
49
62
  })
50
63
  .catch(reason => this.saveFail(reason));
51
64
  }
65
+ async recordValidate() {
66
+ if (!this._dataUnit.isDirty())
67
+ return;
68
+ try {
69
+ this._invalidCell = undefined;
70
+ await this._recordValidationProcessor.validate(false);
71
+ }
72
+ catch (error) { }
73
+ this._gridOptions.api.refreshCells({ force: true });
74
+ }
52
75
  navigateByEnterKey(keyboardEvent) {
53
76
  const backwards = keyboardEvent.shiftKey;
54
77
  if (this._useEnterLikeTab) {
@@ -257,6 +280,34 @@ export default class GridEditionManager {
257
280
  setCellRenders(customRenders) {
258
281
  this._customRenders = customRenders;
259
282
  }
283
+ setInvalidCell(invalidCell, recordId) {
284
+ this._invalidCell = { field: invalidCell, recordId };
285
+ }
286
+ getInvalidCell() {
287
+ return this._invalidCell;
288
+ }
289
+ clearInvalidCells(action) {
290
+ this._invalidCell = undefined;
291
+ if (action === Action.EDITION_CANCELED) {
292
+ this._isGridEdition = false;
293
+ }
294
+ else if (action === Action.DATA_SAVED && this.canContinuousInsert()) {
295
+ this._dataUnit.addRecord();
296
+ }
297
+ }
298
+ setEnableContinuousInsert(enable) {
299
+ this._enableContinuousInsert = enable;
300
+ }
301
+ hasInvalidField(fieldName, recordId) {
302
+ if (!this.hasInvalidCell())
303
+ return false;
304
+ return this._invalidCell.field.name === fieldName && this._invalidCell.recordId === recordId;
305
+ }
306
+ hasInvalidCell() {
307
+ if (!this._invalidCell || !this._invalidCell.field || !this._invalidCell.recordId)
308
+ return false;
309
+ return true;
310
+ }
260
311
  }
261
312
  class TargetEdition {
262
313
  constructor(rowIndex, column, backwards) {
@@ -1,6 +1,7 @@
1
1
  import { HTMLBuilder } from "@sankhyalabs/core";
2
2
  import { CustomEditorSource } from "../../../../../utils/customEditor/interfaces/ICustomEditor";
3
3
  import EzCellEditor from "../editor/EzCellEditor";
4
+ import { getViewPortHeight } from "../editor/GridEditorUtils";
4
5
  export default class EzGridCustomCellEditor extends EzCellEditor {
5
6
  init(params) {
6
7
  var _a, _b;
@@ -11,6 +12,8 @@ export default class EzGridCustomCellEditor extends EzCellEditor {
11
12
  this._defaultGui = this.getDefaultGui();
12
13
  const fieldMetadata = super.getFieldMetadata();
13
14
  this._params = {
15
+ cellPossition: getViewPortHeight(params.eGridCell),
16
+ eGridCell: params.eGridCell,
14
17
  value: params.value,
15
18
  charPress: params.charPress,
16
19
  currentEditor: this._defaultGui,
@@ -48,12 +51,17 @@ export default class EzGridCustomCellEditor extends EzCellEditor {
48
51
  const element = HTMLBuilder.parseElement(editorElement);
49
52
  return element;
50
53
  }
54
+ this._customGui = editorElement;
51
55
  return editorElement;
52
56
  }
53
57
  setValue(value) {
54
58
  this._value = value;
55
59
  }
56
60
  getValue() {
61
+ if (this._customGui.getValue)
62
+ return this._customGui.getValue();
63
+ if (this._customGui.hasAttribute('value'))
64
+ return this._customGui.value;
57
65
  return this._value;
58
66
  }
59
67
  }
@@ -9,6 +9,7 @@ export const buildSearch = ({ name, required, readOnly, eGridCell, dataUnit }) =
9
9
  />`);
10
10
  const loader = ApplicationContext.getContextValue("__EZUI__SEARCH__OPTION__LOADER__");
11
11
  ezSearch.optionLoader = (argument) => loader(argument, name, dataUnit);
12
+ ezSearch.fromGrid = true;
12
13
  ezSearch.listOptionsPosition = { verticalPosition: 29, bottomLimit: getViewPortHeight(eGridCell), hardPosition: true };
13
14
  ezSearch.valueGetter = () => ezSearch.getValueAsync();
14
15
  return ezSearch;
@@ -36,5 +36,6 @@ export function buildOptions(dataUnit) {
36
36
  serverURL: '',
37
37
  statusResolver: {},
38
38
  useEnterLikeTab: true,
39
+ enableContinuousInsert: false,
39
40
  });
40
41
  }
@@ -36,6 +36,8 @@ export class EzGrid {
36
36
  this.recordsValidator = undefined;
37
37
  this.canEdit = true;
38
38
  this.autoFocus = true;
39
+ this.enableGridInsert = false;
40
+ this.enableContinuousInsert = true;
39
41
  }
40
42
  /**
41
43
  * Aplica a definição de colunas.
@@ -362,6 +364,8 @@ export class EzGrid {
362
364
  editionIsDisabled: () => !this.canEdit,
363
365
  customFormatters: this._customFormatters,
364
366
  autoFocus: this.autoFocus,
367
+ enableGridInsert: this.enableGridInsert,
368
+ enableContinuousInsert: this.enableContinuousInsert,
365
369
  onRefresh: () => {
366
370
  if (this.dataUnit) {
367
371
  this.setSelection(this.dataUnit.getSelectionInfo());
@@ -454,6 +458,11 @@ export class EzGrid {
454
458
  }
455
459
  componentDidUpdate() {
456
460
  this._gridController.setAutoFocus(this.autoFocus);
461
+ this._gridController.setEnableGridInsert(this.enableGridInsert);
462
+ this._gridController.setEnableContinuousInsert(this.enableContinuousInsert);
463
+ if (this.dataUnit) {
464
+ this.setSelection(this.dataUnit.getSelectionInfo());
465
+ }
457
466
  }
458
467
  getDataSource() {
459
468
  var _a;
@@ -694,6 +703,42 @@ export class EzGrid {
694
703
  "attribute": "auto-focus",
695
704
  "reflect": false,
696
705
  "defaultValue": "true"
706
+ },
707
+ "enableGridInsert": {
708
+ "type": "boolean",
709
+ "mutable": false,
710
+ "complexType": {
711
+ "original": "boolean",
712
+ "resolved": "boolean",
713
+ "references": {}
714
+ },
715
+ "required": false,
716
+ "optional": true,
717
+ "docs": {
718
+ "tags": [],
719
+ "text": "Ativa inser\u00E7\u00E3o de registros no modo grade."
720
+ },
721
+ "attribute": "enable-grid-insert",
722
+ "reflect": false,
723
+ "defaultValue": "false"
724
+ },
725
+ "enableContinuousInsert": {
726
+ "type": "boolean",
727
+ "mutable": false,
728
+ "complexType": {
729
+ "original": "boolean",
730
+ "resolved": "boolean",
731
+ "references": {}
732
+ },
733
+ "required": false,
734
+ "optional": true,
735
+ "docs": {
736
+ "tags": [],
737
+ "text": "Ativa/desativa a inser\u00E7\u00E3o continua na grade\nS\u00F3 funciona quando a prop enableGridInsert est\u00E1 ativa"
738
+ },
739
+ "attribute": "enable-continuous-insert",
740
+ "reflect": false,
741
+ "defaultValue": "true"
697
742
  }
698
743
  };
699
744
  }
@@ -8,6 +8,7 @@ export class EzModal {
8
8
  this.opened = true;
9
9
  this.closeEsc = false;
10
10
  this.closeOutsideClick = false;
11
+ this.closeOutsideLeave = false;
11
12
  this.scrim = "medium";
12
13
  }
13
14
  observeOpened() {
@@ -39,6 +40,11 @@ export class EzModal {
39
40
  this.closeModal();
40
41
  }
41
42
  }
43
+ onMouseLeaveHandler() {
44
+ if (this.closeOutsideLeave) {
45
+ this.closeModal();
46
+ }
47
+ }
42
48
  render() {
43
49
  const positionSufix = this.align === "left" ? "left" : "right";
44
50
  const regularVerticalPaddingClass = this.heightMode === "regular" ? 'modal__vertical-padding' : '';
@@ -46,7 +52,7 @@ export class EzModal {
46
52
  const scrimType = `modal__screen-${this.scrim}`;
47
53
  return (h(Host, null, this.opened
48
54
  ?
49
- h("div", { ref: ref => this._modalRef = ref, class: `modal ${scrimType} ${regularVerticalPaddingClass}`, onMouseDown: evt => this.onMouseDownHandler(evt), tabIndex: -1 }, h("div", { class: `modal__container modal__container--${positionSufix}`, ref: ref => this._overlay = ref }, h("div", { class: `modal__content ${modalContentHeightMode} ${this.modalSize}` }, h("slot", null))))
55
+ h("div", { ref: ref => this._modalRef = ref, class: `modal ${scrimType} ${regularVerticalPaddingClass}`, onMouseDown: evt => this.onMouseDownHandler(evt), tabIndex: -1 }, h("div", { class: `modal__container modal__container--${positionSufix}`, ref: ref => this._overlay = ref }, h("div", { onMouseLeave: () => this.onMouseLeaveHandler(), class: `modal__content ${modalContentHeightMode} ${this.modalSize}` }, h("slot", null))))
50
56
  :
51
57
  undefined));
52
58
  }
@@ -174,6 +180,24 @@ export class EzModal {
174
180
  "reflect": false,
175
181
  "defaultValue": "false"
176
182
  },
183
+ "closeOutsideLeave": {
184
+ "type": "boolean",
185
+ "mutable": false,
186
+ "complexType": {
187
+ "original": "boolean",
188
+ "resolved": "boolean",
189
+ "references": {}
190
+ },
191
+ "required": false,
192
+ "optional": true,
193
+ "docs": {
194
+ "tags": [],
195
+ "text": "Define se o modal ser\u00E1 fechado se o mouse sair para fora do conte\u00FAdo."
196
+ },
197
+ "attribute": "close-outside-leave",
198
+ "reflect": false,
199
+ "defaultValue": "false"
200
+ },
177
201
  "scrim": {
178
202
  "type": "string",
179
203
  "mutable": false,
@@ -11,6 +11,7 @@ export class EzModalContainer {
11
11
  this.okButtonLabel = undefined;
12
12
  this.cancelButtonStatus = undefined;
13
13
  this.okButtonStatus = undefined;
14
+ this.showCloseButton = true;
14
15
  }
15
16
  async handleEzModalAction(event) {
16
17
  var _a;
@@ -47,7 +48,7 @@ export class EzModalContainer {
47
48
  this._closeButton.focus();
48
49
  }
49
50
  render() {
50
- 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.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.DISABLED, onClick: () => this.ezModalAction.emit(ModalAction.CANCEL) })), this.okIsVisible() && (h("ez-button", { ref: ref => this._okButton = ref, class: "ez-button--primary", label: this.okButtonLabel, enabled: this.okButtonStatus !== ModalButtonStatus.DISABLED, onClick: () => this.ezModalAction.emit(ModalAction.OK) }))), h("button", { class: "ez-modal-container__focus-ctrl", onFocusin: () => this.focusFirst() })));
51
+ 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.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.DISABLED, onClick: () => this.ezModalAction.emit(ModalAction.CANCEL) })), this.okIsVisible() && (h("ez-button", { ref: ref => this._okButton = ref, class: "ez-button--primary", label: this.okButtonLabel, enabled: this.okButtonStatus !== ModalButtonStatus.DISABLED, onClick: () => this.ezModalAction.emit(ModalAction.OK) }))), h("button", { class: "ez-modal-container__focus-ctrl", onFocusin: () => this.focusFirst() })));
51
52
  }
52
53
  static get is() { return "ez-modal-container"; }
53
54
  static get encapsulation() { return "scoped"; }
@@ -182,6 +183,24 @@ export class EzModalContainer {
182
183
  },
183
184
  "attribute": "ok-button-status",
184
185
  "reflect": false
186
+ },
187
+ "showCloseButton": {
188
+ "type": "boolean",
189
+ "mutable": false,
190
+ "complexType": {
191
+ "original": "boolean",
192
+ "resolved": "boolean",
193
+ "references": {}
194
+ },
195
+ "required": false,
196
+ "optional": true,
197
+ "docs": {
198
+ "tags": [],
199
+ "text": "Define a visibilidade do bot\u00E3o de fechar."
200
+ },
201
+ "attribute": "show-close-button",
202
+ "reflect": false,
203
+ "defaultValue": "true"
185
204
  }
186
205
  };
187
206
  }
@@ -96,7 +96,7 @@ export class EzMuiltiSelectionList {
96
96
  }
97
97
  async searchWithDataSource(searchArgument, fieldName) {
98
98
  const { argument, mode } = searchArgument;
99
- if (mode !== 'PRELOAD') {
99
+ if (mode !== 'PRELOAD' && fieldName) {
100
100
  return this.dataSource.fetchData(argument, fieldName);
101
101
  }
102
102
  }
@@ -68,13 +68,17 @@
68
68
  border-radius: 12px;
69
69
  box-shadow: 0px 0px 16px rgba(0, 38, 111, 0.122);
70
70
  box-sizing: border-box;
71
- padding: var(--ez-popup__container--padding)
71
+ padding: var(--ez-popup__container--padding);
72
72
  }
73
73
 
74
74
  .popup__container--auto {
75
75
  height: auto;
76
76
  }
77
77
 
78
+ .popup__overflow-y--auto {
79
+ overflow-y: auto;
80
+ }
81
+
78
82
  .popup__content {
79
83
  box-sizing: border-box;
80
84
  height: 100%;