@sankhyalabs/ezui 5.10.8 → 5.11.0-dev.2

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 (137) hide show
  1. package/README.md +0 -1
  2. package/dist/cjs/{CSSVarsUtils-af809e73.js → CSSVarsUtils-b136a156.js} +5 -0
  3. package/dist/cjs/RecordValidationProcessor-edd23705.js +102 -0
  4. package/dist/cjs/ez-actions-button.cjs.entry.js +1 -1
  5. package/dist/cjs/ez-calendar.cjs.entry.js +34 -5
  6. package/dist/cjs/ez-combo-box.cjs.entry.js +89 -14
  7. package/dist/cjs/ez-date-input.cjs.entry.js +53 -22
  8. package/dist/cjs/ez-date-time-input.cjs.entry.js +53 -19
  9. package/dist/cjs/ez-filter-input_2.cjs.entry.js +1 -1
  10. package/dist/cjs/ez-form.cjs.entry.js +9 -83
  11. package/dist/cjs/ez-grid.cjs.entry.js +488 -6
  12. package/dist/cjs/ez-number-input.cjs.entry.js +39 -15
  13. package/dist/cjs/ez-search.cjs.entry.js +11 -2
  14. package/dist/cjs/ez-text-area.cjs.entry.js +6 -2
  15. package/dist/cjs/ez-text-input.cjs.entry.js +7 -4
  16. package/dist/cjs/ez-time-input.cjs.entry.js +11 -7
  17. package/dist/cjs/ezui.cjs.js +1 -1
  18. package/dist/cjs/loader.cjs.js +1 -1
  19. package/dist/collection/collection-manifest.json +2 -2
  20. package/dist/collection/components/ez-calendar/ez-calendar.js +63 -6
  21. package/dist/collection/components/ez-combo-box/ez-combo-box.css +6 -0
  22. package/dist/collection/components/ez-combo-box/ez-combo-box.js +122 -12
  23. package/dist/collection/components/ez-date-input/ez-date-input.js +71 -21
  24. package/dist/collection/components/ez-date-time-input/ez-date-time-input.js +71 -18
  25. package/dist/collection/components/ez-grid/controller/ag-grid/AgGridController.js +40 -7
  26. package/dist/collection/components/ez-grid/controller/ag-grid/DataSource.js +1 -0
  27. package/dist/collection/components/ez-grid/controller/ag-grid/GridEditionManager.js +230 -0
  28. package/dist/collection/components/ez-grid/controller/ag-grid/editor/EzCellEditor.js +49 -0
  29. package/dist/collection/components/ez-grid/controller/ag-grid/editor/GridEditorUtils.js +10 -0
  30. package/dist/collection/components/ez-grid/controller/ag-grid/editor/IEditorMetadata.js +4 -0
  31. package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/ComboBox.tpl.js +38 -0
  32. package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/DateInput.tpl.js +40 -0
  33. package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/NumberInput.tpl.js +20 -0
  34. package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/Search.tpl.js +15 -0
  35. package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/TextInput.tpl.js +41 -0
  36. package/dist/collection/components/ez-grid/ez-grid.js +67 -0
  37. package/dist/collection/components/ez-number-input/ez-number-input.css +4 -0
  38. package/dist/collection/components/ez-number-input/ez-number-input.js +62 -15
  39. package/dist/collection/components/ez-search/ez-search.css +1 -1
  40. package/dist/collection/components/ez-search/ez-search.js +46 -1
  41. package/dist/collection/components/ez-text-area/ez-text-area.css +4 -0
  42. package/dist/collection/components/ez-text-area/ez-text-area.js +23 -1
  43. package/dist/collection/components/ez-text-input/ez-text-input.css +8 -1
  44. package/dist/collection/components/ez-text-input/ez-text-input.js +14 -5
  45. package/dist/collection/components/ez-time-input/ez-time-input.css +4 -0
  46. package/dist/collection/components/ez-time-input/ez-time-input.js +18 -7
  47. package/dist/collection/utils/CSSVarsUtils.js +5 -0
  48. package/dist/collection/utils/form/DataBinder.js +7 -62
  49. package/dist/collection/utils/form/FormMetadata.js +3 -22
  50. package/dist/collection/utils/interfaces/AbstractFieldMetadata.js +21 -0
  51. package/dist/collection/utils/validators/recordvalidator/IValidationResult.js +1 -0
  52. package/dist/collection/utils/validators/recordvalidator/IValidationSource.js +1 -0
  53. package/dist/collection/utils/validators/recordvalidator/RecordValidationProcessor.js +74 -0
  54. package/dist/custom-elements/index.js +922 -203
  55. package/dist/esm/{CSSVarsUtils-00f67f32.js → CSSVarsUtils-a97cfa29.js} +5 -0
  56. package/dist/esm/RecordValidationProcessor-abc814af.js +99 -0
  57. package/dist/esm/ez-actions-button.entry.js +1 -1
  58. package/dist/esm/ez-calendar.entry.js +35 -6
  59. package/dist/esm/ez-combo-box.entry.js +89 -14
  60. package/dist/esm/ez-date-input.entry.js +53 -22
  61. package/dist/esm/ez-date-time-input.entry.js +53 -19
  62. package/dist/esm/ez-filter-input_2.entry.js +1 -1
  63. package/dist/esm/ez-form.entry.js +10 -84
  64. package/dist/esm/ez-grid.entry.js +489 -7
  65. package/dist/esm/ez-number-input.entry.js +39 -15
  66. package/dist/esm/ez-search.entry.js +11 -2
  67. package/dist/esm/ez-text-area.entry.js +6 -2
  68. package/dist/esm/ez-text-input.entry.js +7 -4
  69. package/dist/esm/ez-time-input.entry.js +11 -7
  70. package/dist/esm/ezui.js +1 -1
  71. package/dist/esm/loader.js +1 -1
  72. package/dist/ezui/ezui.esm.js +1 -1
  73. package/dist/ezui/p-028f264f.entry.js +1 -0
  74. package/dist/ezui/p-391de0e4.entry.js +1 -0
  75. package/dist/ezui/p-4535da17.entry.js +1 -0
  76. package/dist/ezui/p-5cef0264.entry.js +1 -0
  77. package/dist/ezui/p-7eb3e1a5.js +1 -0
  78. package/dist/ezui/p-86a2036d.js +1 -0
  79. package/dist/ezui/{p-12303d2e.entry.js → p-87e85160.entry.js} +1 -1
  80. package/dist/ezui/p-90fa4cb3.entry.js +1 -0
  81. package/dist/ezui/p-9f41b414.entry.js +1 -0
  82. package/dist/ezui/p-ce035beb.entry.js +1 -0
  83. package/dist/ezui/p-d43b22f3.entry.js +1 -0
  84. package/dist/ezui/p-e2dfd935.entry.js +1 -0
  85. package/dist/ezui/p-e67d0bd5.entry.js +1 -0
  86. package/dist/ezui/{p-c7a23be9.entry.js → p-fd54b5b4.entry.js} +2 -2
  87. package/dist/ezui/{p-f1a537e3.entry.js → p-ff82b176.entry.js} +1 -1
  88. package/dist/types/components/ez-calendar/ez-calendar.d.ts +9 -1
  89. package/dist/types/components/ez-combo-box/ez-combo-box.d.ts +14 -0
  90. package/dist/types/components/ez-date-input/ez-date-input.d.ts +4 -0
  91. package/dist/types/components/ez-date-time-input/ez-date-time-input.d.ts +4 -0
  92. package/dist/types/components/ez-form-view/interfaces/IFormViewField.d.ts +2 -14
  93. package/dist/types/components/ez-grid/controller/EzGridController.d.ts +18 -0
  94. package/dist/types/components/ez-grid/controller/ag-grid/AgGridController.d.ts +4 -0
  95. package/dist/types/components/ez-grid/controller/ag-grid/GridEditionManager.d.ts +38 -0
  96. package/dist/types/components/ez-grid/controller/ag-grid/editor/EzCellEditor.d.ts +10 -0
  97. package/dist/types/components/ez-grid/controller/ag-grid/editor/GridEditorUtils.d.ts +1 -0
  98. package/dist/types/components/ez-grid/controller/ag-grid/editor/IEditorMetadata.d.ts +9 -0
  99. package/dist/types/components/ez-grid/controller/ag-grid/editor/IUICellEditor.d.ts +10 -0
  100. package/dist/types/components/ez-grid/controller/ag-grid/editor/templates/ComboBox.tpl.d.ts +4 -0
  101. package/dist/types/components/ez-grid/controller/ag-grid/editor/templates/DateInput.tpl.d.ts +5 -0
  102. package/dist/types/components/ez-grid/controller/ag-grid/editor/templates/NumberInput.tpl.d.ts +4 -0
  103. package/dist/types/components/ez-grid/controller/ag-grid/editor/templates/Search.tpl.d.ts +3 -0
  104. package/dist/types/components/ez-grid/controller/ag-grid/editor/templates/TextInput.tpl.d.ts +4 -0
  105. package/dist/types/components/ez-grid/ez-grid.d.ts +13 -0
  106. package/dist/types/components/ez-number-input/ez-number-input.d.ts +5 -1
  107. package/dist/types/components/ez-search/ez-search.d.ts +6 -1
  108. package/dist/types/components/ez-text-area/ez-text-area.d.ts +4 -0
  109. package/dist/types/components/ez-text-input/ez-text-input.d.ts +4 -1
  110. package/dist/types/components/ez-time-input/ez-time-input.d.ts +2 -1
  111. package/dist/types/components.d.ts +65 -6
  112. package/dist/types/utils/form/DataBinder.d.ts +1 -3
  113. package/dist/types/utils/form/interfaces/IFormConfig.d.ts +1 -1
  114. package/dist/types/utils/form/interfaces/index.d.ts +4 -4
  115. package/dist/types/utils/interfaces/AbstractFieldMetadata.d.ts +17 -0
  116. package/dist/types/utils/{form/interfaces → interfaces}/IFieldConfig.d.ts +2 -2
  117. package/dist/types/utils/validators/recordvalidator/IValidationSource.d.ts +6 -0
  118. package/dist/types/utils/validators/recordvalidator/RecordValidationProcessor.d.ts +13 -0
  119. package/package.json +2 -2
  120. package/dist/ezui/p-00c7c25d.entry.js +0 -1
  121. package/dist/ezui/p-0b160fec.entry.js +0 -1
  122. package/dist/ezui/p-0bd54a6f.entry.js +0 -1
  123. package/dist/ezui/p-39153935.entry.js +0 -1
  124. package/dist/ezui/p-4a5e37a7.js +0 -1
  125. package/dist/ezui/p-5782443e.entry.js +0 -1
  126. package/dist/ezui/p-5d45e384.entry.js +0 -1
  127. package/dist/ezui/p-70ea4beb.entry.js +0 -1
  128. package/dist/ezui/p-78a6e049.entry.js +0 -1
  129. package/dist/ezui/p-8bcb197f.entry.js +0 -1
  130. package/dist/ezui/p-a4c9f3c4.entry.js +0 -1
  131. /package/dist/collection/{utils/form/interfaces/IFieldConfig.js → components/ez-grid/controller/ag-grid/editor/IUICellEditor.js} +0 -0
  132. /package/dist/collection/utils/{form/interfaces/IInvalidField.js → interfaces/IFieldConfig.js} +0 -0
  133. /package/dist/collection/utils/{form/interfaces/IRecordValidator.js → validators/recordvalidator/IInvalidField.js} +0 -0
  134. /package/dist/collection/utils/{form/interfaces/IValidationResult.js → validators/recordvalidator/IRecordValidator.js} +0 -0
  135. /package/dist/types/utils/{form/interfaces → validators/recordvalidator}/IInvalidField.d.ts +0 -0
  136. /package/dist/types/utils/{form/interfaces → validators/recordvalidator}/IRecordValidator.d.ts +0 -0
  137. /package/dist/types/utils/{form/interfaces → validators/recordvalidator}/IValidationResult.d.ts +0 -0
