@sankhyalabs/ezui 1.1.158 → 1.1.160

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 (79) hide show
  1. package/dist/cjs/ez-combo-box.cjs.entry.js +109 -29
  2. package/dist/cjs/ez-date-input.cjs.entry.js +71 -25
  3. package/dist/cjs/ez-date-time-input.cjs.entry.js +94 -31
  4. package/dist/cjs/ez-filter-input.cjs.entry.js +10 -4
  5. package/dist/cjs/ez-form.cjs.entry.js +54 -9
  6. package/dist/cjs/ez-grid.cjs.entry.js +9 -6
  7. package/dist/cjs/ez-number-input.cjs.entry.js +69 -25
  8. package/dist/cjs/ez-search.cjs.entry.js +20 -5
  9. package/dist/cjs/ez-text-area.cjs.entry.js +8 -2
  10. package/dist/cjs/ez-text-input.cjs.entry.js +38 -21
  11. package/dist/cjs/ez-time-input.cjs.entry.js +75 -40
  12. package/dist/cjs/ezui.cjs.js +1 -1
  13. package/dist/cjs/loader.cjs.js +1 -1
  14. package/dist/collection/components/ez-combo-box/ez-combo-box.css +15 -17
  15. package/dist/collection/components/ez-combo-box/ez-combo-box.js +132 -33
  16. package/dist/collection/components/ez-date-input/ez-date-input.js +87 -25
  17. package/dist/collection/components/ez-date-time-input/ez-date-time-input.js +108 -31
  18. package/dist/collection/components/ez-filter-input/ez-filter-input.js +26 -4
  19. package/dist/collection/components/ez-form/DataBinder.js +12 -3
  20. package/dist/collection/components/ez-form/ez-form.js +43 -6
  21. package/dist/collection/components/ez-grid/controller/ag-grid/AgGridController.js +1 -1
  22. package/dist/collection/components/ez-grid/ez-grid.js +14 -7
  23. package/dist/collection/components/ez-number-input/ez-number-input.js +83 -25
  24. package/dist/collection/components/ez-search/ez-search.js +38 -5
  25. package/dist/collection/components/ez-text-area/ez-text-area.css +1 -1
  26. package/dist/collection/components/ez-text-area/ez-text-area.js +23 -1
  27. package/dist/collection/components/ez-text-input/ez-text-input.css +2 -2
  28. package/dist/collection/components/ez-text-input/ez-text-input.js +53 -38
  29. package/dist/collection/components/ez-time-input/ez-time-input.js +95 -59
  30. package/dist/custom-elements/index.js +598 -239
  31. package/dist/esm/ez-combo-box.entry.js +109 -29
  32. package/dist/esm/ez-date-input.entry.js +71 -25
  33. package/dist/esm/ez-date-time-input.entry.js +94 -31
  34. package/dist/esm/ez-filter-input.entry.js +10 -4
  35. package/dist/esm/ez-form.entry.js +54 -9
  36. package/dist/esm/ez-grid.entry.js +9 -6
  37. package/dist/esm/ez-number-input.entry.js +69 -25
  38. package/dist/esm/ez-search.entry.js +20 -5
  39. package/dist/esm/ez-text-area.entry.js +8 -2
  40. package/dist/esm/ez-text-input.entry.js +38 -21
  41. package/dist/esm/ez-time-input.entry.js +76 -41
  42. package/dist/esm/ezui.js +1 -1
  43. package/dist/esm/loader.js +1 -1
  44. package/dist/ezui/ezui.esm.js +1 -1
  45. package/dist/ezui/p-003d53b1.entry.js +1 -0
  46. package/dist/ezui/p-267fa515.entry.js +1 -0
  47. package/dist/ezui/p-2acf7d59.entry.js +1 -0
  48. package/dist/ezui/p-403de0a4.entry.js +1 -0
  49. package/dist/ezui/p-4c3d136c.entry.js +1 -0
  50. package/dist/ezui/p-53bbba8e.entry.js +1 -0
  51. package/dist/ezui/p-6668c3b0.entry.js +1 -0
  52. package/dist/ezui/p-7fd6deec.entry.js +1 -0
  53. package/dist/ezui/p-ad6cc559.entry.js +1 -0
  54. package/dist/ezui/{p-be87ac5e.entry.js → p-ae2fea4c.entry.js} +1 -1
  55. package/dist/ezui/p-ff7b4b13.entry.js +1 -0
  56. package/dist/types/components/ez-combo-box/ez-combo-box.d.ts +22 -8
  57. package/dist/types/components/ez-date-input/ez-date-input.d.ts +10 -3
  58. package/dist/types/components/ez-date-time-input/ez-date-time-input.d.ts +15 -7
  59. package/dist/types/components/ez-filter-input/ez-filter-input.d.ts +5 -1
  60. package/dist/types/components/ez-form/DataBinder.d.ts +1 -1
  61. package/dist/types/components/ez-form/ez-form.d.ts +1 -0
  62. package/dist/types/components/ez-grid/ez-grid.d.ts +4 -1
  63. package/dist/types/components/ez-number-input/ez-number-input.d.ts +14 -5
  64. package/dist/types/components/ez-search/ez-search.d.ts +6 -1
  65. package/dist/types/components/ez-text-area/ez-text-area.d.ts +4 -0
  66. package/dist/types/components/ez-text-input/ez-text-input.d.ts +9 -6
  67. package/dist/types/components/ez-time-input/ez-time-input.d.ts +17 -13
  68. package/dist/types/components.d.ts +49 -20
  69. package/package.json +1 -1
  70. package/dist/ezui/p-140f7085.entry.js +0 -1
  71. package/dist/ezui/p-49fdfa4b.entry.js +0 -1
  72. package/dist/ezui/p-4fdceb7d.entry.js +0 -1
  73. package/dist/ezui/p-6d4b1628.entry.js +0 -1
  74. package/dist/ezui/p-8f4fac31.entry.js +0 -1
  75. package/dist/ezui/p-91377c65.entry.js +0 -1
  76. package/dist/ezui/p-991ce464.entry.js +0 -1
  77. package/dist/ezui/p-b524dfca.entry.js +0 -1
  78. package/dist/ezui/p-ec21ecce.entry.js +0 -1
  79. package/dist/ezui/p-fc9b9487.entry.js +0 -1
@@ -4,17 +4,21 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-c15a9551.js');
6
6
  const core = require('@sankhyalabs/core');
7
+ const ApplicationUtils = require('./ApplicationUtils-4a223c7a.js');
7
8
  const CSSVarsUtils = require('./CSSVarsUtils-1034b7b6.js');
8
9
 
