@sankhyalabs/ezui 0.0.0-bugfix-dev-KB-75609.0 → 0.0.0-bugfix-dev-KB-75609.1

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 (105) hide show
  1. package/dist/cjs/DataBinder-aff1dcc7.js +445 -0
  2. package/dist/cjs/FocusResolver-885f2173.js +35 -0
  3. package/dist/cjs/ez-card-item_3.cjs.entry.js +8 -2
  4. package/dist/cjs/ez-combo-box.cjs.entry.js +46 -10
  5. package/dist/cjs/ez-date-input.cjs.entry.js +8 -2
  6. package/dist/cjs/ez-date-time-input.cjs.entry.js +8 -2
  7. package/dist/cjs/ez-dialog.cjs.entry.js +9 -1
  8. package/dist/cjs/ez-form.cjs.entry.js +3 -324
  9. package/dist/cjs/ez-grid.cjs.entry.js +254 -62
  10. package/dist/cjs/ez-number-input.cjs.entry.js +7 -0
  11. package/dist/cjs/ez-search.cjs.entry.js +27 -11
  12. package/dist/cjs/ez-text-area.cjs.entry.js +6 -0
  13. package/dist/cjs/ez-text-input.cjs.entry.js +7 -1
  14. package/dist/cjs/ez-time-input.cjs.entry.js +6 -0
  15. package/dist/cjs/ezui.cjs.js +1 -1
  16. package/dist/cjs/loader.cjs.js +1 -1
  17. package/dist/collection/collection-manifest.json +1 -1
  18. package/dist/collection/components/ez-combo-box/ez-combo-box.js +75 -14
  19. package/dist/collection/components/ez-date-input/ez-date-input.js +35 -4
  20. package/dist/collection/components/ez-date-time-input/ez-date-time-input.js +35 -4
  21. package/dist/collection/components/ez-dialog/ez-dialog.js +9 -1
  22. package/dist/collection/components/ez-filter-input/ez-filter-input.js +35 -4
  23. package/dist/collection/components/ez-grid/controller/ag-grid/AgGridController.js +52 -14
  24. package/dist/collection/components/ez-grid/controller/ag-grid/DataSource.js +3 -0
  25. package/dist/collection/components/ez-grid/controller/ag-grid/GridEditionManager.js +166 -45
  26. package/dist/collection/components/ez-grid/controller/ag-grid/components/EzGridCustomCellEditor.js +7 -0
  27. package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/ComboBox.tpl.js +1 -0
  28. package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/DateInput.tpl.js +1 -0
  29. package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/NumberInput.tpl.js +1 -0
  30. package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/Search.tpl.js +1 -0
  31. package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/TextInput.tpl.js +4 -1
  32. package/dist/collection/components/ez-grid/ez-grid.js +83 -1
  33. package/dist/collection/components/ez-number-input/ez-number-input.js +25 -0
  34. package/dist/collection/components/ez-search/ez-search.js +54 -13
  35. package/dist/collection/components/ez-text-area/ez-text-area.js +24 -0
  36. package/dist/collection/components/ez-text-input/ez-text-input.css +14 -38
  37. package/dist/collection/components/ez-text-input/ez-text-input.js +24 -0
  38. package/dist/collection/components/ez-time-input/ez-time-input.js +24 -0
  39. package/dist/collection/utils/FocusResolver.js +31 -0
  40. package/dist/collection/utils/form/DataBinder.js +18 -3
  41. package/dist/custom-elements/index.js +442 -102
  42. package/dist/esm/DataBinder-bd240826.js +441 -0
  43. package/dist/esm/FocusResolver-1ccbf850.js +33 -0
  44. package/dist/esm/ez-card-item_3.entry.js +8 -2
  45. package/dist/esm/ez-combo-box.entry.js +47 -11
  46. package/dist/esm/ez-date-input.entry.js +8 -2
  47. package/dist/esm/ez-date-time-input.entry.js +8 -2
  48. package/dist/esm/ez-dialog.entry.js +9 -1
  49. package/dist/esm/ez-form.entry.js +2 -323
  50. package/dist/esm/ez-grid.entry.js +253 -61
  51. package/dist/esm/ez-number-input.entry.js +7 -0
  52. package/dist/esm/ez-search.entry.js +27 -11
  53. package/dist/esm/ez-text-area.entry.js +6 -0
  54. package/dist/esm/ez-text-input.entry.js +7 -1
  55. package/dist/esm/ez-time-input.entry.js +6 -0
  56. package/dist/esm/ezui.js +1 -1
  57. package/dist/esm/loader.js +1 -1
  58. package/dist/ezui/ezui.esm.js +1 -1
  59. package/dist/ezui/p-03a2c7d1.entry.js +1 -0
  60. package/dist/ezui/p-0a75bb05.entry.js +1 -0
  61. package/dist/ezui/{p-37219d42.entry.js → p-0db68715.entry.js} +1 -1
  62. package/dist/ezui/p-19098a3f.entry.js +1 -0
  63. package/dist/ezui/p-1f830a2f.entry.js +1 -0
  64. package/dist/ezui/p-3dd919b7.entry.js +1 -0
  65. package/dist/ezui/p-7bfae0fc.entry.js +1 -0
  66. package/dist/ezui/p-81f06699.js +1 -0
  67. package/dist/ezui/p-97af4b13.entry.js +1 -0
  68. package/dist/ezui/p-9ceefe4d.entry.js +1 -0
  69. package/dist/ezui/{p-c3c3d640.entry.js → p-b0a5c2cd.entry.js} +2 -2
  70. package/dist/ezui/p-d0ca26fe.entry.js +1 -0
  71. package/dist/ezui/p-dc628ed3.js +1 -0
  72. package/dist/ezui/p-ffd246f5.entry.js +1 -0
  73. package/dist/types/components/ez-combo-box/ez-combo-box.d.ts +7 -1
  74. package/dist/types/components/ez-date-input/ez-date-input.d.ts +6 -1
  75. package/dist/types/components/ez-date-time-input/ez-date-time-input.d.ts +6 -1
  76. package/dist/types/components/ez-dialog/ez-dialog.d.ts +2 -0
  77. package/dist/types/components/ez-filter-input/ez-filter-input.d.ts +6 -1
  78. package/dist/types/components/ez-grid/controller/EzGridController.d.ts +10 -0
  79. package/dist/types/components/ez-grid/controller/ag-grid/AgGridController.d.ts +4 -0
  80. package/dist/types/components/ez-grid/controller/ag-grid/GridEditionManager.d.ts +18 -6
  81. package/dist/types/components/ez-grid/controller/ag-grid/components/EzGridCustomCellEditor.d.ts +2 -0
  82. package/dist/types/components/ez-grid/controller/ag-grid/editor/IUICellEditor.d.ts +1 -0
  83. package/dist/types/components/ez-grid/ez-grid.d.ts +10 -0
  84. package/dist/types/components/ez-number-input/ez-number-input.d.ts +4 -0
  85. package/dist/types/components/ez-search/ez-search.d.ts +6 -1
  86. package/dist/types/components/ez-text-area/ez-text-area.d.ts +4 -0
  87. package/dist/types/components/ez-text-input/ez-text-input.d.ts +4 -0
  88. package/dist/types/components/ez-time-input/ez-time-input.d.ts +4 -0
  89. package/dist/types/components.d.ts +91 -6
  90. package/dist/types/utils/FocusResolver.d.ts +5 -0
  91. package/dist/types/utils/form/DataBinder.d.ts +3 -0
  92. package/package.json +1 -1
  93. package/dist/cjs/RecordValidationProcessor-10846595.js +0 -108
  94. package/dist/esm/RecordValidationProcessor-9c6cc267.js +0 -105
  95. package/dist/ezui/p-0f3b2e67.entry.js +0 -1
  96. package/dist/ezui/p-49456b34.entry.js +0 -1
  97. package/dist/ezui/p-5a90d7d1.entry.js +0 -1
  98. package/dist/ezui/p-62732269.entry.js +0 -1
  99. package/dist/ezui/p-b95632e8.entry.js +0 -1
  100. package/dist/ezui/p-c25f0e92.entry.js +0 -1
  101. package/dist/ezui/p-d2c06f38.entry.js +0 -1
  102. package/dist/ezui/p-e85c48d7.entry.js +0 -1
  103. package/dist/ezui/p-f0e2ce9d.entry.js +0 -1
  104. package/dist/ezui/p-f299c608.entry.js +0 -1
  105. package/dist/ezui/p-f42855b9.js +0 -1