@@ -1,7 +1,8 @@
1
1
  import { h, r as registerInstance, c as createEvent, H as Host, g as getElement } from './index-296b8458.js';
2
- import { Action, ObjectUtils as ObjectUtils$1, ApplicationContext, StringUtils as StringUtils$1, UserInterface, NumberUtils as NumberUtils$1, DataType, SortMode, ElementIDUtils, JSUtils, DateUtils as DateUtils$1 } from '@sankhyalabs/core';
2
+ import { Action, ObjectUtils as ObjectUtils$1, HTMLBuilder, ApplicationContext, UserInterface, StringUtils as StringUtils$1, NumberUtils as NumberUtils$1, MaskFormatter, DataType, SortMode, ElementIDUtils, JSUtils, DateUtils as DateUtils$1 } from '@sankhyalabs/core';
3
3
  import { SelectionMode } from '@sankhyalabs/core/dist/dataunit/DataUnit';
4
4
  import { D as DISTINCT_FILTER_NAME_PREFIX } from './constants-6dab64f7.js';
5
+ import { b as buildFieldMetadata, R as RecordValidationProcessor } from './RecordValidationProcessor-abc814af.js';
5
6
  import { A as ApplicationUtils } from './ApplicationUtils-d9a34a16.js';
6
7
  import './DialogType-54a62731.js';
