@sankhyalabs/ezui 1.1.8 → 1.1.9

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 (141) hide show
  1. package/README.md +72 -72
  2. package/dist/cjs/{DataUnit-28b290cb.js → DataUnit-9a4a35ca.js} +415 -371
  3. package/dist/cjs/ez-action-chip.cjs.entry.js +41 -41
  4. package/dist/cjs/ez-button_14.cjs.entry.js +1911 -1911
  5. package/dist/cjs/ez-label-chip.cjs.entry.js +120 -120
  6. package/dist/cjs/ez-modal.cjs.entry.js +104 -104
  7. package/dist/cjs/ez-number-input.cjs.entry.js +236 -236
  8. package/dist/cjs/ez-time-input.cjs.entry.js +168 -168
  9. package/dist/cjs/form-metadata.cjs.entry.js +65 -65
  10. package/dist/collection/components/ez-action-chip/ez-action-chip.css +82 -82
  11. package/dist/collection/components/ez-action-chip/ez-action-chip.js +109 -109
  12. package/dist/collection/components/ez-button/ez-button.css +94 -94
  13. package/dist/collection/components/ez-button/ez-button.js +125 -125
  14. package/dist/collection/components/ez-calendar/ez-calendar.css +210 -210
  15. package/dist/collection/components/ez-calendar/ez-calendar.js +215 -215
  16. package/dist/collection/components/ez-check/ez-check.css +265 -265
  17. package/dist/collection/components/ez-check/ez-check.js +168 -168
  18. package/dist/collection/components/ez-collapsable-box/ez-collapsable-box.css +67 -67
  19. package/dist/collection/components/ez-collapsable-box/ez-collapsable-box.js +108 -108
  20. package/dist/collection/components/ez-combo-box/ez-combo-box-interfaces.js +2 -2
  21. package/dist/collection/components/ez-combo-box/ez-combo-box.css +167 -167
  22. package/dist/collection/components/ez-combo-box/ez-combo-box.js +363 -363
  23. package/dist/collection/components/ez-date-input/ez-date-input.css +38 -38
  24. package/dist/collection/components/ez-date-input/ez-date-input.js +172 -172
  25. package/dist/collection/components/ez-form/ez-form.css +19 -19
  26. package/dist/collection/components/ez-form/ez-form.js +368 -368
  27. package/dist/collection/components/ez-form/store/Form.actions.js +132 -132
  28. package/dist/collection/components/ez-form/store/Form.reducer.js +194 -194
  29. package/dist/collection/components/ez-form/store/Form.selectors.js +44 -44
  30. package/dist/collection/components/ez-form/subcomponents/DataUnit.js +251 -207
  31. package/dist/collection/components/ez-form/subcomponents/FormMetadata.js +16 -16
  32. package/dist/collection/components/ez-form/subcomponents/css/place-holder.css +23 -23
  33. package/dist/collection/components/ez-form/subcomponents/form-metadata.js +173 -173
  34. package/dist/collection/components/ez-form/subcomponents/place-holder.js +14 -14
  35. package/dist/collection/components/ez-form/subcomponents/structure/Field.js +71 -71
  36. package/dist/collection/components/ez-form/subcomponents/structure/FieldSet.js +27 -27
  37. package/dist/collection/components/ez-form/subcomponents/structure/FormSheet.js +40 -40
  38. package/dist/collection/components/ez-form/subcomponents/structure/NavigationBar.js +27 -27
  39. package/dist/collection/components/ez-icon/ez-icon.css +36 -36
  40. package/dist/collection/components/ez-icon/ez-icon.js +56 -56
  41. package/dist/collection/components/ez-label-chip/ez-label-chip.css +117 -117
  42. package/dist/collection/components/ez-label-chip/ez-label-chip.js +276 -276
  43. package/dist/collection/components/ez-modal/ez-modal.css +86 -86
  44. package/dist/collection/components/ez-modal/ez-modal.js +224 -224
  45. package/dist/collection/components/ez-number-input/ez-number-input.css +144 -144
  46. package/dist/collection/components/ez-number-input/ez-number-input.js +465 -465
  47. package/dist/collection/components/ez-popover/ez-popover.css +38 -38
  48. package/dist/collection/components/ez-popover/ez-popover.js +323 -323
  49. package/dist/collection/components/ez-search/ez-search.css +295 -295
  50. package/dist/collection/components/ez-search/ez-search.js +527 -527
  51. package/dist/collection/components/ez-tabselector/ez-tabselector.css +125 -125
  52. package/dist/collection/components/ez-tabselector/ez-tabselector.js +283 -283
  53. package/dist/collection/components/ez-text-area/ez-text-area.css +139 -139
  54. package/dist/collection/components/ez-text-area/ez-text-area.js +267 -267
  55. package/dist/collection/components/ez-text-input/ez-text-input.css +169 -169
  56. package/dist/collection/components/ez-text-input/ez-text-input.js +395 -395
  57. package/dist/collection/components/ez-time-input/ez-time-input.css +155 -155
  58. package/dist/collection/components/ez-time-input/ez-time-input.js +326 -326
  59. package/dist/collection/index.js +1 -1
  60. package/dist/collection/servidor.js +100 -100
  61. package/dist/collection/utils/FloatingManager.js +15 -15
  62. package/dist/collection/utils/utils.js +6 -6
  63. package/dist/custom-elements/index.js +3125 -3081
  64. package/dist/esm/{DataUnit-69e518fa.js → DataUnit-d5d4c9a3.js} +415 -371
  65. package/dist/esm/ez-action-chip.entry.js +41 -41
  66. package/dist/esm/ez-button_14.entry.js +1911 -1911
  67. package/dist/esm/ez-label-chip.entry.js +120 -120
  68. package/dist/esm/ez-modal.entry.js +104 -104
  69. package/dist/esm/ez-number-input.entry.js +236 -236
  70. package/dist/esm/ez-time-input.entry.js +168 -168
  71. package/dist/esm/form-metadata.entry.js +65 -65
  72. package/dist/esm/polyfills/core-js.js +0 -0
  73. package/dist/esm/polyfills/dom.js +0 -0
  74. package/dist/esm/polyfills/es5-html-element.js +0 -0
  75. package/dist/esm/polyfills/index.js +0 -0
  76. package/dist/esm/polyfills/system.js +0 -0
  77. package/dist/ezui/ezui.esm.js +1 -1
  78. package/dist/ezui/{p-b0974f4f.entry.js → p-0fcdfb51.entry.js} +1 -1
  79. package/dist/ezui/p-dac7a6c2.js +1 -0
  80. package/dist/ezui/{p-db11c600.entry.js → p-dbef7060.entry.js} +1 -1
  81. package/dist/types/components/ez-action-chip/ez-action-chip.d.ts +16 -16
  82. package/dist/types/components/ez-button/ez-button.d.ts +20 -20
  83. package/dist/types/components/ez-calendar/ez-calendar.d.ts +42 -42
  84. package/dist/types/components/ez-check/ez-check.d.ts +32 -32
  85. package/dist/types/components/ez-collapsable-box/ez-collapsable-box.d.ts +18 -18
  86. package/dist/types/components/ez-combo-box/ez-combo-box-interfaces.d.ts +4 -4
  87. package/dist/types/components/ez-combo-box/ez-combo-box.d.ts +68 -68
  88. package/dist/types/components/ez-date-input/ez-date-input.d.ts +31 -31
  89. package/dist/types/components/ez-form/ez-form.d.ts +26 -31
  90. package/dist/types/components/ez-form/store/Form.actions.d.ts +111 -111
  91. package/dist/types/components/ez-form/store/Form.reducer.d.ts +20 -20
  92. package/dist/types/components/ez-form/store/Form.selectors.d.ts +14 -14
  93. package/dist/types/components/ez-form/subcomponents/DataUnit.d.ts +60 -55
  94. package/dist/types/components/ez-form/subcomponents/FormMetadata.d.ts +41 -41
  95. package/dist/types/components/ez-form/subcomponents/form-metadata.d.ts +15 -15
  96. package/dist/types/components/ez-form/subcomponents/place-holder.d.ts +3 -3
  97. package/dist/types/components/ez-form/subcomponents/structure/Field.d.ts +10 -10
  98. package/dist/types/components/ez-form/subcomponents/structure/FieldSet.d.ts +12 -12
  99. package/dist/types/components/ez-form/subcomponents/structure/FormSheet.d.ts +13 -13
  100. package/dist/types/components/ez-form/subcomponents/structure/NavigationBar.d.ts +17 -17
  101. package/dist/types/components/ez-icon/ez-icon.d.ts +5 -5
  102. package/dist/types/components/ez-label-chip/ez-label-chip.d.ts +40 -40
  103. package/dist/types/components/ez-modal/ez-modal.d.ts +32 -32
  104. package/dist/types/components/ez-number-input/ez-number-input.d.ts +73 -73
  105. package/dist/types/components/ez-popover/ez-popover.d.ts +52 -52
  106. package/dist/types/components/ez-search/ez-search.d.ts +95 -95
  107. package/dist/types/components/ez-tabselector/ez-tabselector.d.ts +31 -31
  108. package/dist/types/components/ez-text-area/ez-text-area.d.ts +49 -49
  109. package/dist/types/components/ez-text-input/ez-text-input.d.ts +64 -64
  110. package/dist/types/components/ez-time-input/ez-time-input.d.ts +53 -53
  111. package/dist/types/index.d.ts +1 -1
  112. package/dist/types/utils/utils.d.ts +2 -2
  113. package/package.json +114 -114
  114. package/dist/ezui/p-10ef58b3.js +0 -1
  115. package/react/components.d.ts +0 -22
  116. package/react/components.js +0 -25
  117. package/react/components.js.map +0 -1
  118. package/react/react-component-lib/createComponent.d.ts +0 -10
  119. package/react/react-component-lib/createComponent.js +0 -59
  120. package/react/react-component-lib/createComponent.js.map +0 -1
  121. package/react/react-component-lib/createOverlayComponent.d.ts +0 -20
  122. package/react/react-component-lib/createOverlayComponent.js +0 -89
  123. package/react/react-component-lib/createOverlayComponent.js.map +0 -1
  124. package/react/react-component-lib/index.d.ts +0 -2
  125. package/react/react-component-lib/index.js +0 -3
  126. package/react/react-component-lib/index.js.map +0 -1
  127. package/react/react-component-lib/interfaces.d.ts +0 -29
  128. package/react/react-component-lib/interfaces.js +0 -1
  129. package/react/react-component-lib/interfaces.js.map +0 -1
  130. package/react/react-component-lib/utils/attachProps.d.ts +0 -12
  131. package/react/react-component-lib/utils/attachProps.js +0 -96
  132. package/react/react-component-lib/utils/attachProps.js.map +0 -1
  133. package/react/react-component-lib/utils/case.d.ts +0 -2
  134. package/react/react-component-lib/utils/case.js +0 -7
  135. package/react/react-component-lib/utils/case.js.map +0 -1
  136. package/react/react-component-lib/utils/dev.d.ts +0 -2
  137. package/react/react-component-lib/utils/dev.js +0 -13
  138. package/react/react-component-lib/utils/dev.js.map +0 -1
  139. package/react/react-component-lib/utils/index.d.ts +0 -7
  140. package/react/react-component-lib/utils/index.js +0 -21
  141. package/react/react-component-lib/utils/index.js.map +0 -1