9
- const ezComboBoxCss = ":host{--ez-combo-box--height:42px;--ez-combo-box--width:100%;--ez-combo-box__icon--width:48px;--ez-combo-box--border-radius:var(--border--radius-medium, 12px);--ez-combo-box--border-radius-small:var(--border--radius-small, 6px);--ez-combo-box--font-size:var(--text--medium, 14px);--ez-combo-box--font-family:var(--font-pattern, Arial);--ez-combo-box--font-weight--large:var(--text-weight--large, 500);--ez-combo-box--font-weight--medium:var(--text-weight--medium, 400);--ez-combo-box--background-color--xlight:var(--background--xlight, #fff);--ez-combo-box--background-medium:var(--background--medium, #f0f3f7);--ez-combo-box__input--background-color:var(--background--medium, #e0e0e0);--ez-combo-box__input--border:var(--border--medium, 2px solid);--ez-combo-box__input--border-color:var(--ez-combo-box__input--background-color);--ez-combo-box__input--focus--border-color:var(--color--primary, #008561);--ez-combo-box__input--disabled--background-color:var(--color--disable-secondary, #F2F5F8);--ez-combo-box__input--disabled--color:var(--text--disable, #AFB6C0);--ez-combo-box__input--error--border-color:#CC2936;--ez-combo-box__btn--color:var(--text--primary, #626e82);--ez-combo-box__btn-disabled--color:var(--text--disable, #AFB6C0);--ez-combo-box__btn-hover--color:var(--color--primary, #4e4e4e);--ez-combo-box__label--color:var(--title--primary, #2B3A54);--ez-combo-box__list-title--primary:var(--title--primary, #2B3A54);--ez-combo-box__list-text--primary:var(--text--primary, #626e82);--ez-combo-box__list-height:calc(var(--ez-combo-box--font-size) + var(--ez-combo-box--space--medium));--ez-combo-box--space--medium:var(--space--medium, 12px);--ez-combo-box--space--small:var(--space--small, 6px);--ez-combo-box__list-scrollbar--background-color:var(--text--primary, #626e82);--ez-combo-box__list-scrollbar--border-radius:var(--border--radius-small, 6px);--ez-combo-box__list-scrollbar--width:var(--space--medium, 12px);display:flex;flex-wrap:wrap;position:relative;width:var(--ez-combo-box--width)}ez-icon{--ez-icon--color:inherit}.suppressed-search-input{--ez-text-input__input--border-color:var(--color--strokes, #dce0e8);--ez-text-input__input--disabled--background-color:var(--background--xlight, #fff);--ez-text-input__input--disabled--color:var(--title--primary, #2B3A54)}.list-container{position:relative;width:100%}.list-wrapper{display:flex;flex-direction:column;box-sizing:border-box;width:100%;z-index:var(--more-visible, 2);max-height:calc(4*var(--ez-combo-box__list-height) + 2*var(--ez-combo-box--space--small));background-color:var(--ez-combo-box--background-color--xlight);border-radius:var(--ez-combo-box--border-radius);box-shadow:var(--shadow, 0px 0px 16px 0px #000);padding:var(--ez-combo-box--space--small)}.list-options{box-sizing:border-box;width:100%;height:100%;display:flex;flex-direction:column;scroll-behavior:smooth;overflow:auto}.list-options::-webkit-scrollbar-track{background-color:#f0f2f5;border-radius:var(--ez-combo-box__list-scrollbar--border-radius)}.list-options::-webkit-scrollbar-thumb{background-color:var(--ez-combo-box__list-scrollbar--background-color);border-radius:var(--ez-combo-box__list-scrollbar--border-radius)}.list-options::-webkit-scrollbar{background-color:#f0f2f5;width:var(--ez-combo-box__list-scrollbar--width);max-width:var(--ez-combo-box__list-scrollbar--width);min-width:var(--ez-combo-box__list-scrollbar--width)}.item{display:flex;align-items:center;width:100%;box-sizing:border-box;list-style-type:none;cursor:pointer;border-radius:var(--ez-combo-box--border-radius-small);padding:0 var(--ez-combo-box--space--small);min-height:var(--ez-combo-box__list-height);gap:var(--space--small, 6px)}.item__value,.item__label{font-weight:var(--ez-combo-box--font-weight--large);font-family:var(--ez-combo-box--font-family);font-size:var(--ez-combo-box--font-size)}.item__value,.item__label{flex-basis:auto;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--ez-combo-box__list-title--primary)}.item__value{text-align:center;color:var(--ez-combo-box__list-text--primary)}.item__value--hidden{visibility:hidden;position:absolute;z-index:-1;top:0;left:0}.item__label{text-align:left}.message{text-align:center;display:flex;justify-content:center;align-items:center;list-style-type:none;padding:var(--ez-combo-box--space--small);border-radius:var(--ez-combo-box--border-radius-small);min-height:var(--ez-combo-box__list-height)}.message__no-result{color:var(--ez-combo-box__list-title--primary);font-family:var(--ez-combo-box--font-family)}.message__loading{border-radius:50%;width:20px;height:20px;-webkit-animation:spin 1s linear infinite;animation:spin 1s linear infinite;border:2px solid var(--color--secondary-700);border-top:2px solid transparent}li:hover{background-color:var(--ez-combo-box--background-medium)}.preselected{background-color:var(--background--medium)}.btn{outline:none;border:none;background:none;cursor:pointer;color:var(--ez-combo-box__btn--color)}.btn:disabled{cursor:unset;color:var(--ez-combo-box__btn-disabled--color)}.btn:disabled:hover{cursor:unset;color:var(--ez-combo-box__btn-disabled--color)}.btn:hover{color:var(--ez-combo-box__btn-hover--color)}@-webkit-keyframes spin{0%{-webkit-transform:rotate(0deg)}100%{-webkit-transform:rotate(360deg)}}@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}";
10
+ const ezComboBoxCss = ":host{--ez-combo-box--height:42px;--ez-combo-box--width:100%;--ez-combo-box__icon--width:48px;--ez-combo-box--border-radius:var(--border--radius-medium, 12px);--ez-combo-box--border-radius-small:var(--border--radius-small, 6px);--ez-combo-box--font-size:var(--text--medium, 14px);--ez-combo-box--font-family:var(--font-pattern, Arial);--ez-combo-box--font-weight--large:var(--text-weight--large, 500);--ez-combo-box--font-weight--medium:var(--text-weight--medium, 400);--ez-combo-box--background-color--xlight:var(--background--xlight, #fff);--ez-combo-box--background-medium:var(--background--medium, #f0f3f7);--ez-combo-box__input--background-color:var(--background--medium, #e0e0e0);--ez-combo-box__input--border:var(--border--medium, 2px solid);--ez-combo-box__input--border-color:var(--ez-combo-box__input--background-color);--ez-combo-box__input--focus--border-color:var(--color--primary, #008561);--ez-combo-box__input--disabled--background-color:var(--color--disable-secondary, #F2F5F8);--ez-combo-box__input--disabled--color:var(--text--disable, #AFB6C0);--ez-combo-box__input--error--border-color:#CC2936;--ez-combo-box__btn--color:var(--title--primary, #2B3A54);--ez-combo-box__btn-disabled--color:var(--text--disable, #AFB6C0);--ez-combo-box__btn-hover--color:var(--color--primary, #4e4e4e);--ez-combo-box__label--color:var(--title--primary, #2B3A54);--ez-combo-box__list-title--primary:var(--title--primary, #2B3A54);--ez-combo-box__list-text--primary:var(--text--primary, #626e82);--ez-combo-box__list-height:calc(var(--ez-combo-box--font-size) + var(--ez-combo-box--space--medium));--ez-combo-box--space--medium:var(--space--medium, 12px);--ez-combo-box--space--small:var(--space--small, 6px);--ez-combo-box__list-scrollbar--background-color:var(--title--primary, #2B3A54);--ez-combo-box__list-scrollbar--border-radius:var(--border--radius-small, 6px);--ez-combo-box__list-scrollbar--width:var(--space--medium, 12px);display:flex;flex-wrap:wrap;position:relative;width:var(--ez-combo-box--width)}ez-icon{--ez-icon--color:inherit;font-weight:var(--text-weight--large, 600)}.suppressed-search-input{--ez-text-input__input--border-color:var(--color--strokes, #dce0e8);--ez-text-input__input--disabled--background-color:var(--background--xlight, #fff);--ez-text-input__input--disabled--color:var(--title--primary, #2B3A54)}.list-container{position:relative;width:100%}.list-wrapper{display:flex;flex-direction:column;box-sizing:border-box;width:100%;z-index:var(--more-visible, 2);max-height:calc(4*var(--ez-combo-box__list-height) + 2*var(--ez-combo-box--space--small));background-color:var(--ez-combo-box--background-color--xlight);border-radius:var(--ez-combo-box--border-radius);box-shadow:var(--shadow, 0px 0px 16px 0px #000);padding:var(--ez-combo-box--space--small)}.list-options{box-sizing:border-box;width:100%;height:100%;display:flex;flex-direction:column;scroll-behavior:smooth;overflow:auto}.list-options::-webkit-scrollbar-track{background-color:#f0f2f5;border-radius:var(--ez-combo-box__list-scrollbar--border-radius)}.list-options::-webkit-scrollbar-thumb{background-color:var(--ez-combo-box__list-scrollbar--background-color);border-radius:var(--ez-combo-box__list-scrollbar--border-radius)}.list-options::-webkit-scrollbar{background-color:#f0f2f5;width:var(--ez-combo-box__list-scrollbar--width);max-width:var(--ez-combo-box__list-scrollbar--width);min-width:var(--ez-combo-box__list-scrollbar--width)}.item{display:flex;align-items:center;width:100%;box-sizing:border-box;list-style-type:none;cursor:pointer;border-radius:var(--ez-combo-box--border-radius-small);padding:0 var(--ez-combo-box--space--small);min-height:var(--ez-combo-box__list-height);gap:var(--space--small, 6px)}.item__value,.item__label{flex-basis:auto;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--ez-combo-box__list-title--primary);font-weight:var(--ez-combo-box--font-weight--large);font-family:var(--ez-combo-box--font-family);font-size:var(--ez-combo-box--font-size)}.item__value{text-align:center;color:var(--ez-combo-box__list-text--primary)}.item__value--hidden{visibility:hidden;position:absolute;z-index:-1;top:0;left:0}.item__label{text-align:left}.message{text-align:center;display:flex;justify-content:center;align-items:center;list-style-type:none;min-height:calc(var(--ez-combo-box__list-height) * 1.5)}.message__no-result{color:var(--ez-combo-box__list-title--primary);font-family:var(--ez-combo-box--font-family);font-size:var(--ez-combo-box--font-size)}.message__loading{border-radius:50%;width:16px;height:16px;-webkit-animation:spin 1s linear infinite;animation:spin 1s linear infinite;border:3px solid var(--ez-combo-box__list-title--primary);border-top:3px solid transparent}li:hover{background-color:var(--ez-combo-box--background-medium)}.preselected{background-color:var(--background--medium)}.btn{outline:none;border:none;background:none;cursor:pointer;color:var(--ez-combo-box__btn--color)}.btn:disabled{cursor:unset;color:var(--ez-combo-box__btn-disabled--color)}.btn:disabled:hover{cursor:unset;color:var(--ez-combo-box__btn-disabled--color)}.btn:hover{color:var(--ez-combo-box__btn-hover--color)}@-webkit-keyframes spin{0%{-webkit-transform:rotate(0deg)}100%{-webkit-transform:rotate(360deg)}}@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}";
10
11
 