@@ -1,4 +1,4 @@
1
- import { ElementIDUtils, FloatingManager, ObjectUtils } from "@sankhyalabs/core";
1
+ import { ElementIDUtils, FloatingManager, ObjectUtils, StringUtils } from "@sankhyalabs/core";
2
2
  import { h, Host } from "@stencil/core";
3
3
  import { CSSVarsUtils } from "../../utils";
4
4
  export class EzComboBox {
@@ -25,12 +25,13 @@ export class EzComboBox {
25
25
  this.suppressSearch = false;
26
26
  this.optionLoader = undefined;
27
27
  this.suppressEmptyOption = false;
28
- this.stopPropagateEnterKeyEvent = false;
28
+ this.stopPropagateEnterKeyEvent = true;
29
29
  this.canShowError = true;
30
30
  this.mode = "regular";
31
31
  this.hideErrorOnFocusOut = true;
32
32
  this.listOptionsPosition = undefined;
33
33
  this.isTextSearch = false;
34
+ this.autoFocus = false;
34
35
  }
35
36
  observeErrorMessage() {
36
37
  var _a;
@@ -93,9 +94,9 @@ export class EzComboBox {
93
94
  /**
94
95
  * Aplica o foco no campo.
95
96
  */
96
- async setFocus() {
97
+ async setFocus(options) {
97
98
  if (this._textInput) {
98
- this._textInput.setFocus();
99
+ this._textInput.setFocus(options);
99
100
  }
100
101
  }
101
102
  /**
@@ -255,11 +256,15 @@ export class EzComboBox {
255
256
  : undefined, h("span", { class: "item__label " + (this.showOptionValue ? "item__label--bold" : ""), title: opt.label }, opt.label));
256
257
  }
257
258
  showOptions() {
259
+ var _a, _b;
258
260
  if (!this.enabled)
259
261
  return;
260
262
  if (this.isOptionsVisible()) {
261
263
  return;
262
264
  }
265
+ const valueString = (_b = (_a = this.value) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : this.value;
266
+ const indexValue = this._visibleOptions.findIndex(option => option.value === valueString);
267
+ this._preSelection = indexValue === -1 ? 0 : indexValue;
263
268
  if (!!this._resizeObserver)
264
269
  this._resizeObserver.observe(this._textInput);
265
270
  this._floatingID = FloatingManager.float(this._listWrapper, this._listContainer, { autoClose: true, isFixed: true, backClickListener: () => this.hideOptions() });
@@ -301,11 +306,26 @@ export class EzComboBox {
301
306
  liElem.scrollIntoView({ behavior: "smooth", block: "nearest" });
302
307
  });
303
308
  }
304
- selectCurrentOption() {
309
+ selectCurrentOption(focusOnInput = true) {
305
310
  if (this._preSelection !== undefined) {
306
- this.selectOption(this._visibleOptions[this._preSelection]);
311
+ this.selectOption(this._visibleOptions[this._preSelection], focusOnInput);
307
312
  this._preSelection = undefined;
308
313
  }
314
+ else {
315
+ this.controlListWithOnlyOne(focusOnInput);
316
+ }
317
+ }
318
+ controlListWithOnlyOne(focusOnInput = true) {
319
+ var _a;
320
+ const source = (_a = this._visibleOptions) === null || _a === void 0 ? void 0 : _a.filter((opt) => opt.label !== "" && opt.value != undefined);
321
+ if ((source === null || source === void 0 ? void 0 : source.length) > 0) {
322
+ let title = StringUtils.decodeHtmlEntities(source[0].label);
323
+ const option = {
324
+ value: source[0].value,
325
+ label: title,
326
+ };
327
+ this.selectOption(option, focusOnInput);
328
+ }
309
329
  }
310
330
  updateSource(source) {
311
331
  this._startLoading = false;
@@ -331,7 +351,7 @@ export class EzComboBox {
331
351
  }
332
352
  }
333
353
  }
334
- selectOption(newOption) {
354
+ selectOption(newOption, focusOnInput = true) {
335
355
  var _a, _b;
336
356
  const currentValue = this.getSelectedOption(this.value);
337
357
  if ((((_a = currentValue === null || currentValue === void 0 ? void 0 : currentValue.value) === null || _a === void 0 ? void 0 : _a.toString()) !== ((_b = newOption === null || newOption === void 0 ? void 0 : newOption.value) === null || _b === void 0 ? void 0 : _b.toString()))
@@ -342,6 +362,11 @@ export class EzComboBox {
342
362
  else {
343
363
  this.resetOptions();
344
364
  }
365
+ if (focusOnInput) {
366
+ setTimeout(() => {
367
+ this.setFocus();
368
+ }, 0);
369
+ }
345
370
  }
346
371
  loadOptions(mode, argument = "") {
347
372
  this._criteria = argument;
@@ -425,6 +450,11 @@ export class EzComboBox {
425
450
  }
426
451
  });
427
452
  });
453
+ if (this.autoFocus) {
454
+ requestAnimationFrame(() => {
455
+ this.setFocus({ selectText: true });
456
+ });
457
+ }
428
458
  }
429
459
  //---------------------------------------------
430
460
  // Event handlers
@@ -479,18 +509,24 @@ export class EzComboBox {
479
509
  }
480
510
  switch (event.key) {
481
511
  case "ArrowDown":
512
+ event.stopPropagation();
513
+ if (this.canShowListOptions())
514
+ event.preventDefault();
482
515
  this.showOptions();
483
516
  this.nextOption();
484
- event.stopPropagation();
485
517
  break;
486
518
  case "ArrowUp":
519
+ event.stopPropagation();
520
+ if (this.canShowListOptions())
521
+ event.preventDefault();
487
522
  this.showOptions();
488
523
  this.previousOption();
489
- event.stopPropagation();
490
524
  break;
491
525
  case "Enter":
492
526
  this.handleEventPropagation(event);
493
- this.selectCurrentOption();
527
+ if (this.isOptionsVisible()) {
528
+ this.selectCurrentOption();
529
+ }
494
530
  break;
495
531
  case "Escape":
496
532
  if (this.isOptionsVisible()) {
@@ -502,7 +538,7 @@ export class EzComboBox {
502
538
  case "Tab":
503
539
  this._tabPressed = true;
504
540
  if (this.isOptionsVisible()) {
505
- this.selectCurrentOption();
541
+ this.selectCurrentOption(false);
506
542
  }
507
543
  this.resetOptions();
508
544
  break;
@@ -778,7 +814,7 @@ export class EzComboBox {
778
814
  },
779
815
  "attribute": "stop-propagate-enter-key-event",
780
816
  "reflect": false,
781
- "defaultValue": "false"
817
+ "defaultValue": "true"
782
818
  },
783
819
  "canShowError": {
784
820
  "type": "boolean",
@@ -870,6 +906,24 @@ export class EzComboBox {
870
906
  "attribute": "is-text-search",
871
907
  "reflect": false,
872
908
  "defaultValue": "false"
909
+ },
910
+ "autoFocus": {
911
+ "type": "boolean",
912
+ "mutable": false,
913
+ "complexType": {
914
+ "original": "boolean",
915
+ "resolved": "boolean",
916
+ "references": {}
917
+ },
918
+ "required": false,
919
+ "optional": false,
920
+ "docs": {
921
+ "tags": [],
922
+ "text": "Se true o campo de texto receber\u00E1 o foco ao ser renderizado."
923
+ },
924
+ "attribute": "auto-focus",
925
+ "reflect": false,
926
+ "defaultValue": "false"
873
927
  }
874
928
  };
875
929
  }
@@ -924,11 +978,18 @@ export class EzComboBox {
924
978
  },
925
979
  "setFocus": {
926
980
  "complexType": {
927
- "signature": "() => Promise<void>",
928
- "parameters": [],
981
+ "signature": "(options?: TFocusOptions) => Promise<void>",
982
+ "parameters": [{
983
+ "tags": [],
984
+ "text": ""
985
+ }],
929
986
  "references": {
930
987
  "Promise": {
931
988
  "location": "global"
989
+ },
990
+ "TFocusOptions": {
991
+ "location": "import",
992
+ "path": "../ez-text-input/ez-text-input"
932
993
  }
933
994
  },
934
995
  "return": "Promise<void>"
@@ -12,6 +12,7 @@ export class EzDateInput {
12
12
  this.errorMessage = undefined;
13
13
  this.mode = "regular";
14
14
  this.canShowError = true;
15
+ this.autoFocus = false;
15
16
  }
16
17
  observeLabel() {
17
18
  if (this._textInput) {
@@ -48,8 +49,8 @@ export class EzDateInput {
48
49
  /**
49
50
  * Aplica o foco no campo.
50
51
  */
51
- async setFocus() {
52
- this._textInput.setFocus();
52
+ async setFocus(options) {
53
+ this._textInput.setFocus(options);
53
54
  }
54
55
  /**
55
56
  * Remove o foco do campo.
@@ -167,6 +168,11 @@ export class EzDateInput {
167
168
  componentDidLoad() {
168
169
  CSSVarsUtils.applyVarsTextInput(this._elem, this._textInput);
169
170
  this.setInputValue();
171
+ if (this.autoFocus) {
172
+ requestAnimationFrame(() => {
173
+ this.setFocus({ selectText: true });
174
+ });
175
+ }
170
176
  }
171
177
  render() {
172
178
  ElementIDUtils.addIDInfoIfNotExists(this._elem, 'input');
@@ -292,6 +298,24 @@ export class EzDateInput {
292
298
  "attribute": "can-show-error",
293
299
  "reflect": true,
294
300
  "defaultValue": "true"
301
+ },
302
+ "autoFocus": {
303
+ "type": "boolean",
304
+ "mutable": false,
305
+ "complexType": {
306
+ "original": "boolean",
307
+ "resolved": "boolean",
308
+ "references": {}
309
+ },
310
+ "required": false,
311
+ "optional": false,
312
+ "docs": {
313
+ "tags": [],
314
+ "text": "Se true o campo de texto receber\u00E1 o foco ao ser renderizado."
315
+ },
316
+ "attribute": "auto-focus",
317
+ "reflect": false,
318
+ "defaultValue": "false"
295
319
  }
296
320
  };
297
321
  }
@@ -356,11 +380,18 @@ export class EzDateInput {
356
380
  return {
357
381
  "setFocus": {
358
382
  "complexType": {
359
- "signature": "() => Promise<void>",
360
- "parameters": [],
383
+ "signature": "(options?: TFocusOptions) => Promise<void>",
384
+ "parameters": [{
385
+ "tags": [],
386
+ "text": ""
387
+ }],
361
388
  "references": {
362
389
  "Promise": {
363
390
  "location": "global"
391
+ },
392
+ "TFocusOptions": {
393
+ "location": "import",
394
+ "path": "../ez-text-input/ez-text-input"
364
395
  }
365
396
  },
366
397
  "return": "Promise<void>"
@@ -13,6 +13,7 @@ export class EzDateTimeInput {
13
13
  this.showSeconds = false;
14
14
  this.mode = "regular";
15
15
  this.canShowError = true;
16
+ this.autoFocus = false;
16
17
  }
17
18
  observeLabel() {
18
19
  if (this._textInput) {
@@ -49,8 +50,8 @@ export class EzDateTimeInput {
49
50
  /**
50
51
  * Aplica o foco no campo.
51
52
  */
52
- async setFocus() {
53
- this._textInput.setFocus();
53
+ async setFocus(options) {
54
+ this._textInput.setFocus(options);
54
55
  }
55
56
  /**
56
57
  * Remove o foco do campo.
@@ -217,6 +218,11 @@ export class EzDateTimeInput {
217
218
  componentDidLoad() {
218
219
  CSSVarsUtils.applyVarsTextInput(this._elem, this._textInput);
219
220
  this.setInputValue();
221
+ if (this.autoFocus) {
222
+ requestAnimationFrame(() => {
223
+ this.setFocus({ selectText: true });
224
+ });
225
+ }
220
226
  }
221
227
  render() {
222
228
  ElementIDUtils.addIDInfoIfNotExists(this._elem, 'input');
@@ -360,6 +366,24 @@ export class EzDateTimeInput {
360
366
  "attribute": "can-show-error",
361
367
  "reflect": true,
362
368
  "defaultValue": "true"
369
+ },
370
+ "autoFocus": {
371
+ "type": "boolean",
372
+ "mutable": false,
373
+ "complexType": {
374
+ "original": "boolean",
375
+ "resolved": "boolean",
376
+ "references": {}
377
+ },
378
+ "required": false,
379
+ "optional": false,
380
+ "docs": {
381
+ "tags": [],
382
+ "text": "Se true o campo de texto receber\u00E1 o foco ao ser renderizado."
383
+ },
384
+ "attribute": "auto-focus",
385
+ "reflect": false,
386
+ "defaultValue": "false"
363
387
  }
364
388
  };
365
389
  }
@@ -424,11 +448,18 @@ export class EzDateTimeInput {
424
448
  return {
425
449
  "setFocus": {
426
450
  "complexType": {
427
- "signature": "() => Promise<void>",
428
- "parameters": [],
451
+ "signature": "(options?: TFocusOptions) => Promise<void>",
452
+ "parameters": [{
453
+ "tags": [],
454
+ "text": ""
455
+ }],
429
456
  "references": {
430
457
  "Promise": {
431
458
  "location": "global"
459
+ },
460
+ "TFocusOptions": {
461
+ "location": "import",
462
+ "path": "../ez-text-input/ez-text-input"
432
463
  }
433
464
  },
434
465
  "return": "Promise<void>"
@@ -1,6 +1,7 @@
1
1
  import { h, forceUpdate, } from '@stencil/core';
2
2
  import { DialogType } from "./DialogType";
3
3
  import { ElementIDUtils, FloatingManager } from "@sankhyalabs/core";
4
+ import FocusResolver from '../../utils/FocusResolver';
4
5
  class Message {
5
6
  constructor(title, message, dialogType, confirm, icon, labelCancel, labelConfirm, btnConfirmDanger, callBack, beforeClose) {
6
7
  this.title = title;
@@ -164,6 +165,7 @@ export class EzDialog {
164
165
  const dialog = this._element.shadowRoot.querySelector('.overlay .dialog');
165
166
  if (dialog instanceof HTMLDivElement) {
166
167
  dialog.style.outline = 'none';
168
+ this._lastActiveElement = document.activeElement;
167
169
  dialog.focus();
168
170
  }
169
171
  }
@@ -176,7 +178,13 @@ export class EzDialog {
176
178
  focusOnPrimaryButton() {
177
179
  const btnConfirm = this._element.shadowRoot.querySelector(`#${this.PRIMARY_BUTTON_ID}`);
178
180
  const buttonElement = btnConfirm === null || btnConfirm === void 0 ? void 0 : btnConfirm.shadowRoot.querySelector('button');
179
- buttonElement === null || buttonElement === void 0 ? void 0 : buttonElement.focus();
181
+ requestAnimationFrame(() => {
182
+ buttonElement === null || buttonElement === void 0 ? void 0 : buttonElement.focus();
183
+ });
184
+ }
185
+ disconnectedCallback() {
186
+ FocusResolver.resolveFocus(this._lastActiveElement);
187
+ this._lastActiveElement = undefined;
180
188
  }
181
189
  render() {
182
190
  if (this.opened && this._currentMessage) {
@@ -21,6 +21,7 @@ export class EzFilterInput {
21
21
  this.mode = "regular";
22
22
  this.asyncSearch = false;
23
23
  this.canShowError = true;
24
+ this.autoFocus = false;
24
25
  }
25
26
  observeLabel() {
26
27
  if (this._textInput) {
@@ -41,8 +42,8 @@ export class EzFilterInput {
41
42
  /**
42
43
  * Aplica o foco no campo.
43
44
  */
44
- async setFocus() {
45
- this._textInput.setFocus();
45
+ async setFocus(options) {
46
+ this._textInput.setFocus(options);
46
47
  }
47
48
  /**
48
49
  * Remove o foco do campo.
@@ -95,6 +96,11 @@ export class EzFilterInput {
95
96
  }
96
97
  componentDidLoad() {
97
98
  CSSVarsUtils.applyVarsTextInput(this._elem, this._textInput);
99
+ if (this.autoFocus) {
100
+ requestAnimationFrame(() => {
101
+ this.setFocus({ selectText: true });
102
+ });
103
+ }
98
104
  }
99
105
  render() {
100
106
  ElementIDUtils.addIDInfoIfNotExists(this._elem, 'input');
@@ -253,6 +259,24 @@ export class EzFilterInput {
253
259
  "attribute": "can-show-error",
254
260
  "reflect": true,
255
261
  "defaultValue": "true"
262
+ },
263
+ "autoFocus": {
264
+ "type": "boolean",
265
+ "mutable": false,
266
+ "complexType": {
267
+ "original": "boolean",
268
+ "resolved": "boolean",
269
+ "references": {}
270
+ },
271
+ "required": false,
272
+ "optional": false,
273
+ "docs": {
274
+ "tags": [],
275
+ "text": "Se true o campo de texto receber\u00E1 o foco ao ser renderizado."
276
+ },
277
+ "attribute": "auto-focus",
278
+ "reflect": false,
279
+ "defaultValue": "false"
256
280
  }
257
281
  };
258
282
  }
@@ -308,11 +332,18 @@ export class EzFilterInput {
308
332
  return {
309
333
  "setFocus": {
310
334
  "complexType": {
311
- "signature": "() => Promise<void>",
312
- "parameters": [],
335
+ "signature": "(options?: TFocusOptions) => Promise<void>",
336
+ "parameters": [{
337
+ "tags": [],
338
+ "text": ""
339
+ }],
313
340
  "references": {
314
341
  "Promise": {
315
342
  "location": "global"
343
+ },
344
+ "TFocusOptions": {
345
+ "location": "import",
346
+ "path": "../ez-text-input/ez-text-input"
316
347
  }
317
348
  },
318
349
  "return": "Promise<void>"
@@ -1,4 +1,4 @@
1
- import { ApplicationContext, DataType, MaskFormatter, NumberUtils, SortMode, StringUtils, UserInterface, } from '@sankhyalabs/core';
1
+ import { ApplicationContext, DataType, LockManager, MaskFormatter, NumberUtils, SortMode, StringUtils, UserInterface, } from '@sankhyalabs/core';
2
2
  import { Grid, } from 'ag-grid-community';
3
3
  import { Grid as EnterpriseGrid, LicenseManager } from 'ag-grid-enterprise';
4
4
  import DataSource from './DataSource';
@@ -121,6 +121,7 @@ export default class AgGridController {
121
121
  var _a;
122
122
  this._options = options;
123
123
  this._container = container;
124
+ const lockerId = options.enableLockManger ? LockManager.addLockManagerCtxId(this._container) : null;
124
125
  if (this._grid === undefined) {
125
126
  LicenseManager.setLicenseKey(ApplicationContext.getContextValue('__EZUI__GRID_LICENSE__'));
126
127
  this._columnStateChangeCallback = options.onColumnStateChange;
@@ -128,7 +129,7 @@ export default class AgGridController {
128
129
  this._doubleClickCallBack = options.onDoubleClick;
129
130
  this._multipleSelection = options.allowMultipleSelection;
130
131
  this._dataUnit = options.dataUnit;
131
- this._editionManager = new GridEditionManager(this._dataUnit, options.useEnterLikeTab, options.recordsValidator, options.editionIsDisabled, options.customEditors || this._customEditors, options.customRenders || this._customRenders, options.enableContinuousInsert, options.enableGridInsert);
132
+ this._editionManager = new GridEditionManager(this._dataUnit, options.useEnterLikeTab, options.recordsValidator, options.editionIsDisabled, options.customEditors || this._customEditors, options.customRenders || this._customRenders, options.enableContinuousInsert, options.enableGridInsert, lockerId);
132
133
  this._statusResolver = options.statusResolver;
133
134
  if (this._dataUnit) {
134
135
  this._dataUnit.sortingProvider = this;
@@ -491,7 +492,7 @@ export default class AgGridController {
491
492
  r.setData(data);
492
493
  });
493
494
  this._gridOptions.api.refreshCells({ force: true });
494
- const invalidCell = this._editionManager.getInvalidCell();
495
+ const invalidCell = this._editionManager.getNextInvalidCell();
495
496
  if (invalidCell) {
496
497
  const rowNode = this._gridOptions.api.getRowNode(invalidCell.recordId);
497
498
  if (rowNode && invalidCell.field) {
@@ -511,6 +512,7 @@ export default class AgGridController {
511
512
  if (this._grid === undefined) {
512
513
  throw new Error('Erro interno: Grid ainda não inicializado.');
513
514
  }
515
+ this._gridOptions.api.clearRangeSelection();
514
516
  this._gridOptions.api.refreshServerSide({ purge: true });
515
517
  this._options.onRefresh();
516
518
  if (scrollToSelectedRow)
@@ -533,12 +535,15 @@ export default class AgGridController {
533
535
  }
534
536
  setFocus() {
535
537
  var _a, _b;
536
- if ((_b = (_a = this._dataUnit) === null || _a === void 0 ? void 0 : _a.records) === null || _b === void 0 ? void 0 : _b.length) {
537
- this.setFocusFirstRow();
538
- }
539
- else {
538
+ if (!((_b = (_a = this._dataUnit) === null || _a === void 0 ? void 0 : _a.records) === null || _b === void 0 ? void 0 : _b.length)) {
540
539
  this.focusOnGridContainer();
540
+ return;
541
541
  }
542
+ if (!this._dataUnit.getSelectedRecord()) {
543
+ this.setFocusFirstRow();
544
+ return;
545
+ }
546
+ this.syncSelectWithDataUnit();
542
547
  }
543
548
  setAutoFocus(autoFocus) {
544
549
  var _a;
@@ -582,6 +587,23 @@ export default class AgGridController {
582
587
  this.startEditionOnRowByIndex(newRowIndex);
583
588
  }
584
589
  }
590
+ syncSelectWithDataUnit() {
591
+ const rowNode = this._gridOptions.api.getRowNode(this._dataUnit.getSelectedRecord().__record__id__);
592
+ if ((rowNode === null || rowNode === void 0 ? void 0 : rowNode.rowIndex) < 0)
593
+ return;
594
+ const rowRange = this._gridOptions.api.getCellRanges().find(row => row.startRow.rowIndex === rowNode.rowIndex);
595
+ if ((rowRange === null || rowRange === void 0 ? void 0 : rowRange.columns.length) > 0) {
596
+ if (this._dataUnit.hasNewRecord()) {
597
+ this.startEdition(rowNode.rowIndex, rowRange.columns[0]);
598
+ return;
599
+ }
600
+ this.focusByCollAndRow(rowRange.columns[0], rowNode.rowIndex);
601
+ this._gridOptions.api.addCellRange({ rowStartIndex: rowNode.rowIndex, rowEndIndex: rowNode.rowIndex, columns: rowRange.columns });
602
+ return;
603
+ }
604
+ this._gridOptions.api.clearRangeSelection();
605
+ this.setFocusOnRow(rowNode.rowIndex);
606
+ }
585
607
  startEdition(rowIndex, firstCol) {
586
608
  this._gridOptions.api.clearRangeSelection();
587
609
  this._gridOptions.api.addCellRange({ rowStartIndex: rowIndex, rowEndIndex: rowIndex, columns: [firstCol] });
@@ -612,6 +634,7 @@ export default class AgGridController {
612
634
  let displayedColumns = this._gridOptions.columnApi.getAllDisplayedColumns();
613
635
  let firstColl = displayedColumns.find(column => column.getColDef().headerName !== '');
614
636
  this.focusByCollAndRow(firstColl, rowIndex);
637
+ this._gridOptions.api.addCellRange({ rowStartIndex: rowIndex, rowEndIndex: rowIndex, columns: [firstColl] });
615
638
  }
616
639
  focusByCollAndRow(firstCell, rowIndex) {
617
640
  this._gridOptions.api.ensureColumnVisible(firstCell);
@@ -651,6 +674,14 @@ export default class AgGridController {
651
674
  this._gridOptions.api.setColumnDefs(this._colDefs);
652
675
  }
653
676
  }
677
+ hideSelectionColumn() {
678
+ var _a, _b;
679
+ (_b = (_a = this._gridOptions) === null || _a === void 0 ? void 0 : _a.columnApi) === null || _b === void 0 ? void 0 : _b.setColumnVisible(this.CHECK_BOX_COL_ID, false);
680
+ }
681
+ showSelectionColumn() {
682
+ var _a, _b;
683
+ (_b = (_a = this._gridOptions) === null || _a === void 0 ? void 0 : _a.columnApi) === null || _b === void 0 ? void 0 : _b.setColumnVisible(this.CHECK_BOX_COL_ID, true);
684
+ }
654
685
  getColumnsDef() {
655
686
  if (this._grid === undefined) {
656
687
  throw new Error('Erro interno: Grid ainda não inicializado.');
@@ -935,18 +966,24 @@ export default class AgGridController {
935
966
  return false;
936
967
  }
937
968
  onSelectionChange(event) {
969
+ var _a, _b;
970
+ const selectedRowId = (_b = (_a = event.api.getSelectedNodes()) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.id;
971
+ const isNewRecord = this._dataUnit.isNewRecord(selectedRowId);
938
972
  if (!this._selectionChangeCallback)
939
973
  return;
940
974
  clearTimeout(this._selectionChangeDeboucing);
941
- this._selectionChangeDeboucing = window.setTimeout(() => {
942
- this.handleExecuteProceedAutosave();
975
+ this._selectionChangeDeboucing = window.setTimeout(async () => {
976
+ const saveSuccess = (!isNewRecord && selectedRowId) ? await this.handleExecuteProceedAutosave() : true;
977
+ if (!saveSuccess)
978
+ return;
943
979
  this.processBuildSelectionChangeCallback(event);
944
980
  }, 0);
945
981
  }
946
- handleExecuteProceedAutosave() {
982
+ async handleExecuteProceedAutosave() {
947
983
  if (this._gridShowDom) {
948
- this._editionManager.proceedAutoSave();
984
+ return await this._editionManager.proceedAutoSave();
949
985
  }
986
+ return true;
950
987
  }
951
988
  processBuildSelectionChangeCallback(event) {
952
989
  if (this._dataUnit) {
@@ -971,7 +1008,7 @@ export default class AgGridController {
971
1008
  });
972
1009
  }
973
1010
  onRowDoubleClick(evt) {
974
- if (this._doubleClickCallBack) {
1011
+ if (this._doubleClickCallBack && (!this._options.enableGridInsert || !this._dataUnit.hasNewRecord())) {
975
1012
  this._doubleClickCallBack(evt.data);
976
1013
  }
977
1014
  }
@@ -987,13 +1024,11 @@ export default class AgGridController {
987
1024
  }
988
1025
  }
989
1026
  setCellEditors(customEditors) {
990
- var _a;
991
1027
  if (!this._editionManager) {
992
1028
  this._customEditors = customEditors;
993
1029
  return;
994
1030
  }
995
1031
  this._editionManager.setCellEditors(customEditors);
996
- (_a = this._gridOptions) === null || _a === void 0 ? void 0 : _a.api.redrawRows();
997
1032
  }
998
1033
  setCellRenders(customRenders) {
999
1034
  var _a;
@@ -1016,4 +1051,7 @@ export default class AgGridController {
1016
1051
  destroy() {
1017
1052
  this.observer.disconnect();
1018
1053
  }
1054
+ stopEdit() {
1055
+ this._gridOptions.api.stopEditing();
1056
+ }
1019
1057
  }
@@ -6,12 +6,14 @@ export default class DataSource {
6
6
  this._controller.clearInvalidCells();
7
7
  this.handleRefreshOrReload(action);
8
8
  this._controller.processContinuousInsert();
9
+ this._controller.showSelectionColumn();
9
10
  }
10
11
  handleEditionCanceled(action) {
11
12
  if (this._options.enableGridInsert) {
12
13
  this._controller.processEditionCanceled();
13
14
  }
14
15
  this.handleRefreshOrReload(action);
16
+ this._controller.showSelectionColumn();
15
17
  }
16
18
  handleSavingCanceled(action) {
17
19
  var _a, _b, _c, _d;
@@ -66,6 +68,7 @@ export default class DataSource {
66
68
  }
67
69
  handleRecordsAdded() {
68
70
  if (this._options.enableGridInsert) {
71
+ this._controller.hideSelectionColumn();
69
72
  this._controller.refresh();
70
73
  this.focusOnNewRecord();
71
74
  }