@sankhyalabs/ezui 0.0.0-bugfix-dev-KB-76362.1 → 0.0.0-bugfix-dev-KB-78242.0

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 (189) hide show
  1. package/dist/cjs/DataBinder-3b083480.js +445 -0
  2. package/dist/cjs/FocusResolver-885f2173.js +35 -0
  3. package/dist/cjs/ez-button.cjs.entry.js +1 -1
  4. package/dist/cjs/ez-card-item_3.cjs.entry.js +12 -19
  5. package/dist/cjs/ez-chart.cjs.entry.js +1 -1
  6. package/dist/cjs/ez-combo-box.cjs.entry.js +48 -12
  7. package/dist/cjs/ez-custom-form-input_2.cjs.entry.js +3 -2
  8. package/dist/cjs/ez-date-input.cjs.entry.js +8 -2
  9. package/dist/cjs/ez-date-time-input.cjs.entry.js +8 -2
  10. package/dist/cjs/ez-dialog.cjs.entry.js +10 -2
  11. package/dist/cjs/ez-form-view.cjs.entry.js +2 -2
  12. package/dist/cjs/ez-form.cjs.entry.js +5 -325
  13. package/dist/cjs/ez-grid.cjs.entry.js +14622 -70503
  14. package/dist/cjs/ez-icon.cjs.entry.js +1 -1
  15. package/dist/cjs/ez-list.cjs.entry.js +151 -100
  16. package/dist/cjs/ez-modal.cjs.entry.js +1 -1
  17. package/dist/cjs/ez-number-input.cjs.entry.js +8 -1
  18. package/dist/cjs/ez-popover.cjs.entry.js +1 -1
  19. package/dist/cjs/ez-popup.cjs.entry.js +1 -1
  20. package/dist/cjs/ez-search.cjs.entry.js +67 -22
  21. package/dist/cjs/ez-split-button.cjs.entry.js +1 -1
  22. package/dist/cjs/ez-split-panel.cjs.entry.js +14 -4
  23. package/dist/cjs/ez-text-area.cjs.entry.js +66 -4
  24. package/dist/cjs/ez-text-input.cjs.entry.js +79 -7
  25. package/dist/cjs/ez-time-input.cjs.entry.js +6 -0
  26. package/dist/cjs/ezui.cjs.js +1 -1
  27. package/dist/cjs/loader.cjs.js +1 -1
  28. package/dist/collection/collection-manifest.json +1 -1
  29. package/dist/collection/components/ez-button/ez-button.css +2 -2
  30. package/dist/collection/components/ez-card-item/ez-card-item.css +14 -5
  31. package/dist/collection/components/ez-combo-box/ez-combo-box.css +12 -0
  32. package/dist/collection/components/ez-combo-box/ez-combo-box.js +76 -15
  33. package/dist/collection/components/ez-date-input/ez-date-input.js +35 -4
  34. package/dist/collection/components/ez-date-time-input/ez-date-time-input.js +35 -4
  35. package/dist/collection/components/ez-dialog/ez-dialog.css +3 -3
  36. package/dist/collection/components/ez-dialog/ez-dialog.js +9 -1
  37. package/dist/collection/components/ez-filter-input/ez-filter-input.css +0 -11
  38. package/dist/collection/components/ez-filter-input/ez-filter-input.js +22 -52
  39. package/dist/collection/components/ez-form/ez-form.js +1 -0
  40. package/dist/collection/components/ez-form-view/custom-input/ez-custom-form-input.js +3 -2
  41. package/dist/collection/components/ez-form-view/fieldbuilder/templates/TextInput.tpl.js +2 -2
  42. package/dist/collection/components/ez-grid/controller/ag-grid/AgGridController.js +100 -27
  43. package/dist/collection/components/ez-grid/controller/ag-grid/DataSource.js +8 -0
  44. package/dist/collection/components/ez-grid/controller/ag-grid/GridEditionManager.js +164 -46
  45. package/dist/collection/components/ez-grid/controller/ag-grid/components/EzGridCustomCellEditor.js +7 -0
  46. package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/ComboBox.tpl.js +1 -0
  47. package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/DateInput.tpl.js +1 -0
  48. package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/NumberInput.tpl.js +1 -0
  49. package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/Search.tpl.js +1 -0
  50. package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/TextInput.tpl.js +4 -1
  51. package/dist/collection/components/ez-grid/ez-grid.css +11 -0
  52. package/dist/collection/components/ez-grid/ez-grid.js +110 -4
  53. package/dist/collection/components/ez-icon/ez-icon.css +153 -149
  54. package/dist/collection/components/ez-list/ez-list.css +5 -5
  55. package/dist/collection/components/ez-list/ez-list.js +152 -170
  56. package/dist/collection/components/ez-modal/ez-modal.css +4 -0
  57. package/dist/collection/components/ez-modal/ez-modal.js +2 -2
  58. package/dist/collection/components/ez-number-input/ez-number-input.css +8 -0
  59. package/dist/collection/components/ez-number-input/ez-number-input.js +25 -0
  60. package/dist/collection/components/ez-popover/ez-popover.css +3 -10
  61. package/dist/collection/components/ez-popup/ez-popup.css +4 -8
  62. package/dist/collection/components/ez-search/ez-search.css +1 -1
  63. package/dist/collection/components/ez-search/ez-search.js +94 -24
  64. package/dist/collection/components/ez-split-button/ez-split-button.css +2 -2
  65. package/dist/collection/components/ez-split-panel/ez-split-panel.js +35 -4
  66. package/dist/collection/components/ez-split-panel/interfaces/IPanelSizeInfo.js +1 -0
  67. package/dist/collection/components/ez-text-area/ez-text-area.css +49 -0
  68. package/dist/collection/components/ez-text-area/ez-text-area.js +102 -2
  69. package/dist/collection/components/ez-text-input/ez-text-input.css +33 -53
  70. package/dist/collection/components/ez-text-input/ez-text-input.js +88 -6
  71. package/dist/collection/components/ez-time-input/ez-time-input.js +24 -0
  72. package/dist/collection/utils/FocusResolver.js +31 -0
  73. package/dist/collection/utils/ResponsiveInputUtils.js +26 -0
  74. package/dist/collection/utils/form/DataBinder.js +18 -3
  75. package/dist/collection/utils/form/FormMetadata.js +1 -1
  76. package/dist/collection/utils/interfaces/AbstractFieldMetadata.js +1 -1
  77. package/dist/custom-elements/index.js +15381 -70913
  78. package/dist/esm/DataBinder-02fa9bb9.js +441 -0
  79. package/dist/esm/FocusResolver-1ccbf850.js +33 -0
  80. package/dist/esm/ez-button.entry.js +1 -1
  81. package/dist/esm/ez-card-item_3.entry.js +12 -19
  82. package/dist/esm/ez-chart.entry.js +1 -1
  83. package/dist/esm/ez-combo-box.entry.js +49 -13
  84. package/dist/esm/ez-custom-form-input_2.entry.js +3 -2
  85. package/dist/esm/ez-date-input.entry.js +8 -2
  86. package/dist/esm/ez-date-time-input.entry.js +8 -2
  87. package/dist/esm/ez-dialog.entry.js +10 -2
  88. package/dist/esm/ez-form-view.entry.js +2 -2
  89. package/dist/esm/ez-form.entry.js +4 -324
  90. package/dist/esm/ez-grid.entry.js +14591 -70472
  91. package/dist/esm/ez-icon.entry.js +1 -1
  92. package/dist/esm/ez-list.entry.js +152 -101
  93. package/dist/esm/ez-modal.entry.js +1 -1
  94. package/dist/esm/ez-number-input.entry.js +8 -1
  95. package/dist/esm/ez-popover.entry.js +1 -1
  96. package/dist/esm/ez-popup.entry.js +1 -1
  97. package/dist/esm/ez-search.entry.js +67 -22
  98. package/dist/esm/ez-split-button.entry.js +1 -1
  99. package/dist/esm/ez-split-panel.entry.js +15 -5
  100. package/dist/esm/ez-text-area.entry.js +66 -4
  101. package/dist/esm/ez-text-input.entry.js +79 -7
  102. package/dist/esm/ez-time-input.entry.js +6 -0
  103. package/dist/esm/ezui.js +1 -1
  104. package/dist/esm/loader.js +1 -1
  105. package/dist/ezui/ezui.esm.js +1 -1
  106. package/dist/ezui/p-16e21a40.entry.js +1 -0
  107. package/dist/ezui/p-1af7fae4.entry.js +1 -0
  108. package/dist/ezui/{p-3b546374.entry.js → p-2f53435e.entry.js} +1 -1
  109. package/dist/ezui/p-33675dae.entry.js +1 -0
  110. package/dist/ezui/p-397e3026.entry.js +1 -0
  111. package/dist/ezui/p-3af64edd.entry.js +1 -0
  112. package/dist/ezui/p-3c10cd94.entry.js +1 -0
  113. package/dist/ezui/p-3cc9b84a.entry.js +1 -0
  114. package/dist/ezui/p-3d38bfea.entry.js +1 -0
  115. package/dist/ezui/p-455e737c.js +1 -0
  116. package/dist/ezui/p-46a46507.entry.js +1 -0
  117. package/dist/ezui/p-6bda82d1.entry.js +1 -0
  118. package/dist/ezui/p-6d31c43c.entry.js +1 -0
  119. package/dist/ezui/p-7de7baa3.entry.js +1 -0
  120. package/dist/ezui/p-7f5afb1f.entry.js +1 -0
  121. package/dist/ezui/p-8f026744.entry.js +1 -0
  122. package/dist/ezui/p-aa7779d0.entry.js +1 -0
  123. package/dist/ezui/p-bfc30e61.entry.js +1 -0
  124. package/dist/ezui/p-bfc59380.entry.js +1 -0
  125. package/dist/ezui/p-d27b4b3e.entry.js +1 -0
  126. package/dist/ezui/p-d960a031.entry.js +1 -0
  127. package/dist/ezui/p-dc4b35fb.entry.js +309 -0
  128. package/dist/ezui/p-dc628ed3.js +1 -0
  129. package/dist/ezui/p-dfca5946.entry.js +1 -0
  130. package/dist/ezui/p-efbe0b73.entry.js +1 -0
  131. package/dist/types/components/ez-combo-box/ez-combo-box.d.ts +7 -1
  132. package/dist/types/components/ez-date-input/ez-date-input.d.ts +6 -1
  133. package/dist/types/components/ez-date-time-input/ez-date-time-input.d.ts +6 -1
  134. package/dist/types/components/ez-dialog/ez-dialog.d.ts +2 -0
  135. package/dist/types/components/ez-filter-input/ez-filter-input.d.ts +4 -11
  136. package/dist/types/components/ez-form-view/fieldbuilder/templates/TextInput.tpl.d.ts +1 -1
  137. package/dist/types/components/ez-grid/controller/EzGridController.d.ts +12 -0
  138. package/dist/types/components/ez-grid/controller/ag-grid/AgGridController.d.ts +7 -2
  139. package/dist/types/components/ez-grid/controller/ag-grid/DataSource.d.ts +2 -1
  140. package/dist/types/components/ez-grid/controller/ag-grid/GridEditionManager.d.ts +19 -7
  141. package/dist/types/components/ez-grid/controller/ag-grid/components/EzGridCustomCellEditor.d.ts +3 -1
  142. package/dist/types/components/ez-grid/controller/ag-grid/components/EzGridCustomCellRender.d.ts +1 -1
  143. package/dist/types/components/ez-grid/controller/ag-grid/components/EzGridCustomHeader.d.ts +1 -1
  144. package/dist/types/components/ez-grid/controller/ag-grid/components/cellRendererStatus.d.ts +1 -1
  145. package/dist/types/components/ez-grid/controller/ag-grid/components/selectionHeader.d.ts +1 -1
  146. package/dist/types/components/ez-grid/controller/ag-grid/editor/EzCellEditor.d.ts +1 -1
  147. package/dist/types/components/ez-grid/controller/ag-grid/editor/EzCellRender.d.ts +1 -1
  148. package/dist/types/components/ez-grid/controller/ag-grid/editor/IUICellEditor.d.ts +1 -0
  149. package/dist/types/components/ez-grid/controller/ag-grid/mock/Server.d.ts +1 -1
  150. package/dist/types/components/ez-grid/ez-grid.d.ts +17 -1
  151. package/dist/types/components/ez-list/ez-list.d.ts +3 -26
  152. package/dist/types/components/ez-modal/ez-modal.d.ts +1 -1
  153. package/dist/types/components/ez-number-input/ez-number-input.d.ts +4 -0
  154. package/dist/types/components/ez-search/ez-search.d.ts +10 -2
  155. package/dist/types/components/ez-split-panel/ez-split-panel.d.ts +4 -0
  156. package/dist/types/components/ez-split-panel/interfaces/IPanelSizeInfo.d.ts +9 -0
  157. package/dist/types/components/ez-text-area/ez-text-area.d.ts +17 -0
  158. package/dist/types/components/ez-text-input/ez-text-input.d.ts +9 -0
  159. package/dist/types/components/ez-time-input/ez-time-input.d.ts +4 -0
  160. package/dist/types/components.d.ts +122 -44
  161. package/dist/types/utils/FocusResolver.d.ts +5 -0
  162. package/dist/types/utils/ResponsiveInputUtils.d.ts +6 -0
  163. package/dist/types/utils/form/DataBinder.d.ts +3 -0
  164. package/package.json +11 -4
  165. package/dist/cjs/RecordValidationProcessor-10846595.js +0 -108
  166. package/dist/esm/RecordValidationProcessor-9c6cc267.js +0 -105
  167. package/dist/ezui/p-00687830.entry.js +0 -1
  168. package/dist/ezui/p-044d46d5.entry.js +0 -1
  169. package/dist/ezui/p-11b09aa1.entry.js +0 -1
  170. package/dist/ezui/p-190c190f.entry.js +0 -304
  171. package/dist/ezui/p-2de9f0aa.entry.js +0 -1
  172. package/dist/ezui/p-36180f4d.entry.js +0 -1
  173. package/dist/ezui/p-3f8c33e0.entry.js +0 -1
  174. package/dist/ezui/p-52100a6e.entry.js +0 -1
  175. package/dist/ezui/p-5a40c77a.entry.js +0 -1
  176. package/dist/ezui/p-61059f6b.entry.js +0 -1
  177. package/dist/ezui/p-68267f59.entry.js +0 -1
  178. package/dist/ezui/p-823cc11b.entry.js +0 -1
  179. package/dist/ezui/p-85b500bb.entry.js +0 -1
  180. package/dist/ezui/p-8ac13678.entry.js +0 -1
  181. package/dist/ezui/p-940760bf.entry.js +0 -1
  182. package/dist/ezui/p-9e08ddb0.entry.js +0 -1
  183. package/dist/ezui/p-b2a1398f.entry.js +0 -1
  184. package/dist/ezui/p-ba5f4ee7.entry.js +0 -1
  185. package/dist/ezui/p-d40b93a7.entry.js +0 -1
  186. package/dist/ezui/p-d4aba783.entry.js +0 -1
  187. package/dist/ezui/p-e3ec7422.entry.js +0 -1
  188. package/dist/ezui/p-f291db18.entry.js +0 -1
  189. package/dist/ezui/p-f42855b9.js +0 -1