11
12
  let EzComboBox = class {
12
13
  constructor(hostRef) {
13
14
  index.registerInstance(this, hostRef);
14
15
  this.ezChange = index.createEvent(this, "ezChange", 7);
16
+ this._changeDeboucingTimeout = null;
15
17
  this._limitCharsToSearch = 3;
16
18
  this._deboucingTime = 300;
17
19
  this._maxWidthValue = 0;
20
+ this._tabPressed = false;
21
+ this._textEmptyList = "Nenhum resultado encontrado";
18
22
  this._startLoading = false;
19
23
  this._showLoading = true;
20
24
  /**
@@ -46,40 +50,66 @@ let EzComboBox = class {
46
50
  */
47
51
  this.mode = "regular";
48
52
  }
49
- observeValue() {
50
- if (this._inputElement) {
51
- this._inputElement.value = this.getText();
53
+ observeErrorMessage() {
54
+ var _a;
55
+ if (this._textInput) {
56
+ this._textInput.errorMessage = this.errorMessage;
57
+ if (!((_a = this.errorMessage) === null || _a === void 0 ? void 0 : _a.trim())) {
58
+ this.setInputValue();
59
+ }
60
+ }
61
+ }
62
+ observeValue(newValue, oldValue) {
63
+ var _a, _b, _c, _d;
64
+ if (this._textInput && newValue != oldValue) {
65
+ const newValueSelected = this.getSelectedOption(newValue);
66
+ const oldValueSelected = this.getSelectedOption(oldValue);
67
+ const currentValue = this.getSelectedOption(this.value);
68
+ if (((_a = currentValue === null || currentValue === void 0 ? void 0 : currentValue.value) === null || _a === void 0 ? void 0 : _a.toString()) != ((_b = newValueSelected === null || newValueSelected === void 0 ? void 0 : newValueSelected.value) === null || _b === void 0 ? void 0 : _b.toString())) {
69
+ this.value = newValueSelected;
70
+ }
71
+ if (((_c = newValueSelected === null || newValueSelected === void 0 ? void 0 : newValueSelected.value) === null || _c === void 0 ? void 0 : _c.toString()) !== ((_d = oldValueSelected === null || oldValueSelected === void 0 ? void 0 : oldValueSelected.value) === null || _d === void 0 ? void 0 : _d.toString())) {
72
+ this.setInputValue();
73
+ const valueEmitted = newValueSelected === null ? undefined : newValueSelected;
74
+ this.ezChange.emit(valueEmitted);
75
+ }
76
+ this.hideOptions();
77
+ this._criteria = undefined;
78
+ this._preSelection = undefined;
79
+ this.updateVisibleOptions();
52
80
  }
53
- this.hideOptions();
54
- this._criteria = undefined;
55
- this._preSelection = undefined;
56
- this.updateVisibleOptions();
57
81
  }
58
82
  /**
59
83
  * Realiza o foco no componente de seleção
60
84
  */
61
85
  async setFocus() {
62
- this._inputElement.setFocus();
86
+ this._textInput.setFocus();
63
87
  }
64
88
  /**
65
89
  * Remove o foco no componente de seleção
66
90
  */
67
91
  async setBlur() {
68
- this._inputElement.setBlur();
92
+ this._textInput.setBlur();
93
+ }
94
+ /**
95
+ * Retorna informando se o campo está inválido (true | false)
96
+ */
97
+ async isInvalid() {
98
+ return typeof this.errorMessage === "string" && this.errorMessage.trim() !== "";
69
99
  }
70
100
  getText() {
71
101
  let text = "";
72
- const selected = this.getSelectedOption();
73
- if (selected) {
74
- text = this.showSelectedValue ? `${selected.value} - ${selected.label}` : selected.label;
102
+ const currentValue = this.getSelectedOption(this.value);
103
+ if (currentValue) {
104
+ text = this.showSelectedValue ? `${currentValue.value} - ${currentValue.label}` : currentValue.label;
75
105
  }
76
106
  return text;
77
107
  }
78
- getSelectedOption() {
79
- if (typeof this.value === "string" || this.value instanceof String) {
80
- return this._visibleOptions.find(o => o.value === this.value);
108
+ getSelectedOption(value) {
109
+ if (typeof value === "string" || value instanceof String) {
110
+ return this._visibleOptions.find(o => o.value === value);
81
111
  }
82
- return this.value;
112
+ return value;
83
113
  }
84
114
  updateVisibleOptions() {
85
115
  let opts = this._source || [];
@@ -134,7 +164,7 @@ let EzComboBox = class {
134
164
  //FIXME: Provavelmente isso fará com que o popup abra em uma
135
165
  //posição errada no futuro. Preferi fazer simples no começo,
136
166
  //porque não quis onerar o text input com essa funcionalidade...
137
- const top = (this.errorMessage || !this.canShowError || this.mode == "slim") ? "0px" : "-19px";
167
+ const top = (this.errorMessage || !this.canShowError || this.mode === "slim") ? "0px" : "-19px";
138
168
  this._floatingID = core.FloatingManager.float(this._listWrapper, this._listContainer, { autoClose: true, top });
139
169
  window.requestAnimationFrame(() => {
140
170
  this._listWrapper.scrollIntoView({ behavior: "smooth", block: "nearest", inline: "nearest" });
@@ -182,6 +212,9 @@ let EzComboBox = class {
182
212
  this.selectOption(this._visibleOptions[this._preSelection]);
183
213
  this._preSelection = undefined;
184
214
  }
215
+ else {
216
+ this.controlListWithOnlyOne();
217
+ }
185
218
  }
186
219
  updateSource(source) {
187
220
  this._startLoading = false;
@@ -198,6 +231,10 @@ let EzComboBox = class {
198
231
  if (Array.isArray(source)) {
199
232
  this._source = source;
200
233
  this.updateVisibleOptions();
234
+ if (this._tabPressed) {
235
+ this._tabPressed = false;
236
+ this.controlEmptySearch();
237
+ }
201
238
  }
202
239
  else {
203
240
  this.selectOption(source);
@@ -210,15 +247,16 @@ let EzComboBox = class {
210
247
  }
211
248
  selectOption(newOption) {
212
249
  var _a, _b;
213
- const currentOpt = this.getSelectedOption();
214
- if (((_a = currentOpt === null || currentOpt === void 0 ? void 0 : currentOpt.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())) {
250
+ const currentValue = this.getSelectedOption(this.value);
251
+ 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())) {
215
252
  const adjustedOpt = !(newOption === null || newOption === void 0 ? void 0 : newOption.value) ? undefined : newOption;
216
253
  this.value = adjustedOpt;
217
- this.errorMessage = "";
218
- this.ezChange.emit(this.value);
219
254
  }
220
255
  else {
221
- this.observeValue();
256
+ this.setInputValue();
257
+ }
258
+ if (this.searchMode) {
259
+ this._visibleOptions = [];
222
260
  }
223
261
  }
224
262
  loadOptions(mode, argument = "") {
@@ -232,11 +270,43 @@ let EzComboBox = class {
232
270
  }
233
271
  }
234
272
  cancelPreselection() {
235
- if (!this._inputElement.value && this.value) {
273
+ if (!this._textInput.value && this.value) {
236
274
  this.selectOption(undefined);
237
275
  }
238
276
  else {
239
- this.observeValue();
277
+ this.setInputValue();
278
+ }
279
+ }
280
+ setInputValue(clearError = true) {
281
+ const textValue = this.getText();
282
+ if ((this._textInput.value || '') !== textValue) {
283
+ this._textInput.value = textValue;
284
+ if (clearError) {
285
+ this.errorMessage = "";
286
+ }
287
+ }
288
+ }
289
+ clearSearch() {
290
+ this.value = null;
291
+ }
292
+ controlListWithOnlyOne() {
293
+ if (this.searchMode) {
294
+ const source = this._visibleOptions;
295
+ if ((source === null || source === void 0 ? void 0 : source.length) === 1) {
296
+ this.selectOption(source[0]);
297
+ }
298
+ }
299
+ }
300
+ controlEmptySearch() {
301
+ var _a;
302
+ if (this.searchMode) {
303
+ if (!((_a = this._visibleOptions) === null || _a === void 0 ? void 0 : _a.length)) {
304
+ this.clearSearch();
305
+ ApplicationUtils.ApplicationUtils.info(this._textEmptyList);
306
+ }
307
+ else {
308
+ this.controlListWithOnlyOne();
309
+ }
240
310
  }
241
311
  }
242
312
  //---------------------------------------------
@@ -271,7 +341,8 @@ let EzComboBox = class {
271
341
  }
272
342
  }
273
343
  componentDidLoad() {
274
- CSSVarsUtils.CSSVarsUtils.applyVarsTextInput(this.el, this._inputElement);
344
+ CSSVarsUtils.CSSVarsUtils.applyVarsTextInput(this.el, this._textInput);
345
+ this.setInputValue(false);
275
346
  }
276
347
  //---------------------------------------------
277
348
  // Event handlers
@@ -291,7 +362,7 @@ let EzComboBox = class {
291
362
  const argument = (_a = event.target.value) === null || _a === void 0 ? void 0 : _a.trim();
292
363
  const argumentNumber = Number(argument || undefined);
293
364
  if (!this._criteria) {
294
- this._inputElement.value = event.data || argument;
365
+ this._textInput.value = event.data || argument;
295
366
  }
296
367
  this._criteria = argument;
297
368
  if (argument && (!isNaN(argumentNumber) || argument.length >= this._limitCharsToSearch)) {
@@ -323,6 +394,7 @@ let EzComboBox = class {
323
394
  }
324
395
  }
325
396
  keyDownHandler(event) {
397
+ this._tabPressed = false;
326
398
  switch (event.key) {
327
399
  case "ArrowDown":
328
400
  this.nextOption();
@@ -336,6 +408,10 @@ let EzComboBox = class {
336
408
  case "Escape":
337
409
  this.cancelPreselection();
338
410
  break;
411
+ case "Tab":
412
+ this._tabPressed = true;
413
+ this.controlListWithOnlyOne();
414
+ break;
339
415
  }
340
416
  event.stopPropagation();
341
417
  }
@@ -343,13 +419,17 @@ let EzComboBox = class {
343
419
  this.cancelPreselection();
344
420
  }
345
421
  render() {
346
- return (index.h(index.Host, null, index.h("ez-text-input", { class: this.suppressSearch ? "suppressed-search-input" : "", ref: elem => this._inputElement = elem, enabled: this.enabled && !this.suppressSearch, onInput: evt => this.onTextInputChangeHandler(evt), onClick: () => this.onTextInputClickHandler(), onFocusout: () => this.onTextInputFocusOutHandler(), onKeyDown: event => this.keyDownHandler(event), label: this.label, value: this.getText(), canShowError: this.canShowError, errorMessage: this.errorMessage, mode: this.mode, slaveMode: true }, index.h("button", { class: "btn", slot: this.searchMode ? "leftIcon" : "rightIcon", disabled: !this.enabled, tabindex: -1, onClick: () => this.handlerIconClick() }, index.h("ez-icon", { slot: "icon", "icon-name": this.searchMode ? "search" : "chevron-down" }))), index.h("section", { class: "list-container", ref: elem => this._listContainer = elem }, index.h("div", { class: "list-wrapper", ref: elem => this._listWrapper = elem }, index.h("div", { class: "list-options", ref: elem => this._optionsList = elem }, this._visibleOptions.length === 0
347
- && index.h("div", { class: "message" }, !this._showLoading && index.h("span", { class: "message__no-result" }, "Nenhum resultado encontrado"), this._showLoading && index.h("div", { class: "message__loading" })), this.showOptionValue
422
+ var _a;
423
+ return (index.h(index.Host, null, index.h("ez-text-input", { class: this.suppressSearch ? "suppressed-search-input" : "", ref: elem => this._textInput = elem, "data-slave-mode": "true", enabled: this.enabled && !this.suppressSearch, onInput: event => this.onTextInputChangeHandler(event), onClick: () => this.onTextInputClickHandler(), onFocusout: () => this.onTextInputFocusOutHandler(), onKeyDown: event => this.keyDownHandler(event), label: this.label, canShowError: this.canShowError, errorMessage: this.errorMessage, mode: this.mode }, index.h("button", { class: "btn", slot: this.searchMode ? "leftIcon" : "rightIcon", disabled: !this.enabled, tabindex: -1, onClick: () => this.handlerIconClick() }, index.h("ez-icon", { iconName: this.searchMode ? "search" : "chevron-down" })), this.searchMode && ((_a = this._textInput) === null || _a === void 0 ? void 0 : _a.value) && (this._criteria || this.value)
424
+ ? index.h("button", { class: "btn", slot: "rightIcon", disabled: !this.enabled, tabindex: -1, onClick: () => this.clearSearch() }, index.h("ez-icon", { iconName: "close" }))
425
+ : undefined), index.h("section", { class: "list-container", ref: elem => this._listContainer = elem }, index.h("div", { class: "list-wrapper", ref: elem => this._listWrapper = elem }, index.h("div", { class: "list-options", ref: elem => this._optionsList = elem }, this._visibleOptions.length === 0
426
+ && index.h("div", { class: "message" }, !this._showLoading && index.h("span", { class: "message__no-result" }, this._textEmptyList), this._showLoading && index.h("div", { class: "message__loading" })), this.showOptionValue
348
427
  ? index.h("span", { class: "item__value item__value--hidden", ref: elem => this._itemValueBasis = elem })
349
428
  : undefined, this._visibleOptions.length > 0 && this._visibleOptions.map((opt, index) => this.buildItem(opt, index)))))));
350
429
  }
351
430
  get el() { return index.getElement(this); }
352
431
  static get watchers() { return {
432
+ "errorMessage": ["observeErrorMessage"],
353
433
  "value": ["observeValue"]
354
434
  }; }
355
435
  };
@@ -14,6 +14,7 @@ let EzDateInput = class {
14
14
  this.ezChange = index.createEvent(this, "ezChange", 7);
15
15
  this.ezStartChange = index.createEvent(this, "ezStartChange", 7);
16
16
  this.ezCancelWaitingChange = index.createEvent(this, "ezCancelWaitingChange", 7);
17
+ this._focused = false;
17
18
  /**
18
19
  * Deixa o campo disponível ou não para uso.
19
20
  */
@@ -24,18 +25,33 @@ let EzDateInput = class {
24
25
  this.mode = "regular";
25
26
  }
26
27
  observeLabel() {
27
- this._textInput.label = this.label;
28
+ if (this._textInput) {
29
+ this._textInput.label = this.label;
30
+ }
28
31
  }
29
32
  observeErrorMessage() {
33
+ var _a;
30
34
  if (this._textInput) {
31
35
  this._textInput.errorMessage = this.errorMessage;
36
+ if (!((_a = this.errorMessage) === null || _a === void 0 ? void 0 : _a.trim())) {
37
+ this.setInputValue();
38
+ }
32
39
  }
33
40
  }
34
41
  observeValue(newValue, oldValue) {
35
- if (newValue != oldValue) {
36
- if (this._textInput) {
37
- this.errorMessage = "";
38
- this._textInput.value = this.getTextValue(this.value);
42
+ if (this._textInput && newValue != oldValue) {
43
+ const newValueValidated = this.validateValue(newValue);
44
+ const oldValueValidated = this.validateValue(oldValue);
45
+ if ((newValueValidated === null || newValueValidated === void 0 ? void 0 : newValueValidated.getTime()) !== (oldValueValidated === null || oldValueValidated === void 0 ? void 0 : oldValueValidated.getTime())) {
46
+ const textValue = this.getTextValue(newValueValidated) || '';
47
+ const parsedDate = core.DateUtils.strToDate(textValue);
48
+ if ((parsedDate || !this._focused) && (this._textInput.value || '') !== textValue) {
49
+ this._textInput.value = textValue;
50
+ this._focused = false;
51
+ this.errorMessage = "";
52
+ }
53
+ const valueEmitted = newValueValidated === null ? undefined : newValueValidated;
54
+ this.ezChange.emit(valueEmitted);
39
55
  }
40
56
  }
41
57
  }
@@ -51,59 +67,89 @@ let EzDateInput = class {
51
67
  async setBlur() {
52
68
  this._textInput.setBlur();
53
69
  }
70
+ /**
71
+ * Retorna informando se o campo está inválido (true | false)
72
+ */
73
+ async isInvalid() {
74
+ return typeof this.errorMessage === "string" && this.errorMessage.trim() !== "";
75
+ }
54
76
  changeValue(newValue) {
55
- var _a;
56
- newValue = newValue instanceof Date ? core.DateUtils.clearTime(newValue) : undefined;
57
- this.value = this.value instanceof Date ? core.DateUtils.clearTime(this.value) : undefined;
58
- this._textInput.errorMessage = "";
59
- if ((newValue === null || newValue === void 0 ? void 0 : newValue.toString()) !== ((_a = this.value) === null || _a === void 0 ? void 0 : _a.toString())) {
60
- this.value = newValue;
61
- this.ezChange.emit(this.value);
77
+ const currentValue = this.validateValue(this.value);
78
+ const newValueValidated = this.validateValue(newValue);
79
+ if ((currentValue === null || currentValue === void 0 ? void 0 : currentValue.getTime()) !== (newValueValidated === null || newValueValidated === void 0 ? void 0 : newValueValidated.getTime())) {
80
+ this.value = newValueValidated;
62
81
  }
63
82
  }
64
83
  showCalendar() {
65
- this.parseDate();
84
+ this.handleBlur();
66
85
  this._calendar.value = this.value;
67
86
  //FIXME: Provavelmente isso fará com que o popup abra em uma
68
87
  //posição errada no futuro. Preferi fazer simples no começo,
69
88
  //porque não quis onerar o text input com essa funcionalidade...
70
- const top = this._textInput.errorMessage || this.mode == "slim" ? 0 : -19;
89
+ const top = this.errorMessage || this.mode === "slim" ? 0 : -19;
71
90
  this._calendar.fitVertical(top, this._elem.clientHeight);
72
91
  }
73
92
  hideCalendar() {
74
93
  this.changeValue(this._calendar.value);
75
94
  this._calendar.hide();
76
95
  }
77
- parseDate() {
96
+ handleBlur() {
78
97
  const strValue = this._textInput.value;
79
- const parsedDate = core.DateUtils.strToDate(strValue);
80
- if (parsedDate || !strValue) {
81
- if (this.value === parsedDate) {
82
- this.changeValue(this.value);
98
+ const newValue = core.DateUtils.strToDate(strValue);
99
+ if (newValue || !strValue) {
100
+ this.errorMessage = "";
101
+ const currentValue = this.validateValue(this.value);
102
+ const newValueValidated = this.validateValue(newValue);
103
+ if ((currentValue === null || currentValue === void 0 ? void 0 : currentValue.getTime()) === (newValueValidated === null || newValueValidated === void 0 ? void 0 : newValueValidated.getTime())) {
104
+ if (newValueValidated) {
105
+ this._textInput.value = this.getTextValue(newValueValidated) || '';
106
+ this._focused = false;
107
+ }
108
+ this.ezCancelWaitingChange.emit();
83
109
  }
84
110
  else {
85
- this.changeValue(parsedDate);
111
+ this.changeValue(newValueValidated);
86
112
  }
87
113
  }
88
114
  else {
115
+ this.changeValue(undefined);
89
116
  this.ezCancelWaitingChange.emit();
90
- this._textInput.errorMessage = "O valor digitado não é uma data válida";
117
+ this.errorMessage = "O valor digitado não é uma data válida";
91
118
  }
92
119
  }
93
120
  getTextValue(d) {
94
121
  return d ? new Intl.DateTimeFormat("pt-BR").format(d) : undefined;
95
122
  }
96
- startChange() {
97
- this.ezStartChange.emit({ waitmessage: "", blocking: false });
123
+ handleInput() {
124
+ const strValue = this._textInput.value;
125
+ const newValue = core.DateUtils.strToDate(strValue);
126
+ const currentValue = this.validateValue(this.value);
127
+ const newValueValidated = this.validateValue(newValue);
128
+ if ((currentValue === null || currentValue === void 0 ? void 0 : currentValue.getTime()) !== (newValueValidated === null || newValueValidated === void 0 ? void 0 : newValueValidated.getTime())) {
129
+ this._focused = true;
130
+ this.ezStartChange.emit({ waitmessage: "", blocking: false });
131
+ }
132
+ }
133
+ validateValue(value) {
134
+ return value instanceof Date && !isNaN(value.valueOf())
135
+ ? core.DateUtils.clearTime(value)
136
+ : undefined;
137
+ }
138
+ setInputValue() {
139
+ const textValue = this.getTextValue(this.value) || '';
140
+ if ((this._textInput.value || '') !== textValue) {
141
+ this._textInput.value = textValue;
142
+ }
98
143
  }
99
144
  componentDidLoad() {
100
145
  CSSVarsUtils.CSSVarsUtils.applyVarsTextInput(this._elem, this._textInput);
146
+ this.setInputValue();
101
147
  }
102
148
  render() {
103
- return (index.h(index.Host, null, index.h("ez-text-input", { ref: elem => this._textInput = elem, onBlur: () => this.parseDate(), onKeyDown: event => {
149
+ return (index.h(index.Host, null, index.h("ez-text-input", { ref: elem => this._textInput = elem, "data-slave-mode": "true", onKeyDown: event => {
104
150
  if (event.key === "H" || event.key === "h")
105
151
  this.changeValue(new Date());
106
- }, label: this.label, value: this.getTextValue(this.value), onInput: () => this.startChange(), restrict: "0123456789/", enabled: this.enabled, errorMessage: this.errorMessage, mode: this.mode, slaveMode: true }, index.h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-cal", onClick: () => this.showCalendar(), slot: "leftIcon" })), index.h("ez-calendar", { onEzChange: (event) => { this.hideCalendar(); event.stopPropagation(); }, floating: true, ref: elem => this._calendar = elem })));
152
+ }, label: this.label, onBlur: () => this.handleBlur(), onInput: () => this.handleInput(), restrict: "0123456789/", enabled: this.enabled, errorMessage: this.errorMessage, mode: this.mode }, index.h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-cal", onClick: () => this.showCalendar(), slot: "leftIcon" })), index.h("ez-calendar", { onEzChange: (event) => { this.hideCalendar(); event.stopPropagation(); }, floating: true, ref: elem => this._calendar = elem })));
107
153
  }
108
154
  get _elem() { return index.getElement(this); }
109
155
  static get watchers() { return {
@@ -14,6 +14,7 @@ let EzDateTimeInput = class {
14
14
  this.ezChange = index.createEvent(this, "ezChange", 7);
15
15
  this.ezStartChange = index.createEvent(this, "ezStartChange", 7);
16
16
  this.ezCancelWaitingChange = index.createEvent(this, "ezCancelWaitingChange", 7);
17
+ this._focused = false;
17
18
  /**
18
19
  * Deixa o campo disponível ou não para uso.
19
20
  */
@@ -28,14 +29,34 @@ let EzDateTimeInput = class {
28
29
  this.mode = "regular";
29
30
  }
30
31
  observeLabel() {
31
- this._textInput.label = this.label;
32
+ if (this._textInput) {
33
+ this._textInput.label = this.label;
34
+ }
32
35
  }
33
36
  observeErrorMessage() {
34
- this._textInput.errorMessage = this.errorMessage;
35
- }
36
- observeValue() {
37
+ var _a;
37
38
  if (this._textInput) {
38
- this._textInput.value = this.getTextValue(this.value);
39
+ this._textInput.errorMessage = this.errorMessage;
40
+ if (!((_a = this.errorMessage) === null || _a === void 0 ? void 0 : _a.trim())) {
41
+ this.setInputValue();
42
+ }
43
+ }
44
+ }
45
+ observeValue(newValue, oldValue) {
46
+ if (this._textInput && newValue != oldValue) {
47
+ const newValueValidated = this.validateValue(newValue);
48
+ const oldValueValidated = this.validateValue(oldValue);
49
+ if ((newValueValidated === null || newValueValidated === void 0 ? void 0 : newValueValidated.getTime()) !== (oldValueValidated === null || oldValueValidated === void 0 ? void 0 : oldValueValidated.getTime())) {
50
+ const textValue = this.getTextValue(newValueValidated) || '';
51
+ const parsedDate = this.getParsedDateTime(textValue);
52
+ if ((parsedDate || !this._focused) && (this._textInput.value || '') !== textValue) {
53
+ this._textInput.value = textValue;
54
+ this._focused = false;
55
+ this.errorMessage = "";
56
+ }
57
+ const valueEmitted = newValueValidated === null ? undefined : newValueValidated;
58
+ this.ezChange.emit(valueEmitted);
59
+ }
39
60
  }
40
61
  }
41
62
  /**
@@ -50,30 +71,36 @@ let EzDateTimeInput = class {
50
71
  async setBlur() {
51
72
  this._textInput.setBlur();
52
73
  }
53
- onChangeKeyDown(ev) {
74
+ /**
75
+ * Retorna informando se o campo está inválido (true | false)
76
+ */
77
+ async isInvalid() {
78
+ return typeof this.errorMessage === "string" && this.errorMessage.trim() !== "";
79
+ }
80
+ handleKeyDown(event) {
54
81
  const input = this._textInput.shadowRoot.querySelector('input');
55
- if (ev.key === "H" || ev.key === "h") {
82
+ if (event.key === "H" || event.key === "h") {
56
83
  this.changeValue(new Date());
57
84
  }
58
- else if (ev.shiftKey && ev.key === "Tab") {
85
+ else if (event.shiftKey && event.key === "Tab") {
59
86
  if (input.selectionStart > 0) {
60
87
  let selectIni = input.value.lastIndexOf(" ", input.selectionStart);
61
88
  if (selectIni !== -1) {
62
89
  input.setSelectionRange(0, selectIni);
63
- ev.preventDefault();
90
+ event.preventDefault();
64
91
  }
65
92
  }
66
93
  }
67
- else if (ev.key === "Tab") {
94
+ else if (event.key === "Tab") {
68
95
  if (input.value.length !== input.selectionEnd) {
69
96
  let selectIni = input.value.indexOf(" ", input.selectionEnd);
70
97
  selectIni = selectIni === -1 ? input.selectionEnd : selectIni + 1;
71
98
  input.setSelectionRange(selectIni, input.value.length);
72
- ev.preventDefault();
99
+ event.preventDefault();
73
100
  }
74
101
  }
75
102
  }
76
- onFocused() {
103
+ handleFocus() {
77
104
  const input = this._textInput.shadowRoot.querySelector('input');
78
105
  if (input.selectionStart !== input.selectionEnd) {
79
106
  let selectIni = input.value.indexOf(" ", input.selectionStart);
@@ -81,7 +108,7 @@ let EzDateTimeInput = class {
81
108
  input.setSelectionRange(0, selectIni);
82
109
  }
83
110
  }
84
- onClicked() {
111
+ handleClick() {
85
112
  const input = this._textInput.shadowRoot.querySelector('input');
86
113
  let selectIni = input.value.lastIndexOf(" ", input.selectionEnd);
87
114
  selectIni = selectIni === -1 ? 0 : selectIni + 1;
@@ -90,37 +117,55 @@ let EzDateTimeInput = class {
90
117
  input.setSelectionRange(selectIni, selectFin);
91
118
  }
92
119
  changeValue(newValue) {
93
- var _a;
94
- this._textInput.errorMessage = "";
95
- if ((newValue === null || newValue === void 0 ? void 0 : newValue.toString()) !== ((_a = this.value) === null || _a === void 0 ? void 0 : _a.toString())) {
96
- this.value = newValue;
97
- this.ezChange.emit(this.value);
120
+ const currentValue = this.validateValue(this.value);
121
+ const newValueValidated = this.validateValue(newValue);
122
+ if ((currentValue === null || currentValue === void 0 ? void 0 : currentValue.getTime()) !== (newValueValidated === null || newValueValidated === void 0 ? void 0 : newValueValidated.getTime())) {
123
+ this.value = newValueValidated;
98
124
  }
99
125
  }
100
126
  showCalendar() {
101
- const top = this._textInput.errorMessage || this.mode == "slim" ? 0 : -19;
127
+ const top = this.errorMessage || this.mode === "slim" ? 0 : -19;
102
128
  this._calendar.fitVertical(top, this._elem.clientHeight);
103
129
  this._calendar.style.visibility = 'inherit';
104
130
  }
105
- parseDate() {
106
- const strValue = this._textInput.value;
107
- const partsDateTime = (strValue && strValue.length > 0) ? strValue.split(" ") : [];
131
+ getParsedDateTime(strValue) {
132
+ var _a, _b;
133
+ if (strValue === void 0) {
134
+ strValue = (((_b = (_a = this._textInput) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.trim()) || "");
135
+ }
136
+ if (!strValue) {
137
+ return;
138
+ }
139
+ const partsDateTime = strValue.split(" ");
108
140
  const onlyDate = partsDateTime.length > 0 ? partsDateTime[0] : strValue;
109
141
  const onlyTime = partsDateTime[1] ? partsDateTime[1] : "";
110
142
  const parsedTime = core.TimeFormatter.prepareValue(onlyTime, this.showSeconds);
111
143
  const strDateTime = onlyDate + (parsedTime && " " + parsedTime);
112
- const parsedDate = core.DateUtils.strToDate(strDateTime);
113
- if (parsedDate || !strValue) {
114
- if (this.value === parsedDate) {
115
- this.changeValue(this.value);
144
+ return core.DateUtils.strToDate(strDateTime);
145
+ }
146
+ handleBlur() {
147
+ var _a, _b;
148
+ const strValue = ((_b = (_a = this._textInput) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.trim()) || "";
149
+ const newValue = this.getParsedDateTime();
150
+ if (newValue || !strValue) {
151
+ this.errorMessage = "";
152
+ const currentValue = this.validateValue(this.value);
153
+ const newValueValidated = this.validateValue(newValue);
154
+ if ((currentValue === null || currentValue === void 0 ? void 0 : currentValue.getTime()) === (newValueValidated === null || newValueValidated === void 0 ? void 0 : newValueValidated.getTime())) {
155
+ if (newValueValidated) {
156
+ this._textInput.value = this.getTextValue(newValueValidated) || '';
157
+ this._focused = false;
158
+ }
159
+ this.ezCancelWaitingChange.emit();
116
160
  }
117
161
  else {
118
- this.changeValue(parsedDate);
162
+ this.changeValue(newValueValidated);
119
163
  }
120
164
  }
121
165
  else {
166
+ this.changeValue(undefined);
122
167
  this.ezCancelWaitingChange.emit();
123
- this._textInput.errorMessage = "O valor digitado não é uma data válida";
168
+ this.errorMessage = "O valor digitado não é uma data válida";
124
169
  }
125
170
  }
126
171
  getTextValue(d) {
@@ -134,14 +179,32 @@ let EzDateTimeInput = class {
134
179
  };
135
180
  return d ? (new Intl.DateTimeFormat('pt-BR', this.showSeconds ? optionsSecond : options).format(d)) : undefined;
136
181
  }
137
- startChange() {
138
- this.ezStartChange.emit({ waitmessage: "", blocking: false });
182
+ validateValue(value) {
183
+ return value instanceof Date && !isNaN(value.valueOf())
184
+ ? value
185
+ : undefined;
186
+ }
187
+ handleInput() {
188
+ const newValue = this.getParsedDateTime();
189
+ const currentValue = this.validateValue(this.value);
190
+ const newValueValidated = this.validateValue(newValue);
191
+ if ((currentValue === null || currentValue === void 0 ? void 0 : currentValue.getTime()) !== (newValueValidated === null || newValueValidated === void 0 ? void 0 : newValueValidated.getTime())) {
192
+ this._focused = true;
193
+ this.ezStartChange.emit({ waitmessage: "", blocking: false });
194
+ }
195
+ }
196
+ setInputValue() {
197
+ const textValue = this.getTextValue(this.value) || '';
198
+ if ((this._textInput.value || '') !== textValue) {
199
+ this._textInput.value = textValue;
200
+ }
139
201
  }
140
202
  componentDidLoad() {
141
203
  CSSVarsUtils.CSSVarsUtils.applyVarsTextInput(this._elem, this._textInput);
204
+ this.setInputValue();
142
205
  }
143
206
  render() {
144
- return (index.h(index.Host, null, index.h("ez-text-input", { ref: elem => this._textInput = elem, onBlur: () => this.parseDate(), onKeyDown: event => { this.onChangeKeyDown(event); }, label: this.label, value: this.getTextValue(this.value), restrict: "0123456789/: ", enabled: this.enabled, errorMessage: this.errorMessage, mode: this.mode, onInput: () => this.startChange(), onFocus: () => this.onFocused(), onClick: () => this.onClicked(), slaveMode: true }, index.h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-cal", onClick: () => this.showCalendar(), slot: "leftIcon" })), index.h("ez-calendar", { onEzChange: (event) => { this.changeValue(this._calendar.value); event.stopPropagation(); }, floating: true, ref: elem => this._calendar = elem, time: true, showSeconds: this.showSeconds })));
207
+ return (index.h(index.Host, null, index.h("ez-text-input", { ref: elem => this._textInput = elem, "data-slave-mode": "true", label: this.label, restrict: "0123456789/: ", enabled: this.enabled, errorMessage: this.errorMessage, mode: this.mode, onKeyDown: event => { this.handleKeyDown(event); }, onBlur: () => this.handleBlur(), onInput: () => this.handleInput(), onFocus: () => this.handleFocus(), onClick: () => this.handleClick() }, index.h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-cal", onClick: () => this.showCalendar(), slot: "leftIcon" })), index.h("ez-calendar", { onEzChange: (event) => { this.changeValue(this._calendar.value); event.stopPropagation(); }, floating: true, ref: elem => this._calendar = elem, time: true, showSeconds: this.showSeconds })));
145
208
  }
146
209
  get _elem() { return index.getElement(this); }
147
210
  static get watchers() { return {