7
8
  import './CheckMode-bdb2ec19.js';
@@ -118850,6 +118851,7 @@ class DataSource {
118850
118851
  case Action.DATA_SAVED:
118851
118852
  case Action.EDITION_CANCELED:
118852
118853
  case Action.DATA_CHANGED:
118854
+ case Action.DATA_RESOLVED:
118853
118855
  this._controller.refresh();
118854
118856
  break;
118855
118857
  case Action.SELECTION_CHANGED:
@@ -119183,6 +119185,443 @@ const gridTerms = {
119183
119185
  ctrlV: "Ctrl+V"
119184
119186
  };
119185
119187
 
119188
+ const buildEditorMetadata = (descriptor, eGridCell, dataUnit, editionManager) => {
119189
+ return Object.assign(Object.assign({}, buildFieldMetadata(descriptor)), { eGridCell, dataUnit, editionManager });
119190
+ };
119191
+
119192
+ const MINIMIUM_WIDTH_TEXTAREA = 210;
119193
+ const PADDING_VALUE_TEXTAREA = 12;
119194
+ const buildTextInput = ({ name, contextName }) => {
119195
+ return HTMLBuilder.parseElement(`<ez-text-input
119196
+ class="ez-grid grid_editor"
119197
+ data-field-name=${name}
119198
+ data-context-name=${contextName}
119199
+ mode="slim"
119200
+ />`);
119201
+ };
119202
+ const buildTextAreaInput = ({ eGridCell, editionManager }) => {
119203
+ const element = HTMLBuilder.parseElement(`<ez-text-area
119204
+ can-show-error="false"
119205
+ enable-resize="true"
119206
+ />`);
119207
+ element.addEventListener('keydown', event => handlePressEnterEvent(event, element, editionManager));
119208
+ setElementInitialWidth(eGridCell, element);
119209
+ element.isPopUp = true;
119210
+ return element;
119211
+ };
119212
+ function setElementInitialWidth(eGridCell, element) {
119213
+ const { width } = eGridCell.getBoundingClientRect();
119214
+ const newValue = width > MINIMIUM_WIDTH_TEXTAREA ? width : MINIMIUM_WIDTH_TEXTAREA;
119215
+ element.style.minWidth = `${newValue - PADDING_VALUE_TEXTAREA}px`;
119216
+ element.style.resize = "both";
119217
+ }
119218
+ function handlePressEnterEvent(event, element, editionManager) {
119219
+ if (isEnter(event)) {
119220
+ const shouldBreakLine = event.ctrlKey;
119221
+ if (shouldBreakLine) {
119222
+ element.appendTextToSelection('\n');
119223
+ event.preventDefault();
119224
+ return;
119225
+ }
119226
+ editionManager.navigateByEnterKey(event);
119227
+ }
119228
+ }
119229
+ function isEnter(event) {
119230
+ return [event.key, event.code].includes('Enter');
119231
+ }
119232
+
119233
+ const LIMIT_TIME_VALUE = 2359;
119234
+ const buildDate = () => {
119235
+ const dateInput = HTMLBuilder.parseElement(`<ez-date-input
119236
+ class="ez-grid grid_editor"
119237
+ mode="slim"
119238
+ data-is-fixed="true"
119239
+ />`);
119240
+ dateInput.valueGetter = () => dateInput.getValueAsync();
119241
+ return dateInput;
119242
+ };
119243
+ const buildTime = ({ readOnly }) => {
119244
+ const timeInputElement = HTMLBuilder.parseElement(`<ez-time-input
119245
+ class="ez-grid grid_editor"
119246
+ enabled=${!readOnly}
119247
+ mode="slim"
119248
+ />`);
119249
+ timeInputElement.valueGetter = () => {
119250
+ const value = timeInputElement.value;
119251
+ const isAllowedTime = parseInt(value) <= LIMIT_TIME_VALUE;
119252
+ return isAllowedTime ? value : null;
119253
+ };
119254
+ timeInputElement.valueSetter = (value) => {
119255
+ const isAllowedTime = parseInt(value) <= LIMIT_TIME_VALUE;
119256
+ if (!isAllowedTime)
119257
+ return timeInputElement.value = null;
119258
+ return timeInputElement.value = value;
119259
+ };
119260
+ return timeInputElement;
119261
+ };
119262
+ const buildDateTime = ({ readOnly }) => {
119263
+ const dateTimeInput = HTMLBuilder.parseElement(`<ez-date-time-input
119264
+ class="ez-grid grid_editor"
119265
+ mode="slim"
119266
+ enabled=${!readOnly}
119267
+ data-is-fixed="true"
119268
+ />`);
119269
+ dateTimeInput.valueGetter = () => dateTimeInput.getValueAsync();
119270
+ return dateTimeInput;
119271
+ };
119272
+
119273
+ const buildDecimal = ({ readOnly, props }) => {
119274
+ const precision = Number((props === null || props === void 0 ? void 0 : props.precision) || 2);
119275
+ const prettyPrecision = Number((props === null || props === void 0 ? void 0 : props.prettyPrecision) || precision);
119276
+ return buildNumeric(readOnly, precision, prettyPrecision);
119277
+ };
119278
+ const buildInteger = ({ readOnly }) => {
119279
+ return buildNumeric(readOnly, 0, 0);
119280
+ };
119281
+ function buildNumeric(readOnly, precision, prettyPrecision) {
119282
+ const input = HTMLBuilder.parseElement(`<ez-number-input
119283
+ class="ez-grid grid_editor"
119284
+ enabled=${!readOnly}
119285
+ precision=${precision}
119286
+ pretty-precision=${prettyPrecision}
119287
+ mode="slim"
119288
+ />`);
119289
+ input.valueGetter = () => input.getValueAsync();
119290
+ return input;
119291
+ }
119292
+
119293
+ function getViewPortHeight(cell) {
119294
+ let currentElem = cell;
119295
+ while (currentElem) {
119296
+ const viewPort = currentElem.querySelector("[ref=eBodyViewport]");
119297
+ if (viewPort) {
119298
+ return viewPort.getBoundingClientRect().bottom;
119299
+ }
119300
+ currentElem = currentElem.parentElement;
119301
+ }
119302
+ }
119303
+
119304
+ const BOOLEAN_OPTIONS = new Map([[true, { value: "S", label: "Sim" }], [false, { value: "N", label: "Não" }]]);
119305
+ const buildComboBox = ({ required, props, eGridCell }) => {
119306
+ const prop = props === null || props === void 0 ? void 0 : props.options;
119307
+ let options;
119308
+ if (typeof prop === "string") {
119309
+ const parsed = JSON.parse(prop);
119310
+ options = Object.keys(parsed).map(key => { return { value: key, label: parsed[key] }; });
119311
+ }
119312
+ else {
119313
+ options = prop;
119314
+ }
119315
+ const combo = HTMLBuilder.parseElement(`<ez-combo-box
119316
+ class="grid_editor"
119317
+ suppress-empty-option=${required}
119318
+ mode="slim"
119319
+ />`);
119320
+ combo.options = options;
119321
+ combo.listOptionsPosition = { verticalPosition: 29, bottomLimit: getViewPortHeight(eGridCell), hardPosition: true };
119322
+ return combo;
119323
+ };
119324
+ const buildSwitch = (fieldMetadata) => {
119325
+ const combo = buildComboBox(Object.assign(Object.assign({}, fieldMetadata), { props: Object.assign(Object.assign({}, fieldMetadata.props), { options: Array.from(BOOLEAN_OPTIONS.values()) }) }));
119326
+ combo.valueGetter = () => {
119327
+ const value = combo.value;
119328
+ if (value == undefined) {
119329
+ return;
119330
+ }
119331
+ return value.value == "S";
119332
+ };
119333
+ combo.valueSetter = (value) => {
119334
+ if (value != undefined) {
119335
+ combo.value = BOOLEAN_OPTIONS.get(value);
119336
+ }
119337
+ };
119338
+ return combo;
119339
+ };
119340
+
119341
+ const buildSearch = ({ name, required, readOnly, eGridCell, dataUnit }) => {
119342
+ const ezSearch = HTMLBuilder.parseElement(`<ez-search
119343
+ class="ez-grid grid_editor"
119344
+ mode="slim"
119345
+ suppress-empty-option=${required}
119346
+ enabled=${!readOnly}
119347
+ />`);
119348
+ const loader = ApplicationContext.getContextValue("__EZUI__SEARCH__OPTION__LOADER__");
119349
+ ezSearch.optionLoader = (argument) => loader(argument, name, dataUnit);
119350
+ ezSearch.listOptionsPosition = { verticalPosition: 29, bottomLimit: getViewPortHeight(eGridCell), hardPosition: true };
119351
+ ezSearch.valueGetter = () => ezSearch.getValueAsync();
119352
+ return ezSearch;
119353
+ };
119354
+
119355
+ const uiBuilders = new Map();
119356
+ uiBuilders.set(UserInterface.DATE, buildDate);
119357
+ uiBuilders.set(UserInterface.TIME, buildTime);
119358
+ uiBuilders.set(UserInterface.DATETIME, buildDateTime);
119359
+ uiBuilders.set(UserInterface.DECIMALNUMBER, buildDecimal);
119360
+ uiBuilders.set(UserInterface.INTEGERNUMBER, buildInteger);
119361
+ uiBuilders.set(UserInterface.SWITCH, buildSwitch);
119362
+ uiBuilders.set(UserInterface.CHECKBOX, buildSwitch);
119363
+ uiBuilders.set(UserInterface.OPTIONSELECTOR, buildComboBox);
119364
+ uiBuilders.set(UserInterface.LONGTEXT, buildTextAreaInput);
119365
+ uiBuilders.set(UserInterface.SEARCH, buildSearch);
119366
+ class EzCellEditor {
119367
+ init(params) {
119368
+ const fieldName = params.column.getColId();
119369
+ const dataUnit = params.context.dataUnit;
119370
+ const fieldMetadata = buildEditorMetadata(dataUnit.getField(fieldName), params.eGridCell, dataUnit, params.context.editionManager);
119371
+ const builder = uiBuilders.get(fieldMetadata.userInterface) || buildTextInput;
119372
+ this._gui = builder(fieldMetadata);
119373
+ if (this._gui.valueSetter != undefined) {
119374
+ this._gui.valueSetter(params.value);
119375
+ }
119376
+ else {
119377
+ this._gui.value = params.value;
119378
+ }
119379
+ }
119380
+ getGui() {
119381
+ return this._gui;
119382
+ }
119383
+ afterGuiAttached() {
119384
+ this.focusIn();
119385
+ }
119386
+ focusIn() {
119387
+ this._gui.focus();
119388
+ this._gui.setFocus({ selectText: true });
119389
+ }
119390
+ getValue() {
119391
+ return this._gui.valueGetter != undefined ? this._gui.valueGetter() : this._gui.value;
119392
+ }
119393
+ isPopup() {
119394
+ return this._gui.isPopUp;
119395
+ }
119396
+ }
119397
+
119398
+ class GridEditionManager {
119399
+ constructor(dataUnit, useEnterLikeTab, recordsValidator, editionIsDisabled) {
119400
+ this._dataUnit = dataUnit;
119401
+ this._recordValidationProcessor = new RecordValidationProcessor(this._dataUnit, {
119402
+ getRequiredFields: () => this.getRequiredFields(),
119403
+ markAsInvalid: () => { },
119404
+ getMessageForField: () => null
119405
+ }, recordsValidator);
119406
+ this._useEnterLikeTab = useEnterLikeTab;
119407
+ this._editionIsDisabled = editionIsDisabled;
119408
+ }
119409
+ configureGrid(options) {
119410
+ this._gridOptions = options;
119411
+ options.readOnlyEdit = true;
119412
+ options.onCellEditRequest = evt => this.onCellEditRequest(evt);
119413
+ options.onCellKeyDown = evt => {
119414
+ if (evt.event && evt["column"]) {
119415
+ this.onCellKeyDown(evt);
119416
+ }
119417
+ };
119418
+ return options;
119419
+ }
119420
+ proceedAutoSave() {
119421
+ if (!this._dataUnit.isDirty()) {
119422
+ this.saveSuccess();
119423
+ return;
119424
+ }
119425
+ if (!this._isGridEdition) {
119426
+ return;
119427
+ }
119428
+ const currentRercord = this._dataUnit.getSelectedRecord();
119429
+ if (currentRercord == undefined) {
119430
+ return;
119431
+ }
119432
+ this._recordValidationProcessor
119433
+ .validate()
119434
+ .then(() => {
119435
+ this._dataUnit.saveData()
119436
+ .then(() => this.saveSuccess())
119437
+ .catch(reason => this.saveFail(reason));
119438
+ })
119439
+ .catch(reason => this.saveFail(reason));
119440
+ }
119441
+ navigateByEnterKey(keyboardEvent) {
119442
+ const backwards = keyboardEvent.shiftKey;
119443
+ if (this._useEnterLikeTab) {
119444
+ if (backwards) {
119445
+ this._gridOptions.api.tabToPreviousCell(keyboardEvent);
119446
+ }
119447
+ else {
119448
+ this._gridOptions.api.tabToNextCell(keyboardEvent);
119449
+ }
119450
+ }
119451
+ else {
119452
+ const editionCell = this._gridOptions.api.getEditingCells()[0];
119453
+ if (editionCell) {
119454
+ let { rowIndex } = editionCell;
119455
+ this.nextEditionRow(rowIndex, editionCell.column, backwards);
119456
+ }
119457
+ }
119458
+ }
119459
+ getComponents() {
119460
+ return { ezCellEditor: EzCellEditor };
119461
+ }
119462
+ verifyClickToEdition(api, cellClicked) {
119463
+ if (this.isSecondClick(cellClicked)) {
119464
+ api.startEditingCell({ rowIndex: cellClicked.rowIndex, colKey: cellClicked.column.getColId() });
119465
+ }
119466
+ this._lastCellClicked = cellClicked;
119467
+ }
119468
+ configureColumn(col) {
119469
+ col.cellEditor = 'ezCellEditor';
119470
+ col.editable = params => this.canEdit(params);
119471
+ col.suppressKeyboardEvent = (params) => {
119472
+ return params.event.key === KeyCode.ENTER;
119473
+ };
119474
+ return col;
119475
+ }
119476
+ getRequiredFields() {
119477
+ return this._gridOptions.columnApi.getAllDisplayedColumns().filter(c => {
119478
+ const fieldDefinition = this._dataUnit.getField(c.getColId());
119479
+ return fieldDefinition && fieldDefinition.required;
119480
+ }).map(c => c.getColId());
119481
+ }
119482
+ saveSuccess() {
119483
+ this.focusOnCell(this._targetEditionCell);
119484
+ this._lastCellEdited = undefined;
119485
+ this._targetEditionCell = undefined;
119486
+ this._isGridEdition = false;
119487
+ }
119488
+ saveFail(reason) {
119489
+ this.focusOnCell(this._lastCellEdited);
119490
+ this._isGridEdition = false;
119491
+ if (reason) {
119492
+ Promise.reject(reason);
119493
+ }
119494
+ }
119495
+ focusOnCell(cell) {
119496
+ if (cell == undefined) {
119497
+ return;
119498
+ }
119499
+ const { rowIndex, column } = cell;
119500
+ this._gridOptions.api.getDisplayedRowAtIndex(rowIndex).setSelected(true, true);
119501
+ this._gridOptions.api.clearRangeSelection();
119502
+ this._gridOptions.api.addCellRange({ rowStartIndex: rowIndex, rowEndIndex: rowIndex, columns: [column] });
119503
+ this._gridOptions.api.startEditingCell({ colKey: column.getColId(), rowIndex });
119504
+ this._gridOptions.api.setFocusedCell(rowIndex, column.getColId());
119505
+ const cellEditor = this._gridOptions.api.getCellEditorInstances()[0];
119506
+ if (cellEditor) {
119507
+ cellEditor.focusIn();
119508
+ }
119509
+ }
119510
+ onCellKeyDown(event) {
119511
+ const keyboardEvent = event.event;
119512
+ switch (keyboardEvent.key) {
119513
+ case KeyCode.ENTER:
119514
+ this.processEnterKey(keyboardEvent, event);
119515
+ break;
119516
+ case KeyCode.UP:
119517
+ this.editPreviousRow(event.api);
119518
+ break;
119519
+ case KeyCode.DOWN:
119520
+ this.editNextRow(event.api);
119521
+ break;
119522
+ }
119523
+ }
119524
+ processEnterKey(keyboardEvent, event) {
119525
+ const editionCell = event.api.getEditingCells()[0];
119526
+ if (!editionCell) {
119527
+ event.api.startEditingCell({ colKey: event.column.getColId(), rowIndex: event.rowIndex });
119528
+ return;
119529
+ }
119530
+ this.navigateByEnterKey(keyboardEvent);
119531
+ }
119532
+ nextEditionRow(rowIndex, column, backwards) {
119533
+ if (backwards) {
119534
+ rowIndex = rowIndex - 1;
119535
+ if (rowIndex < 0) {
119536
+ rowIndex = this._dataUnit.records.length - 1;
119537
+ }
119538
+ }
119539
+ else {
119540
+ rowIndex = rowIndex + 1;
119541
+ if (rowIndex >= this._dataUnit.records.length) {
119542
+ rowIndex = 0;
119543
+ }
119544
+ }
119545
+ this._targetEditionCell = new TargetEdition(rowIndex, column, true);
119546
+ this.finishEdition();
119547
+ }
119548
+ editPreviousRow(api) {
119549
+ this.moveEditionVertically(api, -1);
119550
+ }
119551
+ editNextRow(api) {
119552
+ this.moveEditionVertically(api, 1);
119553
+ }
119554
+ moveEditionVertically(api, offset) {
119555
+ const editionCell = api.getEditingCells()[0];
119556
+ if (!editionCell) {
119557
+ return;
119558
+ }
119559
+ const rowIndex = editionCell.rowIndex + offset;
119560
+ if (api.getDisplayedRowAtIndex(rowIndex)) {
119561
+ this._targetEditionCell = new TargetEdition(rowIndex, editionCell.column, offset < 0);
119562
+ this.finishEdition();
119563
+ }
119564
+ }
119565
+ finishEdition() {
119566
+ this._gridOptions.api.stopEditing();
119567
+ setTimeout(() => {
119568
+ //O Timeout foi inserido para permitir que o ciclo de finalização prossiga
119569
+ //pois precisamos aguardar o fim da edição para executar o autosave.
119570
+ this.proceedAutoSave();
119571
+ }, 0);
119572
+ }
119573
+ canEdit(params) {
119574
+ if (this._editionIsDisabled()) {
119575
+ return false;
119576
+ }
119577
+ return this.isColEditable(params.colDef.field);
119578
+ }
119579
+ isColEditable(fieldName) {
119580
+ const fieldDefinition = this._dataUnit.getField(fieldName);
119581
+ if (fieldDefinition) {
119582
+ return !fieldDefinition.readOnly;
119583
+ }
119584
+ return false;
119585
+ }
119586
+ isSecondClick(cellClicked) {
119587
+ if (!this._lastCellClicked) {
119588
+ return false;
119589
+ }
119590
+ if (this._lastCellClicked.column != cellClicked.column) {
119591
+ return false;
119592
+ }
119593
+ if (this._lastCellClicked.rowIndex != cellClicked.rowIndex) {
119594
+ return false;
119595
+ }
119596
+ return true;
119597
+ }
119598
+ onCellEditRequest(event) {
119599
+ const fieldName = event.colDef.field;
119600
+ const value = event.newValue;
119601
+ if (event.oldValue != value) {
119602
+ if (value instanceof Promise) {
119603
+ const fieldDescriptor = this._dataUnit.getField(event.colDef.colId);
119604
+ event.node.setData(Object.assign(Object.assign({}, event.data), { [fieldName]: (fieldDescriptor === null || fieldDescriptor === void 0 ? void 0 : fieldDescriptor.userInterface) === UserInterface.SEARCH ? value : event.oldValue }));
119605
+ value.then(resolved => event.node.setData(Object.assign(Object.assign({}, event.data), { [fieldName]: resolved })));
119606
+ }
119607
+ else {
119608
+ event.node.setData(Object.assign(Object.assign({}, event.data), { [fieldName]: value }));
119609
+ }
119610
+ this._isGridEdition = true;
119611
+ this._dataUnit.setFieldValue(fieldName, value, [event.data.__record__id__]);
119612
+ this._lastCellEdited = { rowIndex: event.rowIndex, column: event.column, rowPinned: undefined };
119613
+ }
119614
+ }
119615
+ }
119616
+ class TargetEdition {
119617
+ constructor(rowIndex, column, backwards) {
119618
+ this.rowPinned = null;
119619
+ this.rowIndex = rowIndex;
119620
+ this.column = column;
119621
+ this.backwards = backwards;
119622
+ }
119623
+ }
119624
+
119186
119625
  class AgGridController {
119187
119626
  configFilterColumn(filterColumn) {
119188
119627
  this._filterColumn = filterColumn;
@@ -119218,6 +119657,9 @@ class AgGridController {
119218
119657
  getGridConfig() {
119219
119658
  return this._gridConfig;
119220
119659
  }
119660
+ getGridApi() {
119661
+ return this._gridOptions.api;
119662
+ }
119221
119663
  getSort() {
119222
119664
  const sortedColumns = [];
119223
119665
  this._gridOptions.columnApi
@@ -119278,6 +119720,7 @@ class AgGridController {
119278
119720
  this._doubleClickCallBack = options.onDoubleClick;
119279
119721
  this._multipleSelection = options.allowMultipleSelection;
119280
119722
  this._dataUnit = options.dataUnit;
119723
+ this._editionManager = new GridEditionManager(this._dataUnit, options.useEnterLikeTab, options.recordsValidator, options.editionIsDisabled);
119281
119724
  this._statusResolver = options.statusResolver;
119282
119725
  if (this._dataUnit) {
119283
119726
  this._dataUnit.sortingProvider = this;
@@ -119297,12 +119740,14 @@ class AgGridController {
119297
119740
  defaultColDef: {
119298
119741
  headerClass: 'ez-grid__cell-header',
119299
119742
  cellClass: 'ez-grid__cell-body',
119743
+ cellStyle: {
119744
+ height: '100%'
119745
+ }
119300
119746
  },
119301
- components: {
119302
- ezGridHeaderComponent: SelectionHeader,
119303
- ezGridCustomHeader: EzGridCustomHeader,
119304
- },
119747
+ components: Object.assign({ ezGridHeaderComponent: SelectionHeader, ezGridCustomHeader: EzGridCustomHeader }, this._editionManager.getComponents()),
119305
119748
  context: {
119749
+ editionManager: this._editionManager,
119750
+ dataUnit: this._dataUnit,
119306
119751
  headerCheckStatusGetter: () => this.getSelectionHeaderStatus(),
119307
119752
  headerCheckStatusSetter: (selectAll) => this.updateSelectionForAll(selectAll),
119308
119753
  },
@@ -119310,6 +119755,7 @@ class AgGridController {
119310
119755
  this.defineRowModelType(this._gridOptions, options);
119311
119756
  this.setOptionsEvents(this._gridOptions);
119312
119757
  this.setOptionsSupress(this._gridOptions);
119758
+ this._gridOptions = this._editionManager.configureGrid(this._gridOptions);
119313
119759
  if (this._enterprise) {
119314
119760
  this._grid = new Grid(container, this._gridOptions);
119315
119761
  }
@@ -119456,6 +119902,7 @@ class AgGridController {
119456
119902
  opt.onSelectionChanged = e => this.onSelectionChange(e);
119457
119903
  opt.onRowDoubleClicked = evt => this.onRowDoubleClick(evt);
119458
119904
  opt.onDragStopped = evt => this.onCallStateChange('columnMovedEnd', evt);
119905
+ opt.onCellClicked = evt => this.onCellClicked(evt);
119459
119906
  }
119460
119907
  setOptionsSupress(opt) {
119461
119908
  opt.suppressDragLeaveHidesColumns = true;
@@ -119759,7 +120206,7 @@ class AgGridController {
119759
120206
  else if (propSortable === false) {
119760
120207
  tooltip = 'Coluna não pode ser ordenada';
119761
120208
  }
119762
- return {
120209
+ return this._editionManager.configureColumn({
119763
120210
  headerName: source.label,
119764
120211
  field: source.name,
119765
120212
  sortable: propSortable,
@@ -119772,10 +120219,19 @@ class AgGridController {
119772
120219
  showColumnFilter: (leftPosition) => this.showFilterColumn({ columnName: source.name, columnLabel: source.label, leftPosition, filteredOptions: this._filteredColumns.get(source.name) }),
119773
120220
  },
119774
120221
  valueFormatter: params => {
120222
+ if (params.value == undefined) {
120223
+ return "";
120224
+ }
120225
+ if (params.value instanceof Promise) {
120226
+ return "Carregando...";
120227
+ }
120228
+ if (this._dataUnit) {
120229
+ return this._dataUnit.getFormattedValue(source.name, params.value);
120230
+ }
119775
120231
  return this.getFormatterByColumn(params, source);
119776
120232
  },
119777
120233
  cellStyle: this.getStyleByColumn(source),
119778
- };
120234
+ });
119779
120235
  }
119780
120236
  getInitCellStyle() {
119781
120237
  return {
@@ -119848,6 +120304,13 @@ class AgGridController {
119848
120304
  return params.value.toLocaleDateString();
119849
120305
  }
119850
120306
  }
120307
+ if ((source === null || source === void 0 ? void 0 : source.userInterface) === UserInterface.ELAPSEDTIME || (source === null || source === void 0 ? void 0 : source.userInterface) === UserInterface.TIME) {
120308
+ if (!!params.value) {
120309
+ const maskFormatter = new MaskFormatter("##:##");
120310
+ const formattedValue = String(params.value).padStart(4, '0');
120311
+ return maskFormatter.format(formattedValue);
120312
+ }
120313
+ }
119851
120314
  }
119852
120315
  onCallStateChange(type, e) {
119853
120316
  const finished = !('finished' in e) || e['finished'];
@@ -119862,6 +120325,13 @@ class AgGridController {
119862
120325
  this._columnStateChangeCallback(type, this.getColumnsState(), info);
119863
120326
  }
119864
120327
  }
120328
+ onCellClicked(event) {
120329
+ this._editionManager.verifyClickToEdition(event.api, {
120330
+ rowIndex: event.rowIndex,
120331
+ column: event.column,
120332
+ rowPinned: undefined
120333
+ });
120334
+ }
119865
120335
  isElementResize(e) {
119866
120336
  return e['target'] && e['target'].getAttribute('ref') === 'eResize';
119867
120337
  }
@@ -119879,6 +120349,7 @@ class AgGridController {
119879
120349
  if (this._selectionChangeCallback) {
119880
120350
  clearTimeout(this._selectionChangeDeboucing);
119881
120351
  this._selectionChangeDeboucing = window.setTimeout(() => {
120352
+ this._editionManager.proceedAutoSave();
119882
120353
  if (this._dataUnit) {
119883
120354
  if (event.context.selectionChangeQuietly) {
119884
120355
  const selectionInfo = this._dataUnit;
@@ -120000,6 +120471,9 @@ const EzGrid = class {
120000
120471
  this.dataUnit = undefined;
120001
120472
  this.statusResolver = undefined;
120002
120473
  this.columnfilterDataSource = undefined;
120474
+ this.useEnterLikeTab = false;
120475
+ this.recordsValidator = undefined;
120476
+ this.canEdit = true;
120003
120477
  }
120004
120478
  /**
120005
120479
  * Aplica a definição de colunas.
@@ -120233,6 +120707,9 @@ const EzGrid = class {
120233
120707
  serverURL: this.serverUrl,
120234
120708
  dataUnit: this.dataUnit,
120235
120709
  statusResolver: this.statusResolver,
120710
+ useEnterLikeTab: this.useEnterLikeTab,
120711
+ recordsValidator: this.recordsValidator,
120712
+ editionIsDisabled: () => !this.canEdit
120236
120713
  });
120237
120714
  if (this.config) {
120238
120715
  this.observeConfig(this.config);
@@ -120241,6 +120718,11 @@ const EzGrid = class {
120241
120718
  this.setEvents();
120242
120719
  this.componentReady.emit();
120243
120720
  this._gridController.configFilterColumn(this._filterColumn);
120721
+ this._container.addEventListener('focusout', (event) => {
120722
+ const api = this._gridController.getGridApi();
120723
+ if (api && !this._container.contains(event.relatedTarget))
120724
+ api.clearFocusedCell();
120725
+ });
120244
120726
  }
120245
120727
  componentWillRender() {
120246
120728
  this.configSelectionCounter();