@@ -1,15 +1,16 @@
1
- import { UserInterface } from '@sankhyalabs/core';
2
- import { KeyCode, } from 'ag-grid-community';
1
+ import { LockManager, LockManagerOperation, UserInterface } from '@sankhyalabs/core';
2
+ import { KeyCode, } from "@ag-grid-community/core";
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
+ import { DataBinder } from '../../../../utils';
7
8
  export default class GridEditionManager {
8
- constructor(dataUnit, useEnterLikeTab, recordsValidator, editionIsDisabled, customEditors, customRenders, enableContinuousInsert, enableGridInsert) {
9
+ constructor(dataUnit, useEnterLikeTab, recordsValidator, editionIsDisabled, customEditors, customRenders, enableContinuousInsert, enableGridInsert, lockerId) {
9
10
  this._dataUnit = dataUnit;
10
11
  this._recordValidationProcessor = new RecordValidationProcessor(this._dataUnit, {
11
12
  getRequiredFields: () => this.getRequiredFields(),
12
- markAsInvalid: (invalidField, recordId) => { this.setInvalidCell(invalidField, recordId); },
13
+ markAsInvalid: (invalidField, recordId) => { this.pushInvalidCell(invalidField, recordId); },
13
14
  getMessageForField: () => null,
14
15
  }, recordsValidator);
15
16
  this._useEnterLikeTab = useEnterLikeTab;
@@ -18,16 +19,34 @@ export default class GridEditionManager {
18
19
  this._enableGridInsert = enableGridInsert;
19
20
  this._customEditors = customEditors;
20
21
  this._customRenders = customRenders;
22
+ this._lockerId = lockerId;
21
23
  }
22
24
  configureGrid(options) {
23
25
  this._gridOptions = options;
24
26
  options.readOnlyEdit = true;
25
27
  options.onCellEditRequest = evt => this.onCellEditRequest(evt);
28
+ options.onCellEditingStarted = async (evt) => {
29
+ var _a;
30
+ if (this._dataUnit.hasNewRecord()) {
31
+ this.handleCellEditingStartedRowAdd(evt);
32
+ }
33
+ else {
34
+ this._lastCellOpened = this._lastCellEdited = { rowIndex: evt.rowIndex, column: evt.column, rowPinned: undefined };
35
+ }
36
+ (_a = this._currentEditLock) === null || _a === void 0 ? void 0 : _a.call(this);
37
+ this._currentEditLock = LockManager.lock(this._lockerId, LockManagerOperation.TASKBAR_CLICK);
38
+ };
39
+ options.onCellEditingStopped = () => {
40
+ var _a;
41
+ (_a = this._currentEditLock) === null || _a === void 0 ? void 0 : _a.call(this);
42
+ };
26
43
  options.onCellKeyDown = evt => {
27
44
  if (evt.event && evt["column"]) {
28
45
  this.onCellKeyDown(evt);
29
46
  }
30
47
  };
48
+ options.isRowSelectable = (node) => this.isSelectableRow(node);
49
+ options.onCellFocused = () => this.lockFocusWhenAddRow();
31
50
  return options;
32
51
  }
33
52
  updateCurrentEditorGuiValue(updatedRowValue) {
@@ -40,37 +59,82 @@ export default class GridEditionManager {
40
59
  const value = updatedRowValue[fieldName];
41
60
  currentEditor.setGuiValue(value);
42
61
  }
62
+ lockFocusWhenAddRow() {
63
+ var _a, _b, _c, _d;
64
+ const api = this._gridOptions.api;
65
+ const newFocusCell = api.getFocusedCell();
66
+ const rowIndex = newFocusCell === null || newFocusCell === void 0 ? void 0 : newFocusCell.rowIndex;
67
+ const recordId = (_b = (_a = this._dataUnit.getAddedRecords()) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.__record__id__;
68
+ const rowNode = api.getRowNode(recordId);
69
+ if (!this._dataUnit.hasNewRecord() || rowIndex == (rowNode === null || rowNode === void 0 ? void 0 : rowNode.rowIndex)) {
70
+ return;
71
+ }
72
+ const lastCell = (_d = (_c = this._lastCellOpened) !== null && _c !== void 0 ? _c : this._lastCellEdited) !== null && _d !== void 0 ? _d : this._lastCellClicked;
73
+ if ((lastCell === null || lastCell === void 0 ? void 0 : lastCell.rowIndex) < (rowNode === null || rowNode === void 0 ? void 0 : rowNode.rowIndex)) {
74
+ return;
75
+ }
76
+ api.clearFocusedCell();
77
+ if (!lastCell || (rowNode === null || rowNode === void 0 ? void 0 : rowNode.rowIndex) == undefined) {
78
+ return;
79
+ }
80
+ lastCell.rowIndex = rowNode === null || rowNode === void 0 ? void 0 : rowNode.rowIndex;
81
+ this.focusOnCell(lastCell);
82
+ }
83
+ handleCellEditingStartedRowAdd(evt) {
84
+ var _a, _b, _c, _d, _e;
85
+ const nodeId = (_a = evt.node) === null || _a === void 0 ? void 0 : _a.id;
86
+ const addedRecordId = (_c = (_b = this._dataUnit.getAddedRecords()) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.__record__id__;
87
+ if (nodeId == addedRecordId) {
88
+ this._lastCellOpened = this._lastCellEdited = { rowIndex: evt.rowIndex, column: evt === null || evt === void 0 ? void 0 : evt.column, rowPinned: undefined };
89
+ return;
90
+ }
91
+ evt.api.stopEditing();
92
+ const rowIndex = (_d = evt.api.getRowNode(addedRecordId)) === null || _d === void 0 ? void 0 : _d.rowIndex;
93
+ this._lastCellOpened = this._lastCellEdited = { rowIndex: rowIndex, column: (_e = this._lastCellEdited) === null || _e === void 0 ? void 0 : _e.column, rowPinned: undefined };
94
+ }
95
+ isSelectableRow(node) {
96
+ if (!this._dataUnit.hasNewRecord()) {
97
+ return true;
98
+ }
99
+ if (!this._dataUnit.isNewRecord(node.id)) {
100
+ return false;
101
+ }
102
+ return true;
103
+ }
43
104
  canContinuousInsert() {
44
105
  var _a;
45
106
  return this._enableContinuousInsert && (this._dataUnit.records.length - 1) === ((_a = this._lastCellEdited) === null || _a === void 0 ? void 0 : _a.rowIndex);
46
107
  }
47
- proceedAutoSave() {
108
+ async proceedAutoSave() {
48
109
  if (!this._dataUnit.isDirty()) {
49
110
  this.saveSuccess();
50
- return;
111
+ return true;
51
112
  }
52
- if (!this._isGridEdition) {
53
- return;
113
+ const currentRecord = this._dataUnit.getSelectedRecord();
114
+ if (currentRecord == undefined) {
115
+ return true;
54
116
  }
55
- const currentRercord = this._dataUnit.getSelectedRecord();
56
- if (currentRercord == undefined) {
57
- return;
117
+ this.clearInvalidCells(false);
118
+ try {
119
+ await this._recordValidationProcessor.validate(true);
120
+ await this.saveDataUnit();
121
+ this.saveSuccess();
122
+ return true;
58
123
  }
59
- this._invalidCell = undefined;
60
- this._recordValidationProcessor
61
- .validate(true)
62
- .then(() => {
63
- this._dataUnit.saveData()
64
- .then(() => this.saveSuccess())
65
- .catch(reason => this.saveFail(reason));
66
- })
67
- .catch(reason => this.saveFail(reason));
124
+ catch (reason) {
125
+ this.saveFail(reason);
126
+ return false;
127
+ }
128
+ }
129
+ async saveDataUnit() {
130
+ await this._dataUnit.saveData();
131
+ return true;
68
132
  }
69
133
  async recordValidate() {
70
134
  if (!this._dataUnit.isDirty())
71
135
  return;
72
136
  try {
73
- this._invalidCell = undefined;
137
+ this.clearInvalidCells(false);
74
138
  await this._recordValidationProcessor.validate(false);
75
139
  }
76
140
  catch (error) { }
@@ -98,6 +162,13 @@ export default class GridEditionManager {
98
162
  return { ezCellEditor: EzCellEditor };
99
163
  }
100
164
  verifyClickToEdition(api, cellClicked) {
165
+ var _a, _b;
166
+ const selectedRecordID = (_a = this._dataUnit.getSelectedRecord()) === null || _a === void 0 ? void 0 : _a.__record__id__;
167
+ if (this._dataUnit.hasNewRecord() && selectedRecordID) {
168
+ const dataUnitRecordIndex = (_b = api.getRowNode(selectedRecordID)) === null || _b === void 0 ? void 0 : _b.rowIndex;
169
+ if (dataUnitRecordIndex != cellClicked.rowIndex)
170
+ return;
171
+ }
101
172
  if (this.isSecondClick(cellClicked)) {
102
173
  api.startEditingCell({ rowIndex: cellClicked.rowIndex, colKey: cellClicked.column.getColId() });
103
174
  }
@@ -107,6 +178,9 @@ export default class GridEditionManager {
107
178
  col.cellEditor = 'ezCellEditor';
108
179
  col.editable = params => this.canEdit(params);
109
180
  col.suppressKeyboardEvent = (params) => {
181
+ if (params.event.key === KeyCode.ESCAPE && params.editing) {
182
+ return this._dataUnit.isDirty();
183
+ }
110
184
  return params.event.key === KeyCode.ENTER;
111
185
  };
112
186
  col.cellEditorSelector = (params) => {
@@ -136,10 +210,21 @@ export default class GridEditionManager {
136
210
  return col;
137
211
  }
138
212
  getRequiredFields() {
139
- return this._gridOptions.columnApi.getAllDisplayedColumns().filter(c => {
140
- const fieldDefinition = this._dataUnit.getField(c.getColId());
141
- return fieldDefinition && fieldDefinition.required;
142
- }).map(c => c.getColId());
213
+ const formRequiredFields = this.getFormRequiredFields();
214
+ return this._gridOptions.columnApi.getAllDisplayedColumns()
215
+ .filter(column => {
216
+ const fieldDefinition = this._dataUnit.getField(column.getColId());
217
+ return (fieldDefinition && fieldDefinition.required) || formRequiredFields.includes(column.getColId());
218
+ })
219
+ .map(column => column.getColId());
220
+ }
221
+ getFormRequiredFields() {
222
+ const formRequiredFields = [];
223
+ const dataBinders = DataBinder.getDataBindersByDataUnit(this._dataUnit);
224
+ dataBinders.forEach(dataBinder => {
225
+ formRequiredFields.push(...dataBinder.getFormRequiredFields());
226
+ });
227
+ return formRequiredFields;
143
228
  }
144
229
  saveSuccess() {
145
230
  var _a;
@@ -152,10 +237,11 @@ export default class GridEditionManager {
152
237
  this._isGridEdition = false;
153
238
  }
154
239
  saveFail(reason) {
155
- this.focusOnCell(this._lastCellEdited);
240
+ var _a;
241
+ this.focusOnCell((_a = this._lastCellOpened) !== null && _a !== void 0 ? _a : this._lastCellEdited);
156
242
  this._isGridEdition = false;
157
243
  if (reason) {
158
- Promise.reject(reason);
244
+ throw reason;
159
245
  }
160
246
  }
161
247
  focusOnCell(cell) {
@@ -220,6 +306,9 @@ export default class GridEditionManager {
220
306
  this.moveEditionVertically(api, 1);
221
307
  }
222
308
  moveEditionVertically(api, offset) {
309
+ if (this._dataUnit.hasNewRecord() && this._isGridEdition) {
310
+ return;
311
+ }
223
312
  const editionCell = api.getEditingCells()[0];
224
313
  if (!editionCell) {
225
314
  return;
@@ -264,41 +353,63 @@ export default class GridEditionManager {
264
353
  return true;
265
354
  }
266
355
  onCellEditRequest(event) {
267
- const fieldName = event.colDef.field;
356
+ var _a;
268
357
  const value = event.newValue;
269
- if (event.oldValue != value) {
270
- if (value instanceof Promise) {
271
- const fieldDescriptor = this._dataUnit.getField(event.colDef.colId);
272
- event.node.setData(Object.assign(Object.assign({}, event.data), { [fieldName]: (fieldDescriptor === null || fieldDescriptor === void 0 ? void 0 : fieldDescriptor.userInterface) === UserInterface.SEARCH ? value : event.oldValue }));
273
- value.then(resolved => event.node.setData(Object.assign(Object.assign({}, event.data), { [fieldName]: resolved })));
274
- }
275
- else {
276
- event.node.setData(Object.assign(Object.assign({}, event.data), { [fieldName]: value }));
277
- }
358
+ if (event.oldValue == value) {
359
+ (_a = this._currentEditLock) === null || _a === void 0 ? void 0 : _a.call(this);
360
+ return;
361
+ }
362
+ if (value instanceof Promise) {
363
+ this.handlePromiseValue(event, value);
364
+ return;
365
+ }
366
+ this.updateCellValue(event, value);
367
+ }
368
+ async handlePromiseValue(event, value) {
369
+ const fieldName = event.colDef.field;
370
+ const fieldDescriptor = this._dataUnit.getField(event.colDef.colId);
371
+ const initialValue = (fieldDescriptor === null || fieldDescriptor === void 0 ? void 0 : fieldDescriptor.userInterface) === UserInterface.SEARCH ? value : event.oldValue;
372
+ event.node.setData(Object.assign(Object.assign({}, event.data), { [fieldName]: initialValue }));
373
+ const resolved = await value;
374
+ return this.updateCellValue(event, resolved);
375
+ }
376
+ updateCellValue(event, newValue) {
377
+ var _a;
378
+ const fieldName = event.colDef.field;
379
+ event.node.setData(Object.assign(Object.assign({}, event.data), { [fieldName]: newValue }));
380
+ (_a = this._currentEditLock) === null || _a === void 0 ? void 0 : _a.call(this);
381
+ if (event.oldValue !== newValue) {
278
382
  this._isGridEdition = true;
279
- this._dataUnit.setFieldValue(fieldName, value, [event.data.__record__id__], { suppressCreateNewRecord: true });
383
+ this._dataUnit.setFieldValue(fieldName, newValue, [event.data.__record__id__], { suppressCreateNewRecord: true });
280
384
  this._lastCellEdited = { rowIndex: event.rowIndex, column: event.column, rowPinned: undefined };
281
385
  }
282
386
  }
283
387
  setCellEditors(customEditors) {
388
+ var _a;
284
389
  this._customEditors = customEditors;
390
+ (_a = this._gridOptions) === null || _a === void 0 ? void 0 : _a.api.stopEditing();
285
391
  }
286
392
  setCellRenders(customRenders) {
287
393
  this._customRenders = customRenders;
288
394
  }
289
- setInvalidCell(invalidCell, recordId) {
290
- this._invalidCell = { field: invalidCell, recordId };
395
+ pushInvalidCell(invalidField, recordId) {
396
+ this._invalidCells.push({ field: invalidField, recordId });
397
+ this._nextInvalidCell = this._invalidCells[0];
398
+ }
399
+ getInvalidCells() {
400
+ return this._invalidCells;
291
401
  }
292
- getInvalidCell() {
293
- return this._invalidCell;
402
+ getNextInvalidCell() {
403
+ return this._nextInvalidCell;
294
404
  }
295
- processContinuousInsert() {
405
+ async processContinuousInsert() {
296
406
  if (!this.canContinuousInsert())
297
407
  return;
298
408
  this._dataUnit.addRecord();
299
409
  }
300
410
  clearInvalidCells(stopEdition) {
301
- this._invalidCell = undefined;
411
+ this._invalidCells = [];
412
+ this._nextInvalidCell = undefined;
302
413
  if (stopEdition) {
303
414
  this._isGridEdition = false;
304
415
  }
@@ -309,10 +420,17 @@ export default class GridEditionManager {
309
420
  hasInvalidField(fieldName, recordId) {
310
421
  if (!this.hasInvalidCell())
311
422
  return false;
312
- return this._invalidCell.field.name === fieldName && this._invalidCell.recordId === recordId;
423
+ this._nextInvalidCell = this._invalidCells[0];
424
+ const containsFieldName = this._nextInvalidCell.field.name === fieldName;
425
+ const containsRecordId = this._nextInvalidCell.recordId === recordId;
426
+ return containsFieldName && containsRecordId;
313
427
  }
314
428
  hasInvalidCell() {
315
- if (!this._invalidCell || !this._invalidCell.field || !this._invalidCell.recordId)
429
+ var _a, _b, _c;
430
+ const hasInvalidCell = ((_a = this._invalidCells) === null || _a === void 0 ? void 0 : _a.length) > 0;
431
+ const hasField = (_b = this._invalidCells) === null || _b === void 0 ? void 0 : _b.filter(invalidCell => { invalidCell.field; });
432
+ const hasRecordId = (_c = this._invalidCells) === null || _c === void 0 ? void 0 : _c.filter(invalidCell => { invalidCell.recordId; });
433
+ if (!hasInvalidCell || !hasField || !hasRecordId)
316
434
  return false;
317
435
  return true;
318
436
  }
@@ -2,6 +2,7 @@ import { HTMLBuilder } from "@sankhyalabs/core";
2
2
  import { CustomEditorSource } from "../../../../../utils/customEditor/interfaces/ICustomEditor";
3
3
  import EzCellEditor from "../editor/EzCellEditor";
4
4
  import { getViewPortHeight } from "../editor/GridEditorUtils";
5
+ import FocusResolver from "../../../../../utils/FocusResolver";
5
6
  export default class EzGridCustomCellEditor extends EzCellEditor {
6
7
  init(params) {
7
8
  var _a, _b;
@@ -65,4 +66,10 @@ export default class EzGridCustomCellEditor extends EzCellEditor {
65
66
  return this._customGui.value;
66
67
  return this._value;
67
68
  }
69
+ afterGuiAttached() {
70
+ this.focusIn();
71
+ }
72
+ focusIn() {
73
+ FocusResolver.resolveFocus(this._customGui);
74
+ }
68
75
  }
@@ -19,6 +19,7 @@ export const buildComboBox = ({ required, props, eGridCell }) => {
19
19
  combo.options = options;
20
20
  combo.stopPropagateEnterKeyEvent = true;
21
21
  combo.listOptionsPosition = { verticalPosition: 29, bottomLimit: getViewPortHeight(eGridCell), hardPosition: true };
22
+ combo.autoFocus = true;
22
23
  return combo;
23
24
  };
24
25
  export const buildSwitch = (fieldMetadata) => {
@@ -7,6 +7,7 @@ export const buildDate = () => {
7
7
  data-is-fixed="true"
8
8
  />`);
9
9
  dateInput.valueGetter = () => dateInput.getValueAsync();
10
+ dateInput.autoFocus = true;
10
11
  return dateInput;
11
12
  };
12
13
  export const buildTime = ({ readOnly }) => {
@@ -17,5 +17,6 @@ function buildNumeric(readOnly, precision, prettyPrecision) {
17
17
  mode="slim"
18
18
  />`);
19
19
  input.valueGetter = () => input.getValueAsync();
20
+ input.autoFocus = true;
20
21
  return input;
21
22
  }
@@ -13,6 +13,7 @@ export const buildSearch = ({ name, required, readOnly, eGridCell, dataUnit }) =
13
13
  ezSearch.suppressPreLoad = true;
14
14
  ezSearch.listOptionsPosition = { verticalPosition: 29, bottomLimit: getViewPortHeight(eGridCell), hardPosition: true };
15
15
  ezSearch.stopPropagateEnterKeyEvent = true;
16
+ ezSearch.autoFocus = true;
16
17
  ezSearch.valueGetter = () => ezSearch.getValueAsync();
17
18
  return ezSearch;
18
19
  };
@@ -2,12 +2,14 @@ import { HTMLBuilder } from "@sankhyalabs/core";
2
2
  const MINIMIUM_WIDTH_TEXTAREA = 210;
3
3
  const PADDING_VALUE_TEXTAREA = 12;
4
4
  export const buildTextInput = ({ name, contextName }) => {
5
- return HTMLBuilder.parseElement(`<ez-text-input
5
+ const textInput = HTMLBuilder.parseElement(`<ez-text-input
6
6
  class="ez-grid grid_editor"
7
7
  data-field-name=${name}
8
8
  data-context-name=${contextName}
9
9
  mode="slim"
10
10
  />`);
11
+ textInput.autoFocus = true;
12
+ return textInput;
11
13
  };
12
14
  export const buildTextAreaInput = ({ eGridCell, editionManager }) => {
13
15
  const element = HTMLBuilder.parseElement(`<ez-text-area
@@ -17,6 +19,7 @@ export const buildTextAreaInput = ({ eGridCell, editionManager }) => {
17
19
  element.addEventListener('keydown', event => handlePressEnterEvent(event, element, editionManager));
18
20
  setElementInitialWidth(eGridCell, element);
19
21
  element.isPopUp = true;
22
+ element.autoFocus = true;
20
23
  return element;
21
24
  };
22
25
  function setElementInitialWidth(eGridCell, element) {
@@ -14,6 +14,10 @@
14
14
  --ez-grid__container--shadow: 0 0 16px 0 rgb(0 38 111 / 12%);
15
15
  /*@doc Define altura mínima da grid */
16
16
  --ez-grid--min-height: 300px;
17
+ /*@doc Define o outline usado como borda.*/
18
+ --ez-grid__container--outline: 1px solid var(--color--strokes);
19
+ /*@doc Define o outline usado como borda.*/
20
+ --ez-grid__container--shadow-as-outline: 0px 0px 0px 1px var(--color--strokes);
17
21
 
18
22
  min-height: var(--ez-grid--min-height);
19
23
  }
@@ -38,6 +42,13 @@
38
42
  background-color: var(--ez-grid__header--background-color);
39
43
  }
40
44
 
45
+ .grid__container.box-outline {
46
+ /*public*/
47
+ box-shadow: var(--ez-grid__container--shadow-as-outline);
48
+ border: none;
49
+ outline: none;
50
+ }
51
+
41
52
  .grid-header__popover {
42
53
  position: relative;
43
54
  top: var(--space--sm, 16px);
@@ -39,6 +39,8 @@ export class EzGrid {
39
39
  this.paginationCounterMode = 'show';
40
40
  this.enableGridInsert = false;
41
41
  this.enableContinuousInsert = true;
42
+ this.enableLockManger = true;
43
+ this.boxShadow = true;
42
44
  }
43
45
  /**
44
46
  * Aplica a definição de colunas.
@@ -163,6 +165,18 @@ export class EzGrid {
163
165
  async setFocus() {
164
166
  this._gridController.setFocus();
165
167
  }
168
+ /**
169
+ * Para a edição da grade.
170
+ */
171
+ async stopEdit() {
172
+ this._gridController.stopEdit();
173
+ }
174
+ async checkStopEditOutsideClick(event) {
175
+ var _a;
176
+ if ((_a = this._container) === null || _a === void 0 ? void 0 : _a.contains(event.target))
177
+ return;
178
+ this._gridController.stopEdit();
179
+ }
166
180
  observeConfig(config) {
167
181
  this._gridController.setColumnsState(config === null || config === void 0 ? void 0 : config.columns);
168
182
  }
@@ -188,6 +202,9 @@ export class EzGrid {
188
202
  this.setSelection(this.dataUnit.getSelectionInfo());
189
203
  }
190
204
  }
205
+ async handleClick(event) {
206
+ this.checkStopEditOutsideClick(event);
207
+ }
191
208
  setSelection(selectionInfo) {
192
209
  var _a;
193
210
  this._selectionCount = (_a = selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.length) !== null && _a !== void 0 ? _a : 0;
@@ -343,7 +360,7 @@ export class EzGrid {
343
360
  resetPaginationState() {
344
361
  var _a;
345
362
  this._paginationChangedByKeyboard = false;
346
- (_a = this._gridApi) === null || _a === void 0 ? void 0 : _a.clearRangeSelection();
363
+ (_a = this._gridController) === null || _a === void 0 ? void 0 : _a.resetPaginationState();
347
364
  }
348
365
  resolvePaginationClassMode() {
349
366
  if (this.paginationCounterMode == 'show')
@@ -384,7 +401,8 @@ export class EzGrid {
384
401
  if (this.dataUnit) {
385
402
  this.setSelection(this.dataUnit.getSelectionInfo());
386
403
  }
387
- }
404
+ },
405
+ enableLockManger: this.enableLockManger
388
406
  });
389
407
  if (this.config) {
390
408
  this.observeConfig(this.config);
@@ -456,8 +474,13 @@ export class EzGrid {
456
474
  this._refPaginationLabelTooltip.removeAttribute('data-tooltip');
457
475
  }
458
476
  disconnectedCallback() {
459
- var _a;
477
+ var _a, _b;
460
478
  (_a = this._headerOverflowWatcher) === null || _a === void 0 ? void 0 : _a.destroy();
479
+ (_b = this._gridController) === null || _b === void 0 ? void 0 : _b.destroy();
480
+ }
481
+ connectedCallback() {
482
+ var _a;
483
+ (_a = this._gridController) === null || _a === void 0 ? void 0 : _a.registryListeners();
461
484
  }
462
485
  componentWillRender() {
463
486
  this.configSelectionCounter();
@@ -494,7 +517,7 @@ export class EzGrid {
494
517
  }
495
518
  render() {
496
519
  var _a;
497
- return (h(Host, { "no-header": this.hideHeader() }, h("div", { class: "grid__container ez-grid", ref: elem => (this._container = elem) }), h("div", { class: "ez-box ez-box--shadow ez-padding--small grid-header" }, h("filter-column", { class: "grid-header__popover", noHeaderTaskBar: !this._hasLeftButtons, dataSource: this.getDataSource(), dataUnit: this.dataUnit, gridHeaderHidden: this.hideHeader(), ref: (element) => (this._filterColumn = element) }), h("div", { class: "grid-header__position" }, h("div", { class: `grid-header__container grid-header__left-container ${this.resolveLeftHeaderClass()}` }, h("slot", { name: "leftButtons" })), this.getPaginationControl())), h("div", { ref: (ref) => (this._gridSelectionCounter = ref), class: `grid__selection-counter ez-elevation--4
520
+ return (h(Host, { "no-header": this.hideHeader() }, h("div", { class: `grid__container ${this.boxShadow ? '' : 'box-outline'} ez-grid`, ref: elem => (this._container = elem) }), h("div", { class: `ez-box ${this.boxShadow ? 'ez-box--shadow-xsmall' : 'ez-box--outline'} ez-padding--small grid-header` }, h("filter-column", { class: "grid-header__popover", noHeaderTaskBar: !this._hasLeftButtons, dataSource: this.getDataSource(), dataUnit: this.dataUnit, gridHeaderHidden: this.hideHeader(), ref: (element) => (this._filterColumn = element) }), h("div", { class: "grid-header__position" }, h("div", { class: `grid-header__container grid-header__left-container ${this.resolveLeftHeaderClass()}` }, h("slot", { name: "leftButtons" })), this.getPaginationControl())), h("div", { ref: (ref) => (this._gridSelectionCounter = ref), class: `grid__selection-counter ez-elevation--4
498
521
  ${this._showSelectionCounter ? 'grid__selection-counter--opened' : ''}
499
522
  ` }, h(SelectionCounter, { selectionCount: this._selectionCount, currentPageSelected: this._currentPageSelected, paginationInfo: this._paginationInfo, canSelectAll: (_a = this.selectionToastConfig) === null || _a === void 0 ? void 0 : _a.canSelectAll, allRecordSelected: this._isAllSelection, onSelectAll: () => this.onSelectAllRecords(), onSelectPage: () => this.onSelectPageRecords(), onClearAll: () => this.onClearSelectedRecords(), onClose: () => (this._showSelectionCounter = false) })), h("div", { class: "grid__footer" }, h("slot", { name: "footer" }))));
500
523
  }
@@ -778,6 +801,42 @@ export class EzGrid {
778
801
  "attribute": "enable-continuous-insert",
779
802
  "reflect": false,
780
803
  "defaultValue": "true"
804
+ },
805
+ "enableLockManger": {
806
+ "type": "boolean",
807
+ "mutable": false,
808
+ "complexType": {
809
+ "original": "boolean",
810
+ "resolved": "boolean",
811
+ "references": {}
812
+ },
813
+ "required": false,
814
+ "optional": true,
815
+ "docs": {
816
+ "tags": [],
817
+ "text": "Ativa inser\u00E7\u00E3o de registros no modo grade."
818
+ },
819
+ "attribute": "enable-lock-manger",
820
+ "reflect": false,
821
+ "defaultValue": "true"
822
+ },
823
+ "boxShadow": {
824
+ "type": "boolean",
825
+ "mutable": false,
826
+ "complexType": {
827
+ "original": "boolean",
828
+ "resolved": "boolean",
829
+ "references": {}
830
+ },
831
+ "required": false,
832
+ "optional": true,
833
+ "docs": {
834
+ "tags": [],
835
+ "text": "Altera visualmente as sombras e bordas do componente\nQuando true, aplica o padr\u00E3o de sombras ao componente (Utilizar quando for o elemento principal do layout)\nQuando false, aplica o padr\u00E3o de outline ao componente (Utilizar quando estiver contido em outro elemento como um painel ou pop-up)"
836
+ },
837
+ "attribute": "box-shadow",
838
+ "reflect": false,
839
+ "defaultValue": "true"
781
840
  }
782
841
  };
783
842
  }
@@ -1282,6 +1341,47 @@ export class EzGrid {
1282
1341
  "text": "Atribui o foco para a grade.",
1283
1342
  "tags": []
1284
1343
  }
1344
+ },
1345
+ "stopEdit": {
1346
+ "complexType": {
1347
+ "signature": "() => Promise<void>",
1348
+ "parameters": [],
1349
+ "references": {
1350
+ "Promise": {
1351
+ "location": "global"
1352
+ }
1353
+ },
1354
+ "return": "Promise<void>"
1355
+ },
1356
+ "docs": {
1357
+ "text": "Para a edi\u00E7\u00E3o da grade.",
1358
+ "tags": []
1359
+ }
1360
+ },
1361
+ "checkStopEditOutsideClick": {
1362
+ "complexType": {
1363
+ "signature": "(event: MouseEvent) => Promise<void>",
1364
+ "parameters": [{
1365
+ "tags": [],
1366
+ "text": ""
1367
+ }],
1368
+ "references": {
1369
+ "Promise": {
1370
+ "location": "global"
1371
+ },
1372
+ "MouseEvent": {
1373
+ "location": "global"
1374
+ },
1375
+ "Node": {
1376
+ "location": "global"
1377
+ }
1378
+ },
1379
+ "return": "Promise<void>"
1380
+ },
1381
+ "docs": {
1382
+ "text": "",
1383
+ "tags": []
1384
+ }
1285
1385
  }
1286
1386
  };
1287
1387
  }
@@ -1305,6 +1405,12 @@ export class EzGrid {
1305
1405
  "target": undefined,
1306
1406
  "capture": false,
1307
1407
  "passive": false
1408
+ }, {
1409
+ "name": "click",
1410
+ "method": "handleClick",
1411
+ "target": undefined,
1412
+ "capture": true,
1413
+ "passive": false
1308
1414
  }];
1309
1415
  }
1310
1416
  }