@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
@@ -23,6 +23,11 @@ export class EzSearch {
23
23
  */
24
24
  this.mode = "regular";
25
25
  }
26
+ observeErrorMessage() {
27
+ if (this._comboElement) {
28
+ this._comboElement.errorMessage = this.errorMessage;
29
+ }
30
+ }
26
31
  observeValue() {
27
32
  if (this._comboElement) {
28
33
  this._comboElement.value = this.value;
@@ -40,16 +45,25 @@ export class EzSearch {
40
45
  async setBlur() {
41
46
  this._comboElement.setBlur();
42
47
  }
43
- onComboChange(evt) {
44
- evt.stopPropagation();
45
- this.value = evt.detail;
46
- this.ezChange.emit(evt.detail);
48
+ /**
49
+ * Retorna informando se o campo está inválido (true | false)
50
+ */
51
+ async isInvalid() {
52
+ return typeof this.errorMessage === "string" && this.errorMessage.trim() !== "";
53
+ }
54
+ onComboChange(event) {
55
+ event.stopPropagation();
56
+ this.value = event.detail;
57
+ this.ezChange.emit(event.detail);
58
+ if (this.errorMessage !== this._comboElement.errorMessage) {
59
+ this.errorMessage = this._comboElement.errorMessage;
60
+ }
47
61
  }
48
62
  componentDidLoad() {
49
63
  CSSVarsUtils.applyVarsTextInput(this._elem, this._comboElement);
50
64
  }
51
65
  render() {
52
- return (h("ez-combo-box", { ref: elem => this._comboElement = elem, value: this.value, label: this.label, enabled: this.enabled, errorMessage: this.errorMessage, optionLoader: this.optionLoader, searchMode: true, onEzChange: evt => this.onComboChange(evt), showSelectedValue: this.showSelectedValue, showOptionValue: this.showOptionValue, suppressEmptyOption: this.suppressEmptyOption, mode: this.mode }));
66
+ return (h("ez-combo-box", { ref: elem => this._comboElement = elem, value: this.value, label: this.label, enabled: this.enabled, errorMessage: this.errorMessage, optionLoader: this.optionLoader, searchMode: true, onEzChange: event => this.onComboChange(event), showSelectedValue: this.showSelectedValue, showOptionValue: this.showOptionValue, suppressEmptyOption: this.suppressEmptyOption, mode: this.mode }));
53
67
  }
54
68
  ;
55
69
  static get is() { return "ez-search"; }
@@ -295,10 +309,29 @@ export class EzSearch {
295
309
  "text": "Remove o foco no componente de pesquisa",
296
310
  "tags": []
297
311
  }
312
+ },
313
+ "isInvalid": {
314
+ "complexType": {
315
+ "signature": "() => Promise<boolean>",
316
+ "parameters": [],
317
+ "references": {
318
+ "Promise": {
319
+ "location": "global"
320
+ }
321
+ },
322
+ "return": "Promise<boolean>"
323
+ },
324
+ "docs": {
325
+ "text": "Retorna informando se o campo est\u00E1 inv\u00E1lido (true | false)",
326
+ "tags": []
327
+ }
298
328
  }
299
329
  }; }
300
330
  static get elementRef() { return "_elem"; }
301
331
  static get watchers() { return [{
332
+ "propName": "errorMessage",
333
+ "methodName": "observeErrorMessage"
334
+ }, {
302
335
  "propName": "value",
303
336
  "methodName": "observeValue"
304
337
  }]; }
@@ -67,7 +67,7 @@ textarea {
67
67
  resize: none;
68
68
  margin-top: calc(var(--space--medium, 12px) + 4px);
69
69
  width: 100%;
70
- font-weight: var(--text-weight--large, 600);
70
+ font-weight: var(--text-area--font-weight);
71
71
  font-family: var(--text-area--font-family);
72
72
  font-size: var(--text-area--font-size);
73
73
  color: var(--text-area--color);
@@ -73,6 +73,12 @@ export class EzTextArea {
73
73
  async setBlur() {
74
74
  this._inputElem.blur();
75
75
  }
76
+ /**
77
+ * Retorna informando se o campo está inválido (true | false)
78
+ */
79
+ async isInvalid() {
80
+ return typeof this.errorMessage === "string" && this.errorMessage.trim() !== "";
81
+ }
76
82
  //---------------------------------------------
77
83
  // Private methods
78
84
  //---------------------------------------------
@@ -134,7 +140,7 @@ export class EzTextArea {
134
140
  this.label && this.mode != "slim" ?
135
141
  h("label", { ref: (el) => this._labelElem = el, class: this.enabled ? "textarea__label" : "textarea__label textarea__label--disabled", onClick: () => this._inputElem.focus(), title: this.label }, this.label)
136
142
  : null,
137
- h("textarea", { onFocus: () => this.handleFocus(), ref: (el) => this._inputElem = el, value: this.value, disabled: !this.enabled, class: this.mode == "slim" ? "textarea--slim" : "", placeholder: this.mode == "slim" && this.label ? this.label : "", onInput: () => { this.handleChange(); }, onFocusout: () => { this.handleFocusout(); }, onKeyDown: event => event.stopPropagation(), rows: this.rows })),
143
+ h("textarea", { onFocus: () => this.handleFocus(), ref: (el) => this._inputElem = el, value: this.value, disabled: !this.enabled, class: this.mode === "slim" ? "textarea--slim" : "", placeholder: this.mode === "slim" && this.label ? this.label : "", onInput: () => { this.handleChange(); }, onFocusout: () => { this.handleFocusout(); }, onKeyDown: event => event.stopPropagation(), rows: this.rows })),
138
144
  this.canShowError && this.mode != "slim" &&
139
145
  h("span", { class: "message-box", ref: (el) => this._messageBoxElem = el, title: this.errorMessage }, this.errorMessage)));