@@ -1,395 +1,395 @@
1
- import { Component, Prop, h, Watch, Host, Method, Event, Element } from '@stencil/core';
2
- import { isValidNumber } from '../../utils/utils';
3
- import { MaskFormatter } from '@sankhyalabs/core';
4
- export class EzTextInput {
5
- constructor() {
6
- /**
7
- * Deixa o campo disponível ou não para digitação.
8
- */
9
- this.enabled = true;
10
- }
11
- showError() {
12
- const hasError = typeof this.errormessage === 'string' && this.errormessage !== '';
13
- if (hasError) {
14
- this._inputElem.classList.add('hasError');
15
- this._messageBoxElem.classList.add('hasError');
16
- }
17
- else {
18
- this._inputElem.classList.remove('hasError');
19
- this._messageBoxElem.classList.remove('hasError');
20
- }
21
- }
22
- prepareMask() {
23
- if (this.mask) {
24
- if (this._maskFormatter == undefined) {
25
- this._maskFormatter = new MaskFormatter(this.mask);
26
- }
27
- else {
28
- this._maskFormatter.mask = this.mask;
29
- }
30
- }
31
- }
32
- updateInputValue() {
33
- this._inputElem.value = this.value;
34
- this.handleChange();
35
- this.ezChange.emit();
36
- this.adjustFloatingLabel();
37
- }
38
- adjustFloatingLabel() {
39
- if (this.label) {
40
- if (!this._inputElem.classList.contains("input--with--label")) {
41
- this._inputElem.classList.add("input--with--label");
42
- }
43
- const hasValue = this.value && this.value.toString().length > 0;
44
- const containsFloatedClass = this._labelElem.classList.contains("input__label--floated");
45
- if (hasValue || this.isFocused()) {
46
- if (!containsFloatedClass) {
47
- this._labelElem.classList.add("input__label--floated");
48
- }
49
- }
50
- else {
51
- if (containsFloatedClass) {
52
- this._labelElem.classList.remove("input__label--floated");
53
- }
54
- }
55
- }
56
- }
57
- isFocused() {
58
- return this._hostElement.shadowRoot.activeElement !== null;
59
- }
60
- //---------------------------------------------
61
- // Public methods
62
- //---------------------------------------------
63
- /**
64
- * Faz o foco no componente de input
65
- */
66
- async setFocus() {
67
- this._inputElem.focus();
68
- }
69
- /**
70
- * Remove o foco no componente de input
71
- */
72
- async setBlur() {
73
- this._inputElem.blur();
74
- }
75
- //---------------------------------------------
76
- // Event handlers
77
- //---------------------------------------------
78
- handleFocusout() {
79
- const value = this._inputElem.value;
80
- if (value && this._maskFormatter) {
81
- try {
82
- this._inputElem.value = this._maskFormatter.format(value);
83
- }
84
- catch (e) {
85
- this.errormessage = e.message;
86
- }
87
- }
88
- this.value = this._inputElem.value;
89
- this.adjustFloatingLabel();
90
- }
91
- isValidValue(value) {
92
- if (this.onlynumber) {
93
- return value == "" || isValidNumber(value);
94
- }
95
- if (this.restrict) {
96
- return Array.from(value).reduce((valid, c) => valid && this.restrict.indexOf(c) > -1, true);
97
- }
98
- return true;
99
- }
100
- handleChange() {
101
- if (!this._inputElem) {
102
- return;
103
- }
104
- const value = this._inputElem.value;
105
- if (this.isValidValue(value)) {
106
- this._lastValidValue = value;
107
- }
108
- else {
109
- this._inputElem.value = this._lastValidValue === undefined ? "" : this._lastValidValue;
110
- }
111
- this.value = this._inputElem.value;
112
- }
113
- handleSlotChange(ev) {
114
- const slot = ev.target;
115
- const content = slot.assignedElements()[0];
116
- if (content) {
117
- content.style.position = "absolute";
118
- content.style.display = "flex";
119
- content.style.alignItems = "center";
120
- content.style.justifyContent = "center";
121
- content.style.overflow = "hidden";
122
- content.style.top = "0px";
123
- content.style.width = "var(--it__icon--width)";
124
- content.style.height = "var(--it--height)";
125
- if (slot.name == "leftIcon") {
126
- content.style.left = "0px";
127
- content.style.borderRadius = "var(--it--border-radius) 0 0 var(--it--border-radius)";
128
- this._inputElem.classList.add('icon--left');
129
- if (this._labelElem) {
130
- this._labelElem.classList.add('input__label--left');
131
- }
132
- }
133
- else if (slot.name == "rightIcon") {
134
- content.style.right = "0px";
135
- content.style.borderRadius = "0 var(--it--border-radius) var(--it--border-radius) 0";
136
- this._inputElem.classList.add('icon--right');
137
- if (this._labelElem) {
138
- this._labelElem.classList.add('input__label--right');
139
- }
140
- }
141
- }
142
- this.showError();
143
- }
144
- doFocus() {
145
- if (this.label && this._labelElem && !this._labelElem.classList.contains("input__label--floated")) {
146
- this._labelElem.classList.add("input__label--floated");
147
- }
148
- }
149
- //---------------------------------------------
150
- // Lifecycle web component
151
- //---------------------------------------------
152
- componentDidLoad() {
153
- if (this.onlynumber) {
154
- this._inputElem.classList.add('text--right');
155
- }
156
- this.showError();
157
- this.prepareMask();
158
- this.adjustFloatingLabel();
159
- }
160
- componentWillLoad() {
161
- this.prepareMask();
162
- if (this.value) {
163
- if (this._maskFormatter) {
164
- try {
165
- this.value = this._maskFormatter.format(this.value);
166
- }
167
- catch (e) {
168
- this.errormessage = e.message;
169
- }
170
- }
171
- if (!this.isValidValue(this.value)) {
172
- this._lastValidValue = "";
173
- this.value = "";
174
- }
175
- }
176
- }
177
- render() {
178
- return (h(Host, null,
179
- h("slot", { name: "leftIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } }),
180
- this.label ?
181
- 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)
182
- : null,
183
- h("input", { onFocus: () => this.doFocus(), ref: (el) => this._inputElem = el, type: "text", value: this.value, disabled: !this.enabled, onInput: () => { this.handleChange(); }, onFocusout: () => { this.handleFocusout(); } }),
184
- h("slot", { name: "rightIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } }),
185
- h("span", { class: "message-box", ref: (el) => this._messageBoxElem = el, title: this.errormessage }, this.errormessage)));
186
- }
187
- static get is() { return "ez-text-input"; }
188
- static get encapsulation() { return "shadow"; }
189
- static get originalStyleUrls() { return {
190
- "$": ["ez-text-input.css"]
191
- }; }
192
- static get styleUrls() { return {
193
- "$": ["ez-text-input.css"]
194
- }; }
195
- static get properties() { return {
196
- "label": {
197
- "type": "string",
198
- "mutable": false,
199
- "complexType": {
200
- "original": "string",
201
- "resolved": "string",
202
- "references": {}
203
- },
204
- "required": false,
205
- "optional": false,
206
- "docs": {
207
- "tags": [],
208
- "text": "Label \u00E9 o t\u00EDtulo do campo"
209
- },
210
- "attribute": "label",
211
- "reflect": true
212
- },
213
- "value": {
214
- "type": "string",
215
- "mutable": true,
216
- "complexType": {
217
- "original": "string",
218
- "resolved": "string",
219
- "references": {}
220
- },
221
- "required": false,
222
- "optional": false,
223
- "docs": {
224
- "tags": [],
225
- "text": "Valor digitado pelo usu\u00E1rio. Este valor \u00E9 o que fica vis\u00EDvel no campo."
226
- },
227
- "attribute": "value",
228
- "reflect": true
229
- },
230
- "enabled": {
231
- "type": "boolean",
232
- "mutable": false,
233
- "complexType": {
234
- "original": "boolean",
235
- "resolved": "boolean",
236
- "references": {}
237
- },
238
- "required": false,
239
- "optional": false,
240
- "docs": {
241
- "tags": [],
242
- "text": "Deixa o campo dispon\u00EDvel ou n\u00E3o para digita\u00E7\u00E3o."
243
- },
244
- "attribute": "enabled",
245
- "reflect": true,
246
- "defaultValue": "true"
247
- },
248
- "loading": {
249
- "type": "boolean",
250
- "mutable": false,
251
- "complexType": {
252
- "original": "boolean",
253
- "resolved": "boolean",
254
- "references": {}
255
- },
256
- "required": false,
257
- "optional": false,
258
- "docs": {
259
- "tags": [],
260
- "text": "Deixa o componente em modo \"carregando\"."
261
- },
262
- "attribute": "loading",
263
- "reflect": true
264
- },
265
- "errormessage": {
266
- "type": "string",
267
- "mutable": true,
268
- "complexType": {
269
- "original": "string",
270
- "resolved": "string",
271
- "references": {}
272
- },
273
- "required": false,
274
- "optional": false,
275
- "docs": {
276
- "tags": [],
277
- "text": "Quando h\u00E1 um problema de valida\u00E7\u00E3o, serve como orienta\u00E7\u00E3o ao usu\u00E1rio"
278
- },
279
- "attribute": "errormessage",
280
- "reflect": true
281
- },
282
- "onlynumber": {
283
- "type": "boolean",
284
- "mutable": false,
285
- "complexType": {
286
- "original": "boolean",
287
- "resolved": "boolean",
288
- "references": {}
289
- },
290
- "required": false,
291
- "optional": false,
292
- "docs": {
293
- "tags": [],
294
- "text": "Faz com que o componente s\u00F3 aceite n\u00FAmeros"
295
- },
296
- "attribute": "onlynumber",
297
- "reflect": true
298
- },
299
- "mask": {
300
- "type": "string",
301
- "mutable": false,
302
- "complexType": {
303
- "original": "string",
304
- "resolved": "string",
305
- "references": {}
306
- },
307
- "required": false,
308
- "optional": false,
309
- "docs": {
310
- "tags": [],
311
- "text": "Aplica uma m\u00E1scara no conte\u00FAdo conforme um o padr\u00E3o estabelecido"
312
- },
313
- "attribute": "mask",
314
- "reflect": false
315
- },
316
- "restrict": {
317
- "type": "string",
318
- "mutable": false,
319
- "complexType": {
320
- "original": "string",
321
- "resolved": "string",
322
- "references": {}
323
- },
324
- "required": false,
325
- "optional": false,
326
- "docs": {
327
- "tags": [],
328
- "text": "Restringe o que o usu\u00E1rio pode digitar. Cada caractere digitado ser\u00E1 testado\ne deve estar contido nessa string ou ser\u00E1 descartado."
329
- },
330
- "attribute": "restrict",
331
- "reflect": false
332
- }
333
- }; }
334
- static get events() { return [{
335
- "method": "ezChange",
336
- "name": "ezChange",
337
- "bubbles": true,
338
- "cancelable": true,
339
- "composed": true,
340
- "docs": {
341
- "tags": [],
342
- "text": ""
343
- },
344
- "complexType": {
345
- "original": "string",
346
- "resolved": "string",
347
- "references": {}
348
- }
349
- }]; }
350
- static get methods() { return {
351
- "setFocus": {
352
- "complexType": {
353
- "signature": "() => Promise<void>",
354
- "parameters": [],
355
- "references": {
356
- "Promise": {
357
- "location": "global"
358
- }
359
- },
360
- "return": "Promise<void>"
361
- },
362
- "docs": {
363
- "text": "Faz o foco no componente de input",
364
- "tags": []
365
- }
366
- },
367
- "setBlur": {
368
- "complexType": {
369
- "signature": "() => Promise<void>",
370
- "parameters": [],
371
- "references": {
372
- "Promise": {
373
- "location": "global"
374
- }
375
- },
376
- "return": "Promise<void>"
377
- },
378
- "docs": {
379
- "text": "Remove o foco no componente de input",
380
- "tags": []
381
- }
382
- }
383
- }; }
384
- static get elementRef() { return "_hostElement"; }
385
- static get watchers() { return [{
386
- "propName": "errormessage",
387
- "methodName": "showError"
388
- }, {
389
- "propName": "mask",
390
- "methodName": "prepareMask"
391
- }, {
392
- "propName": "value",
393
- "methodName": "updateInputValue"
394
- }]; }
395
- }
1
+ import { Component, Prop, h, Watch, Host, Method, Event, Element } from '@stencil/core';
2
+ import { isValidNumber } from '../../utils/utils';
3
+ import { MaskFormatter } from '@sankhyalabs/core';
4
+ export class EzTextInput {
5
+ constructor() {
6
+ /**
7
+ * Deixa o campo disponível ou não para digitação.
8
+ */
9
+ this.enabled = true;
10
+ }
11
+ showError() {
12
+ const hasError = typeof this.errormessage === 'string' && this.errormessage !== '';
13
+ if (hasError) {
14
+ this._inputElem.classList.add('hasError');
15
+ this._messageBoxElem.classList.add('hasError');
16
+ }
17
+ else {
18
+ this._inputElem.classList.remove('hasError');
19
+ this._messageBoxElem.classList.remove('hasError');
20
+ }
21
+ }
22
+ prepareMask() {
23
+ if (this.mask) {
24
+ if (this._maskFormatter == undefined) {
25
+ this._maskFormatter = new MaskFormatter(this.mask);
26
+ }
27
+ else {
28
+ this._maskFormatter.mask = this.mask;
29
+ }
30
+ }
31
+ }
32
+ updateInputValue() {
33
+ this._inputElem.value = this.value;
34
+ this.handleChange();
35
+ this.ezChange.emit();
36
+ this.adjustFloatingLabel();
37
+ }
38
+ adjustFloatingLabel() {
39
+ if (this.label) {
40
+ if (!this._inputElem.classList.contains("input--with--label")) {
41
+ this._inputElem.classList.add("input--with--label");
42
+ }
43
+ const hasValue = this.value && this.value.toString().length > 0;
44
+ const containsFloatedClass = this._labelElem.classList.contains("input__label--floated");
45
+ if (hasValue || this.isFocused()) {
46
+ if (!containsFloatedClass) {
47
+ this._labelElem.classList.add("input__label--floated");
48
+ }
49
+ }
50
+ else {
51
+ if (containsFloatedClass) {
52
+ this._labelElem.classList.remove("input__label--floated");
53
+ }
54
+ }
55
+ }
56
+ }
57
+ isFocused() {
58
+ return this._hostElement.shadowRoot.activeElement !== null;
59
+ }
60
+ //---------------------------------------------
61
+ // Public methods
62
+ //---------------------------------------------
63
+ /**
64
+ * Faz o foco no componente de input
65
+ */
66
+ async setFocus() {
67
+ this._inputElem.focus();
68
+ }
69
+ /**
70
+ * Remove o foco no componente de input
71
+ */
72
+ async setBlur() {
73
+ this._inputElem.blur();
74
+ }
75
+ //---------------------------------------------
76
+ // Event handlers
77
+ //---------------------------------------------
78
+ handleFocusout() {
79
+ const value = this._inputElem.value;
80
+ if (value && this._maskFormatter) {
81
+ try {
82
+ this._inputElem.value = this._maskFormatter.format(value);
83
+ }
84
+ catch (e) {
85
+ this.errormessage = e.message;
86
+ }
87
+ }
88
+ this.value = this._inputElem.value;
89
+ this.adjustFloatingLabel();
90
+ }
91
+ isValidValue(value) {
92
+ if (this.onlynumber) {
93
+ return value == "" || isValidNumber(value);
94
+ }
95
+ if (this.restrict) {
96
+ return Array.from(value).reduce((valid, c) => valid && this.restrict.indexOf(c) > -1, true);
97
+ }
98
+ return true;
99
+ }
100
+ handleChange() {
101
+ if (!this._inputElem) {
102
+ return;
103
+ }
104
+ const value = this._inputElem.value;
105
+ if (this.isValidValue(value)) {
106
+ this._lastValidValue = value;
107
+ }
108
+ else {
109
+ this._inputElem.value = this._lastValidValue === undefined ? "" : this._lastValidValue;
110
+ }
111
+ this.value = this._inputElem.value;
112
+ }
113
+ handleSlotChange(ev) {
114
+ const slot = ev.target;
115
+ const content = slot.assignedElements()[0];
116
+ if (content) {
117
+ content.style.position = "absolute";
118
+ content.style.display = "flex";
119
+ content.style.alignItems = "center";
120
+ content.style.justifyContent = "center";
121
+ content.style.overflow = "hidden";
122
+ content.style.top = "0px";
123
+ content.style.width = "var(--it__icon--width)";
124
+ content.style.height = "var(--it--height)";
125
+ if (slot.name == "leftIcon") {
126
+ content.style.left = "0px";
127
+ content.style.borderRadius = "var(--it--border-radius) 0 0 var(--it--border-radius)";
128
+ this._inputElem.classList.add('icon--left');
129
+ if (this._labelElem) {
130
+ this._labelElem.classList.add('input__label--left');
131
+ }
132
+ }
133
+ else if (slot.name == "rightIcon") {
134
+ content.style.right = "0px";
135
+ content.style.borderRadius = "0 var(--it--border-radius) var(--it--border-radius) 0";
136
+ this._inputElem.classList.add('icon--right');
137
+ if (this._labelElem) {
138
+ this._labelElem.classList.add('input__label--right');
139
+ }
140
+ }
141
+ }
142
+ this.showError();
143
+ }
144
+ doFocus() {
145
+ if (this.label && this._labelElem && !this._labelElem.classList.contains("input__label--floated")) {
146
+ this._labelElem.classList.add("input__label--floated");
147
+ }
148
+ }
149
+ //---------------------------------------------
150
+ // Lifecycle web component
151
+ //---------------------------------------------
152
+ componentDidLoad() {
153
+ if (this.onlynumber) {
154
+ this._inputElem.classList.add('text--right');
155
+ }
156
+ this.showError();
157
+ this.prepareMask();
158
+ this.adjustFloatingLabel();
159
+ }
160
+ componentWillLoad() {
161
+ this.prepareMask();
162
+ if (this.value) {
163
+ if (this._maskFormatter) {
164
+ try {
165
+ this.value = this._maskFormatter.format(this.value);
166
+ }
167
+ catch (e) {
168
+ this.errormessage = e.message;
169
+ }
170
+ }
171
+ if (!this.isValidValue(this.value)) {
172
+ this._lastValidValue = "";
173
+ this.value = "";
174
+ }
175
+ }
176
+ }
177
+ render() {
178
+ return (h(Host, null,
179
+ h("slot", { name: "leftIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } }),
180
+ this.label ?
181
+ 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)
182
+ : null,
183
+ h("input", { onFocus: () => this.doFocus(), ref: (el) => this._inputElem = el, type: "text", value: this.value, disabled: !this.enabled, onInput: () => { this.handleChange(); }, onFocusout: () => { this.handleFocusout(); } }),
184
+ h("slot", { name: "rightIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } }),
185
+ h("span", { class: "message-box", ref: (el) => this._messageBoxElem = el, title: this.errormessage }, this.errormessage)));
186
+ }
187
+ static get is() { return "ez-text-input"; }
188
+ static get encapsulation() { return "shadow"; }
189
+ static get originalStyleUrls() { return {
190
+ "$": ["ez-text-input.css"]
191
+ }; }
192
+ static get styleUrls() { return {
193
+ "$": ["ez-text-input.css"]
194
+ }; }
195
+ static get properties() { return {
196
+ "label": {
197
+ "type": "string",
198
+ "mutable": false,
199
+ "complexType": {
200
+ "original": "string",
201
+ "resolved": "string",
202
+ "references": {}
203
+ },
204
+ "required": false,
205
+ "optional": false,
206
+ "docs": {
207
+ "tags": [],
208
+ "text": "Label \u00E9 o t\u00EDtulo do campo"
209
+ },
210
+ "attribute": "label",
211
+ "reflect": true
212
+ },
213
+ "value": {
214
+ "type": "string",
215
+ "mutable": true,
216
+ "complexType": {
217
+ "original": "string",
218
+ "resolved": "string",
219
+ "references": {}
220
+ },
221
+ "required": false,
222
+ "optional": false,
223
+ "docs": {
224
+ "tags": [],
225
+ "text": "Valor digitado pelo usu\u00E1rio. Este valor \u00E9 o que fica vis\u00EDvel no campo."
226
+ },
227
+ "attribute": "value",
228
+ "reflect": true
229
+ },
230
+ "enabled": {
231
+ "type": "boolean",
232
+ "mutable": false,
233
+ "complexType": {
234
+ "original": "boolean",
235
+ "resolved": "boolean",
236
+ "references": {}
237
+ },
238
+ "required": false,
239
+ "optional": false,
240
+ "docs": {
241
+ "tags": [],
242
+ "text": "Deixa o campo dispon\u00EDvel ou n\u00E3o para digita\u00E7\u00E3o."
243
+ },
244
+ "attribute": "enabled",
245
+ "reflect": true,
246
+ "defaultValue": "true"
247
+ },
248
+ "loading": {
249
+ "type": "boolean",
250
+ "mutable": false,
251
+ "complexType": {
252
+ "original": "boolean",
253
+ "resolved": "boolean",
254
+ "references": {}
255
+ },
256
+ "required": false,
257
+ "optional": false,
258
+ "docs": {
259
+ "tags": [],
260
+ "text": "Deixa o componente em modo \"carregando\"."
261
+ },
262
+ "attribute": "loading",
263
+ "reflect": true
264
+ },
265
+ "errormessage": {
266
+ "type": "string",
267
+ "mutable": true,
268
+ "complexType": {
269
+ "original": "string",
270
+ "resolved": "string",
271
+ "references": {}
272
+ },
273
+ "required": false,
274
+ "optional": false,
275
+ "docs": {
276
+ "tags": [],
277
+ "text": "Quando h\u00E1 um problema de valida\u00E7\u00E3o, serve como orienta\u00E7\u00E3o ao usu\u00E1rio"
278
+ },
279
+ "attribute": "errormessage",
280
+ "reflect": true
281
+ },
282
+ "onlynumber": {
283
+ "type": "boolean",
284
+ "mutable": false,
285
+ "complexType": {
286
+ "original": "boolean",
287
+ "resolved": "boolean",
288
+ "references": {}
289
+ },
290
+ "required": false,
291
+ "optional": false,
292
+ "docs": {
293
+ "tags": [],
294
+ "text": "Faz com que o componente s\u00F3 aceite n\u00FAmeros"
295
+ },
296
+ "attribute": "onlynumber",
297
+ "reflect": true
298
+ },
299
+ "mask": {
300
+ "type": "string",
301
+ "mutable": false,
302
+ "complexType": {
303
+ "original": "string",
304
+ "resolved": "string",
305
+ "references": {}
306
+ },
307
+ "required": false,
308
+ "optional": false,
309
+ "docs": {
310
+ "tags": [],
311
+ "text": "Aplica uma m\u00E1scara no conte\u00FAdo conforme um o padr\u00E3o estabelecido"
312
+ },
313
+ "attribute": "mask",
314
+ "reflect": false
315
+ },
316
+ "restrict": {
317
+ "type": "string",
318
+ "mutable": false,
319
+ "complexType": {
320
+ "original": "string",
321
+ "resolved": "string",
322
+ "references": {}
323
+ },
324
+ "required": false,
325
+ "optional": false,
326
+ "docs": {
327
+ "tags": [],
328
+ "text": "Restringe o que o usu\u00E1rio pode digitar. Cada caractere digitado ser\u00E1 testado\r\ne deve estar contido nessa string ou ser\u00E1 descartado."
329
+ },
330
+ "attribute": "restrict",
331
+ "reflect": false
332
+ }
333
+ }; }
334
+ static get events() { return [{
335
+ "method": "ezChange",
336
+ "name": "ezChange",
337
+ "bubbles": true,
338
+ "cancelable": true,
339
+ "composed": true,
340
+ "docs": {
341
+ "tags": [],
342
+ "text": ""
343
+ },
344
+ "complexType": {
345
+ "original": "string",
346
+ "resolved": "string",
347
+ "references": {}
348
+ }
349
+ }]; }
350
+ static get methods() { return {
351
+ "setFocus": {
352
+ "complexType": {
353
+ "signature": "() => Promise<void>",
354
+ "parameters": [],
355
+ "references": {
356
+ "Promise": {
357
+ "location": "global"
358
+ }
359
+ },
360
+ "return": "Promise<void>"
361
+ },
362
+ "docs": {
363
+ "text": "Faz o foco no componente de input",
364
+ "tags": []
365
+ }
366
+ },
367
+ "setBlur": {
368
+ "complexType": {
369
+ "signature": "() => Promise<void>",
370
+ "parameters": [],
371
+ "references": {
372
+ "Promise": {
373
+ "location": "global"
374
+ }
375
+ },
376
+ "return": "Promise<void>"
377
+ },
378
+ "docs": {
379
+ "text": "Remove o foco no componente de input",
380
+ "tags": []
381
+ }
382
+ }
383
+ }; }
384
+ static get elementRef() { return "_hostElement"; }
385
+ static get watchers() { return [{
386
+ "propName": "errormessage",
387
+ "methodName": "showError"
388
+ }, {
389
+ "propName": "mask",
390
+ "methodName": "prepareMask"
391
+ }, {
392
+ "propName": "value",
393
+ "methodName": "updateInputValue"
394
+ }]; }
395
+ }