140
146
  }
@@ -336,6 +342,22 @@ export class EzTextArea {
336
342
  "text": "Remove o foco no componente de input",
337
343
  "tags": []
338
344
  }
345
+ },
346
+ "isInvalid": {
347
+ "complexType": {
348
+ "signature": "() => Promise<boolean>",
349
+ "parameters": [],
350
+ "references": {
351
+ "Promise": {
352
+ "location": "global"
353
+ }
354
+ },
355
+ "return": "Promise<boolean>"
356
+ },
357
+ "docs": {
358
+ "text": "Retorna informando se o campo est\u00E1 inv\u00E1lido (true | false)",
359
+ "tags": []
360
+ }
339
361
  }
340
362
  }; }
341
363
  static get elementRef() { return "_hostElement"; }
@@ -19,7 +19,7 @@
19
19
  /*@doc Define o peso da fonte do label do componente.*/
20
20
  --ez-text-input--font-weight: var(--text-weight--medium, 400);
21
21
  /*@doc Define a cor da fonte do input e label do componente.*/
22
- --ez-text-input--color: var(--title--primary, #000);
22
+ --ez-text-input--color: var(--title--primary, #2B3A54);
23
23
 
24
24
  /* input */
25
25
  /*@doc Define a cor de fundo do input.*/
@@ -73,7 +73,6 @@ input {
73
73
  width: 100%;
74
74
  box-sizing: border-box;
75
75
  padding: var(--space--medium, 6px);
76
- font-weight: var(--text-weight--large, 600);
77
76
 
78
77
  /*public*/
79
78
  height: var(--ez-text-input--height);
@@ -84,6 +83,7 @@ input {
84
83
  border-color: var(--ez-text-input__input--border-color);
85
84
  background-color: var(--ez-text-input__input--background-color);
86
85
  color: var(--ez-text-input--color);
86
+ font-weight: var(--ez-text-input--font-weight);
87
87
  }
88
88
 
89
89
  input:disabled {
@@ -14,23 +14,20 @@ export class EzTextInput {
14
14
  * Define o modo do tamanho do campo; opções: slim e regular.
15
15
  */
16
16
  this.mode = "regular";
17
- /**
18
- * Define se o controle de change do value será controlado por um componente pai.
19
- */
20
- this.slaveMode = false;
21
17
  }
22
18
  observeErrorMessage() {
23
- var _a, _b;
24
19
  if (this._inputElem) {
25
- const hasError = typeof this.errorMessage === "string" && this.errorMessage !== "";
26
- if (hasError) {
27
- this._inputElem.classList.add("hasError");
28
- (_a = this._messageBoxElem) === null || _a === void 0 ? void 0 : _a.classList.add("hasError");
29
- }
30
- else {
31
- this._inputElem.classList.remove("hasError");
32
- (_b = this._messageBoxElem) === null || _b === void 0 ? void 0 : _b.classList.remove("hasError");
33
- }
20
+ this.isInvalid().then((hasError) => {
21
+ var _a, _b;
22
+ if (hasError) {
23
+ this._inputElem.classList.add("hasError");
24
+ (_a = this._messageBoxElem) === null || _a === void 0 ? void 0 : _a.classList.add("hasError");
25
+ }
26
+ else {
27
+ this._inputElem.classList.remove("hasError");
28
+ (_b = this._messageBoxElem) === null || _b === void 0 ? void 0 : _b.classList.remove("hasError");
29
+ }
30
+ });
34
31
  }
35
32
  }
36
33
  observeMask() {
@@ -49,14 +46,16 @@ export class EzTextInput {
49
46
  this._inputElem.value = this.value || "";
50
47
  this.handleChange();
51
48
  this.adjustFloatingLabel();
52
- if (this.slaveMode) {
53
- return;
49
+ if (!this.isSlaveMode()) {
50
+ this.errorMessage = "";
51
+ this.ezChange.emit(this.value);
54
52
  }
55
- this.errorMessage = "";
56
- this.ezChange.emit(this.value);
57
53
  }
58
54
  }
59
55
  }
56
+ //---------------------------------------------
57
+ // Private methods
58
+ //---------------------------------------------
60
59
  adjustFloatingLabel() {
61
60
  if (this.label && this._labelElem) {
62
61
  if (this._inputElem && !this._inputElem.classList.contains("input--with--label")) {
@@ -79,6 +78,15 @@ export class EzTextInput {
79
78
  isFocused() {
80
79
  return this._hostElement.shadowRoot.activeElement !== null;
81
80
  }
81
+ isSlaveMode() {
82
+ var _a, _b;
83
+ return ((_b = (_a = this._hostElement) === null || _a === void 0 ? void 0 : _a.dataset) === null || _b === void 0 ? void 0 : _b.slaveMode) === "true";
84
+ }
85
+ adjustColorContentSlot(color = "") {
86
+ if (this._contentLeftSlot) {
87
+ this._contentLeftSlot.style.color = color;
88
+ }
89
+ }
82
90
  //---------------------------------------------
83
91
  // Public methods
84
92
  //---------------------------------------------
@@ -94,6 +102,12 @@ export class EzTextInput {
94
102
  async setBlur() {
95
103
  this._inputElem.blur();
96
104
  }
105
+ /**
106
+ * Retorna informando se o campo está inválido (true | false)
107
+ */
108
+ async isInvalid() {
109
+ return typeof this.errorMessage === "string" && this.errorMessage.trim() !== "";
110
+ }
97
111
  //---------------------------------------------
98
112
  // Event handlers
99
113
  //---------------------------------------------
@@ -109,6 +123,7 @@ export class EzTextInput {
109
123
  }
110
124
  this.controlChangeValue();
111
125
  this.adjustFloatingLabel();
126
+ this.adjustColorContentSlot();
112
127
  }
113
128
  isValidValue(value) {
114
129
  if (this.restrict) {
@@ -117,7 +132,7 @@ export class EzTextInput {
117
132
  return true;
118
133
  }
119
134
  controlChangeValue() {
120
- if ((this.value || '') !== this._inputElem.value) {
135
+ if (this._inputElem && (this.value || '') !== this._inputElem.value) {
121
136
  this.value = this._inputElem.value;
122
137
  }
123
138
  }
@@ -153,6 +168,7 @@ export class EzTextInput {
153
168
  if (this._labelElem) {
154
169
  this._labelElem.classList.add("input__label--left");
155
170
  }
171
+ this._contentLeftSlot = content;
156
172
  }
157
173
  else if (slot.name == "rightIcon") {
158
174
  content.style.right = "0px";
@@ -169,6 +185,7 @@ export class EzTextInput {
169
185
  if (this.label && this._labelElem && !this._labelElem.classList.contains("input__label--floated")) {
170
186
  this._labelElem.classList.add("input__label--floated");
171
187
  }
188
+ this.adjustColorContentSlot("var(--ez-text-input__input--focus--border-color)");
172
189
  }
173
190
  //---------------------------------------------
174
191
  // Lifecycle web component
@@ -201,7 +218,7 @@ export class EzTextInput {
201
218
  this.label && this.mode != "slim" ?
202
219
  h("label", { ref: (el) => this._labelElem = el, class: this.enabled ? "input__label" : "input__label input__label--disabled", onClick: () => this._inputElem.focus(), title: this.label }, this.label)
203
220
  : null,
204
- h("input", { onFocus: () => this.doFocus(), ref: (el) => this._inputElem = el, type: "text", class: this.mode == "slim" ? "input--slim" : "", placeholder: this.mode == "slim" && this.label ? this.label : "", value: this.value, disabled: !this.enabled, onInput: () => { this.handleChange(); }, onFocusout: () => { this.handleFocusout(); } }),
221
+ h("input", { onFocus: () => this.doFocus(), ref: (el) => this._inputElem = el, type: "text", class: this.mode === "slim" ? "input--slim" : "", placeholder: this.mode === "slim" && this.label ? this.label : "", value: this.value, disabled: !this.enabled, onInput: () => { this.handleChange(); }, onFocusout: () => { this.handleFocusout(); } }),
205
222
  h("slot", { name: "rightIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } }),
206
223
  this.canShowError && this.mode != "slim" &&
207
224
  h("span", { class: "message-box", ref: (el) => this._messageBoxElem = el, title: this.errorMessage }, this.errorMessage)));
@@ -370,24 +387,6 @@ export class EzTextInput {
370
387
  "attribute": "mode",
371
388
  "reflect": true,
372
389
  "defaultValue": "\"regular\""
373
- },
374
- "slaveMode": {
375
- "type": "boolean",
376
- "mutable": false,
377
- "complexType": {
378
- "original": "boolean",
379
- "resolved": "boolean",
380
- "references": {}
381
- },
382
- "required": false,
383
- "optional": false,
384
- "docs": {
385
- "tags": [],
386
- "text": "Define se o controle de change do value ser\u00E1 controlado por um componente pai."
387
- },
388
- "attribute": "slave-mode",
389
- "reflect": true,
390
- "defaultValue": "false"
391
390
  }
392
391
  }; }
393
392
  static get events() { return [{
@@ -438,6 +437,22 @@ export class EzTextInput {
438
437
  "text": "Remove o foco no componente de input",
439
438
  "tags": []
440
439
  }
440
+ },
441
+ "isInvalid": {
442
+ "complexType": {
443
+ "signature": "() => Promise<boolean>",
444
+ "parameters": [],
445
+ "references": {
446
+ "Promise": {
447
+ "location": "global"
448
+ }
449
+ },
450
+ "return": "Promise<boolean>"
451
+ },
452
+ "docs": {
453
+ "text": "Retorna informando se o campo est\u00E1 inv\u00E1lido (true | false)",
454
+ "tags": []
455
+ }
441
456
  }
442
457
  }; }
443
458
  static get elementRef() { return "_hostElement"; }
@@ -8,7 +8,7 @@ export class EzTimeInput {
8
8
  */
9
9
  this.enabled = true;
10
10
  /**
11
- * Define se o componente irá ou não considerar os segundos
11
+ * Define se o componente irá ou não considerar os segundos.
12
12
  */
13
13
  this.showSeconds = false;
14
14
  /**
@@ -16,6 +16,18 @@ export class EzTimeInput {
16
16
  */
17
17
  this.mode = "regular";
18
18
  }
19
+ observeErrorMessage() {
20
+ var _a;
21
+ if (this._textInput) {
22
+ this._textInput.errorMessage = this.errorMessage;
23
+ if (!((_a = this.errorMessage) === null || _a === void 0 ? void 0 : _a.trim())) {
24
+ this.prepareValue(this._viewValue);
25
+ if ((this._textInput.value || '') !== this._viewValue) {
26
+ this._textInput.value = this._viewValue;
27
+ }
28
+ }
29
+ }
30
+ }
19
31
  observeShowSeconds() {
20
32
  if (this.showSeconds) {
21
33
  this.prepareMask("##:##:##");
@@ -24,9 +36,23 @@ export class EzTimeInput {
24
36
  this.prepareMask("##:##");
25
37
  }
26
38
  }
27
- observeValue() {
28
- if (isNaN(this.value)) {
29
- this.value = undefined;
39
+ observeValue(newValue, oldValue) {
40
+ if (this._textInput && newValue != oldValue) {
41
+ let newValueValidated = this.validateValue(newValue);
42
+ const oldValueValidated = this.validateValue(oldValue);
43
+ if (newValueValidated != oldValueValidated) {
44
+ this._viewValue = newValueValidated == undefined ? "" : newValueValidated.toString();
45
+ this.prepareValue(this._viewValue);
46
+ if (this._viewValue && !TimeFormatter.validateTime(this._viewValue, this.showSeconds)) {
47
+ this.setError("Favor inserir um horário válido.");
48
+ newValueValidated = undefined;
49
+ }
50
+ else {
51
+ this.setError("");
52
+ }
53
+ const valueEmitted = newValueValidated === null ? undefined : newValueValidated;
54
+ this.ezChange.emit(valueEmitted);
55
+ }
30
56
  }
31
57
  }
32
58
  //---------------------------------------------
@@ -40,76 +66,84 @@ export class EzTimeInput {
40
66
  this._maskFormatter.mask = mask;
41
67
  }
42
68
  }
69
+ validateValue(value) {
70
+ return isNaN(value) || value === undefined ? null : value;
71
+ }
72
+ setError(msg) {
73
+ this.errorMessage = msg;
74
+ if (this._textInput && (msg === null || msg === void 0 ? void 0 : msg.trim())) {
75
+ this.ezCancelWaitingChange.emit();
76
+ }
77
+ }
43
78
  //---------------------------------------------
44
79
  // Public methods
45
80
  //---------------------------------------------
81
+ getViewValue() {
82
+ return this._viewValue;
83
+ }
84
+ prepareValue(value) {
85
+ try {
86
+ this._viewValue = TimeFormatter.prepareValue(value, this.showSeconds);
87
+ if (this._textInput && this._textInput.value !== this._viewValue) {
88
+ this._textInput.value = this._viewValue;
89
+ }
90
+ }
91
+ catch (e) {
92
+ this.setError(e.message);
93
+ }
94
+ }
46
95
  /**
47
96
  * Faz o foco no componente de input
48
97
  */
49
98
  async setFocus() {
50
- this._inputElem.setFocus();
99
+ this._textInput.setFocus();
51
100
  }
52
101
  /**
53
102
  * Remove o foco no componente de input
54
103
  */
55
104
  async setBlur() {
56
- this._inputElem.setBlur();
105
+ this._textInput.setBlur();
106
+ }
107
+ /**
108
+ * Retorna informando se o campo está inválido (true | false)
109
+ */
110
+ async isInvalid() {
111
+ return typeof this.errorMessage === "string" && this.errorMessage.trim() !== "";
57
112
  }
58
113
  //---------------------------------------------
59
114
  // Event handlers
60
115
  //---------------------------------------------
61
- handleFocusout() {
62
- this.errorMessage = "";
63
- this.prepareValue(this.viewValue);
64
- if (this.viewValue && !TimeFormatter.validateTime(this.viewValue, this.showSeconds)) {
65
- this._oldViewValue = this.viewValue;
66
- this.ezCancelWaitingChange.emit();
67
- this.errorMessage = "Favor inserir um horário válido.";
68
- }
69
- else {
70
- if (this.viewValue === this._oldViewValue) {
71
- this.ezCancelWaitingChange.emit();
72
- return;
73
- }
74
- this._oldViewValue = this.viewValue;
75
- if (this.viewValue === "00:00" && this.value == undefined) {
76
- this.value = 0;
77
- }
78
- this.ezChange.emit(this.value);
116
+ handleBlur() {
117
+ if (this._textInput) {
118
+ this._viewValue = this._textInput.value;
119
+ this.prepareValue(this._viewValue);
120
+ this.value = NumberUtils.stringToNumber(this._viewValue.replace(/\D/g, ""));
79
121
  }
80
122
  }
81
- prepareValue(value) {
82
- try {
83
- this.viewValue = TimeFormatter.prepareValue(value, this.showSeconds);
123
+ handleInput() {
124
+ const parsedNumber = NumberUtils.stringToNumber(this._textInput.value.replace(/\D/g, ""));
125
+ if (parsedNumber !== this.value) {
126
+ this.ezStartChange.emit({ waitmessage: "", blocking: false });
84
127
  }
85
- catch (e) {
86
- this.errorMessage = e.message;
87
- }
88
- }
89
- handleChange() {
90
- this.ezStartChange.emit({ waitmessage: "", blocking: false });
91
- this.viewValue = this._inputElem.value;
92
- this.value = NumberUtils.stringToNumber(this.viewValue.replace(/\D/g, ""));
93
128
  }
94
129
  //---------------------------------------------
95
130
  // Lifecycle web component
96
131
  //---------------------------------------------
97
132
  componentDidLoad() {
98
- this.observeValue();
99
- CSSVarsUtils.applyVarsTextInput(this._elem, this._inputElem);
133
+ CSSVarsUtils.applyVarsTextInput(this._elem, this._textInput);
100
134
  }
101
135
  componentWillLoad() {
102
136
  this.observeShowSeconds();
103
137
  if (this.value) {
104
138
  this.prepareValue(this.value.toString());
105
139
  }
106
- else if (this.viewValue) {
107
- this.prepareValue(this.viewValue);
140
+ else if (this._viewValue) {
141
+ this.prepareValue(this._viewValue);
108
142
  }
109
143
  }
110
144
  render() {
111
145
  return (h(Host, null,
112
- h("ez-text-input", { ref: (el) => this._inputElem = el, value: this.viewValue, enabled: this.enabled, label: this.label, restrict: "0123456789:", onInput: () => { this.handleChange(); }, onFocusout: () => { this.handleFocusout(); }, errorMessage: this.errorMessage, mode: this.mode, slaveMode: true },
146
+ h("ez-text-input", { ref: (el) => this._textInput = el, "data-slave-mode": "true", value: this._viewValue, enabled: this.enabled, label: this.label, restrict: "0123456789:", onBlur: () => this.handleBlur(), onInput: () => this.handleInput(), errorMessage: this.errorMessage, mode: this.mode },
113
147
  h("ez-icon", { slot: "leftIcon", iconName: "timer-outline" }))));
114
148
  }
115
149
  static get is() { return "ez-time-input"; }
@@ -139,23 +173,6 @@ export class EzTimeInput {
139
173
  "attribute": "label",
140
174
  "reflect": true
141
175
  },
142
- "viewValue": {
143
- "type": "string",
144
- "mutable": true,
145
- "complexType": {
146
- "original": "string",
147
- "resolved": "string",
148
- "references": {}
149
- },
150
- "required": false,
151
- "optional": false,
152
- "docs": {
153
- "tags": [],
154
- "text": "Valor digitado pelo usu\u00E1rio. Este valor \u00E9 o que fica vis\u00EDvel no campo."
155
- },
156
- "attribute": "view-value",
157
- "reflect": true
158
- },
159
176
  "value": {
160
177
  "type": "number",
161
178
  "mutable": true,
@@ -203,7 +220,7 @@ export class EzTimeInput {
203
220
  "optional": false,
204
221
  "docs": {
205
222
  "tags": [],
206
- "text": "Quando h\u00E1 um problema de valida\u00E7\u00E3o, serve como orienta\u00E7\u00E3o ao usu\u00E1rio"
223
+ "text": "Quando h\u00E1 um problema de valida\u00E7\u00E3o, serve como orienta\u00E7\u00E3o ao usu\u00E1rio."
207
224
  },
208
225
  "attribute": "error-message",
209
226
  "reflect": true
@@ -220,7 +237,7 @@ export class EzTimeInput {
220
237
  "optional": false,
221
238
  "docs": {
222
239
  "tags": [],
223
- "text": "Define se o componente ir\u00E1 ou n\u00E3o considerar os segundos"
240
+ "text": "Define se o componente ir\u00E1 ou n\u00E3o considerar os segundos."
224
241
  },
225
242
  "attribute": "show-seconds",
226
243
  "reflect": true,
@@ -328,10 +345,29 @@ export class EzTimeInput {
328
345
  "text": "Remove o foco no componente de input",
329
346
  "tags": []
330
347
  }
348
+ },
349
+ "isInvalid": {
350
+ "complexType": {
351
+ "signature": "() => Promise<boolean>",
352
+ "parameters": [],
353
+ "references": {
354
+ "Promise": {
355
+ "location": "global"
356
+ }
357
+ },
358
+ "return": "Promise<boolean>"
359
+ },
360
+ "docs": {
361
+ "text": "Retorna informando se o campo est\u00E1 inv\u00E1lido (true | false)",
362
+ "tags": []
363
+ }
331
364
  }
332
365
  }; }
333
366
  static get elementRef() { return "_elem"; }
334
367
  static get watchers() { return [{
368
+ "propName": "errorMessage",
369
+ "methodName": "observeErrorMessage"
370
+ }, {
335
371
  "propName": "showSeconds",
336
372
  "methodName": "observeShowSeconds"
337
373
  }, {