@dile/ui 3.22.0 → 3.23.0

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 (29) hide show
  1. package/components/button/src/DileButton.js +3 -0
  2. package/components/color-picker/src/DileColorPicker.js +6 -2
  3. package/components/drop-file/src/DileDropFile.js +3 -3
  4. package/components/form-group/form-group.js +5 -0
  5. package/components/form-group/index.js +1 -0
  6. package/components/form-group/src/DileFormGroup.js +188 -0
  7. package/components/input/src/DileInput.js +121 -30
  8. package/components/input/src/DileInputContact.js +38 -40
  9. package/components/input/src/DileInputIcon.js +7 -43
  10. package/components/input/src/DileInputInteger.js +8 -22
  11. package/components/input/src/DileInputMask.js +9 -15
  12. package/components/input/src/DileInputMoney.js +6 -23
  13. package/components/input/src/DileInputNumber.js +6 -12
  14. package/components/input/src/DileInputNumberMask.js +5 -12
  15. package/components/input/src/DileInputPercentage.js +8 -20
  16. package/components/input/src/DileInputSearch.js +5 -1
  17. package/components/menu-overlay/src/DileMenuOverlay.js +17 -0
  18. package/components/number-picker/src/DileNumberPicker.js +3 -2
  19. package/components/number-picker/src/DileNumberPickerElement.js +5 -0
  20. package/components/otp-input/src/DileOtpInput.js +5 -2
  21. package/components/password/src/DilePassword.js +19 -42
  22. package/components/select/src/DileSelectAjax.js +5 -3
  23. package/components/time-picker/src/DileTimePicker.js +5 -2
  24. package/components/wheel-picker/index.js +1 -0
  25. package/components/wheel-picker/src/DileWheelPicker.js +364 -0
  26. package/components/wheel-picker/wheel-picker.js +5 -0
  27. package/mixins/form/index.js +1 -1
  28. package/mixins/form/src/DileFieldMessage.js +4 -1
  29. package/package.json +2 -2
@@ -27,6 +27,8 @@ export class DileButton extends LitElement {
27
27
  noWrap: { type: Boolean, reflect: true, attribute: 'no-wrap' },
28
28
  /** Accessible name for the button. Required when the button only shows an icon. */
29
29
  label: { type: String },
30
+ /** Accessible description of the button, applied as aria-description (e.g. a related validation message). */
31
+ accessibleDescription: { type: String },
30
32
  _hasText: { type: Boolean, state: true },
31
33
  };
32
34
  }
@@ -175,6 +177,7 @@ export class DileButton extends LitElement {
175
177
  type=${this.type || "button"}
176
178
  aria-label=${ifDefined(this._computedAriaLabel)}
177
179
  aria-busy=${ifDefined(this.loading ? 'true' : undefined)}
180
+ aria-description=${ifDefined(this.accessibleDescription || undefined)}
178
181
  >
179
182
  ${showIcon && this.iconPosition !== 'right' ? this.iconTemplate : ''}
180
183
  <slot @slotchange=${this._onSlotChange}></slot>
@@ -1,5 +1,6 @@
1
1
  import { LitElement, html, css } from 'lit';
2
- import { DileEmmitChange } from '../../../mixins/form/index.js';
2
+ import { ifDefined } from 'lit/directives/if-defined.js';
3
+ import { DileEmmitChange, FIELD_MESSAGE_ID } from '../../../mixins/form/index.js';
3
4
  import { DileOverlay } from '../../../mixins/overlay/index.js';
4
5
  import { DileCloseDocumentClick } from '../../../mixins/close-document-click/index.js';
5
6
  import { DileCloseOnEscPressed } from '../../../mixins/close-on-esc-pressed/index.js';
@@ -308,6 +309,7 @@ export class DileColorPicker extends DileOverlay(
308
309
  aria-haspopup="dialog"
309
310
  aria-expanded="${this.opened}"
310
311
  aria-label="${this.label || 'Color picker'}"
312
+ aria-describedby="${ifDefined(this.message ? FIELD_MESSAGE_ID : undefined)}"
311
313
  @click="${this.toggle}"
312
314
  ></button>
313
315
  </div>
@@ -361,6 +363,8 @@ export class DileColorPicker extends DileOverlay(
361
363
  type="text"
362
364
  class="hex-input ${this.errored ? 'errored' : ''}"
363
365
  aria-label="Hex color"
366
+ aria-invalid="${ifDefined(this.errored ? 'true' : undefined)}"
367
+ aria-describedby="${ifDefined(this.message ? FIELD_MESSAGE_ID : undefined)}"
364
368
  maxlength="7"
365
369
  spellcheck="false"
366
370
  autocomplete="off"
@@ -379,7 +383,7 @@ export class DileColorPicker extends DileOverlay(
379
383
  get messageTemplate() {
380
384
  return html`
381
385
  ${this.message
382
- ? html`<div class="message ${this.errored ? 'errored-msg' : ''}"><span>${this.message}</span></div>`
386
+ ? html`<div id="${FIELD_MESSAGE_ID}" class="message ${this.errored ? 'errored-msg' : ''}"><span>${this.message}</span></div>`
383
387
  : ''
384
388
  }
385
389
  `;
@@ -4,7 +4,7 @@ import '../file-preview.js';
4
4
  import '../../button/button.js';
5
5
  import { labelStyles } from '../../input/src/label-styles.js';
6
6
  import { messageStyles } from '../../input/src/message-styles.js';
7
- import { DileEmmitChange } from '../../../mixins/form/index.js';
7
+ import { DileEmmitChange, FIELD_MESSAGE_ID } from '../../../mixins/form/index.js';
8
8
 
9
9
  export class DileDropFile extends DileEmmitChange(LitElement) {
10
10
  static styles = [
@@ -136,7 +136,7 @@ export class DileDropFile extends DileEmmitChange(LitElement) {
136
136
  get messageTemplate() {
137
137
  return html`
138
138
  ${this.message
139
- ? html`<div class="message ${this.errored ? 'errored-msg' : ''}"><span>${this.message}</span></div>`
139
+ ? html`<div id="${FIELD_MESSAGE_ID}" class="message ${this.errored ? 'errored-msg' : ''}"><span>${this.message}</span></div>`
140
140
  : ''
141
141
  }
142
142
  `
@@ -145,7 +145,7 @@ export class DileDropFile extends DileEmmitChange(LitElement) {
145
145
  get dropLabelTemplate() {
146
146
  return html`
147
147
  <p>${this.dropLabel}</p>
148
- <p><dile-button>${this.buttonLabel}</dile-button></p>
148
+ <p><dile-button .accessibleDescription=${this.message || undefined}>${this.buttonLabel}</dile-button></p>
149
149
  `
150
150
  }
151
151
 
@@ -0,0 +1,5 @@
1
+ import { DileFormGroup } from "./src/DileFormGroup.js";
2
+
3
+ if (!customElements.get("dile-form-group")) {
4
+ window.customElements.define("dile-form-group", DileFormGroup);
5
+ }
@@ -0,0 +1 @@
1
+ export { DileFormGroup } from './src/DileFormGroup.js';
@@ -0,0 +1,188 @@
1
+ import { LitElement, html, css, nothing } from 'lit';
2
+
3
+ export class DileFormGroup extends LitElement {
4
+ static styles = [
5
+ css`
6
+ * {
7
+ box-sizing: border-box;
8
+ }
9
+ :host {
10
+ display: block;
11
+ margin: var(--dile-form-group-margin, 0 0 1.5rem);
12
+ }
13
+ :host([hidden]) {
14
+ display: none;
15
+ }
16
+
17
+ .group {
18
+ padding: var(--dile-form-group-padding, 1rem 0 0);
19
+ border-top: var(--dile-form-group-border-top, 1px solid var(--dile-form-group-line-color, var(--dile-secondary-dark-color, #888)));
20
+ }
21
+ :host([variant="box"]) .group {
22
+ padding: var(--dile-form-group-padding, 1rem);
23
+ border: var(--dile-form-group-border, 1px solid var(--dile-form-group-line-color, #ccc));
24
+ border-radius: var(--dile-form-group-border-radius, 0.5rem);
25
+ background-color: var(--dile-form-group-background-color, transparent);
26
+ }
27
+ :host([variant="plain"]) .group {
28
+ padding: var(--dile-form-group-padding, 0);
29
+ border: none;
30
+ }
31
+
32
+ header {
33
+ margin-bottom: var(--dile-form-group-header-margin-bottom, 0.75rem);
34
+ }
35
+ .label {
36
+ margin: 0;
37
+ color: var(--dile-form-group-label-color, var(--dile-secondary-dark-color, #888));
38
+ font-size: var(--dile-form-group-label-font-size, 1.1rem);
39
+ font-weight: var(--dile-form-group-label-font-weight, 300);
40
+ }
41
+ .description {
42
+ margin: 0.25rem 0 0;
43
+ color: var(--dile-form-group-description-color, var(--dile-on-background-color, #303030));
44
+ font-size: var(--dile-form-group-description-font-size, 0.875rem);
45
+ opacity: 0.8;
46
+ }
47
+
48
+ .grid {
49
+ display: grid;
50
+ grid-template-columns: minmax(0, 1fr);
51
+ gap: var(--dile-form-group-gap, 0 1rem);
52
+ align-items: start;
53
+ }
54
+ :host([columns="2"]) .grid {
55
+ grid-template-columns: repeat(2, minmax(0, 1fr));
56
+ }
57
+ :host([columns="3"]) .grid {
58
+ grid-template-columns: repeat(3, minmax(0, 1fr));
59
+ }
60
+ .grid ::slotted([data-span="2"]) {
61
+ grid-column: span 2;
62
+ }
63
+ .grid ::slotted([data-span="full"]) {
64
+ grid-column: 1 / -1;
65
+ }
66
+
67
+ .split {
68
+ display: grid;
69
+ grid-template-columns: var(--dile-form-group-split-columns, 1fr 1fr);
70
+ gap: var(--dile-form-group-gap, 0 1rem);
71
+ align-items: start;
72
+ }
73
+ .split-column {
74
+ display: flex;
75
+ flex-direction: column;
76
+ min-width: 0;
77
+ }
78
+ .split:not(.has-content) {
79
+ display: none;
80
+ }
81
+
82
+ :host([collapsed]) .grid,
83
+ :host([collapsed]) .split {
84
+ grid-template-columns: minmax(0, 1fr);
85
+ }
86
+ :host([collapsed]) .grid ::slotted([data-span]) {
87
+ grid-column: auto;
88
+ }
89
+ `
90
+ ];
91
+
92
+ static get properties() {
93
+ return {
94
+ label: { type: String },
95
+ description: { type: String },
96
+ labelLevel: { type: Number, attribute: 'label-level' },
97
+ columns: { type: Number, reflect: true },
98
+ breakpoint: { type: Number },
99
+ variant: { type: String, reflect: true },
100
+ collapsed: { type: Boolean, reflect: true },
101
+ _hasSplitContent: { state: true },
102
+ _hasLabelSlot: { state: true },
103
+ };
104
+ }
105
+
106
+ constructor() {
107
+ super();
108
+ this.columns = 1;
109
+ this.breakpoint = 600;
110
+ this.variant = 'line';
111
+ this.collapsed = false;
112
+ this._hasSplitContent = false;
113
+ this._hasLabelSlot = false;
114
+ this._width = null;
115
+ this._resizeObserver = new ResizeObserver((entries) => {
116
+ this._width = entries[0].contentRect.width;
117
+ this._updateCollapsed();
118
+ });
119
+ }
120
+
121
+ connectedCallback() {
122
+ super.connectedCallback();
123
+ this._resizeObserver.observe(this);
124
+ }
125
+
126
+ disconnectedCallback() {
127
+ super.disconnectedCallback();
128
+ this._resizeObserver.disconnect();
129
+ }
130
+
131
+ updated(changedProperties) {
132
+ if (changedProperties.has('breakpoint')) {
133
+ this._updateCollapsed();
134
+ }
135
+ }
136
+
137
+ _updateCollapsed() {
138
+ if (this._width === null) return;
139
+ this.collapsed = this.breakpoint > 0 && this._width < this.breakpoint;
140
+ }
141
+
142
+ render() {
143
+ const hasHeader = this.label || this.description || this._hasLabelSlot;
144
+ return html`
145
+ <div
146
+ class="group"
147
+ role="group"
148
+ aria-labelledby=${this.label || this._hasLabelSlot ? 'label' : nothing}
149
+ aria-describedby=${this.description ? 'description' : nothing}
150
+ >
151
+ <header ?hidden=${!hasHeader}>
152
+ ${this.labelTemplate}
153
+ ${this.description ? html`<p id="description" class="description">${this.description}</p>` : ''}
154
+ </header>
155
+ <div class="split ${this._hasSplitContent ? 'has-content' : ''}">
156
+ <div class="split-column"><slot name="left" @slotchange=${this._onSplitSlotChange}></slot></div>
157
+ <div class="split-column"><slot name="right" @slotchange=${this._onSplitSlotChange}></slot></div>
158
+ </div>
159
+ <div class="grid">
160
+ <slot></slot>
161
+ </div>
162
+ </div>
163
+ `;
164
+ }
165
+
166
+ get labelTemplate() {
167
+ const useHeadingRole = this.labelLevel && !this._hasLabelSlot;
168
+ return html`
169
+ <div
170
+ id="label"
171
+ class="label"
172
+ role=${useHeadingRole ? 'heading' : nothing}
173
+ aria-level=${useHeadingRole ? this.labelLevel : nothing}
174
+ >
175
+ <slot name="label" @slotchange=${this._onLabelSlotChange}>${this.label}</slot>
176
+ </div>
177
+ `;
178
+ }
179
+
180
+ _onSplitSlotChange() {
181
+ const slots = this.shadowRoot.querySelectorAll('slot[name="left"], slot[name="right"]');
182
+ this._hasSplitContent = [...slots].some((slot) => slot.assignedNodes().length > 0);
183
+ }
184
+
185
+ _onLabelSlotChange(e) {
186
+ this._hasLabelSlot = e.target.assignedNodes().length > 0;
187
+ }
188
+ }
@@ -1,6 +1,6 @@
1
1
  import { LitElement, html, css } from 'lit';
2
2
  import { ifDefined } from 'lit/directives/if-defined.js';
3
- import { DileEmmitChange, DileFieldMessage } from '../../../mixins/form/index.js';
3
+ import { DileEmmitChange, DileFieldMessage, FIELD_MESSAGE_ID } from '../../../mixins/form/index.js';
4
4
  import { labelStyles } from './label-styles.js';
5
5
  import { messageStyles } from './message-styles.js';
6
6
 
@@ -44,6 +44,9 @@ export class DileInput extends DileFieldMessage(DileEmmitChange(LitElement)) {
44
44
  /** Disable the autocomplete of the input field */
45
45
  disableAutocomplete: { type: Boolean },
46
46
 
47
+ /** Value of the autocomplete attribute of the input field (e.g. "email", "new-password"). Defaults to "on". Ignored when disableAutocomplete is set */
48
+ autocomplete: { type: String },
49
+
47
50
  /** ReadOnly attribute */
48
51
  readonly: { type: Boolean },
49
52
 
@@ -58,6 +61,9 @@ export class DileInput extends DileFieldMessage(DileEmmitChange(LitElement)) {
58
61
 
59
62
  /** Set the application focus to this the input component after the initialization */
60
63
  focusOnStart: { type: Boolean },
64
+
65
+ /** Disabled state inherited from an ancestor fieldset or form */
66
+ _formDisabled: { state: true },
61
67
  };
62
68
  }
63
69
 
@@ -76,9 +82,21 @@ export class DileInput extends DileFieldMessage(DileEmmitChange(LitElement)) {
76
82
  this.name = '';
77
83
  this.type = 'text';
78
84
  this.types = ['text', 'password', 'email', 'number', 'tel', 'url', 'search', 'date', 'time', 'datetime', 'datetime-local', 'month', 'week'];
85
+ this._formDisabled = false;
79
86
  this.internals = this.attachInternals();
80
87
  }
81
88
 
89
+ /** Called by the browser when the owner form is reset: restores the value of the value attribute */
90
+ formResetCallback() {
91
+ this.value = this.getAttribute('value') ?? '';
92
+ this.clearError();
93
+ }
94
+
95
+ /** Called by the browser when an ancestor fieldset or form is disabled or enabled */
96
+ formDisabledCallback(disabled) {
97
+ this._formDisabled = disabled;
98
+ }
99
+
82
100
  firstUpdated() {
83
101
  if(this.focusOnStart) {
84
102
  this.focus();
@@ -88,7 +106,7 @@ export class DileInput extends DileFieldMessage(DileEmmitChange(LitElement)) {
88
106
  updated(changedProperties) {
89
107
  if(changedProperties.has('value')) {
90
108
  this.emmitChange();
91
- this.internals.setFormValue(this.value);
109
+ this.internals.setFormValue(this.value ?? '');
92
110
  }
93
111
  }
94
112
 
@@ -156,36 +174,99 @@ export class DileInput extends DileFieldMessage(DileEmmitChange(LitElement)) {
156
174
  render() {
157
175
  return html`
158
176
  <main>
159
- ${this.label
160
- ? html`<label for="textField">${this.label}</label>`
161
- : ""}
162
- <section class="for-input">
163
- <input
164
- type="${this.availableType(this.type)}"
165
- id="textField"
166
- name="${this.name}"
167
- aria-label="${ifDefined(this.inputAriaLabel)}"
168
- placeholder="${this.placeholder}"
169
- ?disabled="${this.disabled}"
170
- ?readonly="${this.readonly}"
171
- autocomplete="${this.disableAutocomplete ? "off" : "on"}"
172
- .value="${this.computeValue(this.value)}"
173
- class="${this.errored ? 'errored' : ''}"
174
- @keypress="${this._lookForEnter}"
175
- @input="${this._input}"
176
- @blur="${this.doBlur}"
177
- @focus="${this.doFocus}"
178
- />
179
- ${this.labelRight
180
- ? html`<span class="labelright">${this.labelRight}</span>`
181
- : ''
182
- }
177
+ ${this.labelTemplate}
178
+ <section class="for-input">
179
+ ${this.fieldStartTemplate}
180
+ ${this.inputTemplate}
181
+ ${this.fieldEndTemplate}
182
+ ${this.labelRightTemplate}
183
183
  </section>
184
184
  ${this.messageTemplate}
185
185
  </main>
186
186
  `;
187
187
  }
188
188
 
189
+ /** Template of the visible label. Override to customize it. */
190
+ get labelTemplate() {
191
+ return this.label
192
+ ? html`<label for="textField">${this.label}</label>`
193
+ : '';
194
+ }
195
+
196
+ /**
197
+ * Template of the native input. Subclasses should reuse it instead of copying it,
198
+ * customizing it through `inputType`, `computeValue()`, `computeAutocomplete()`,
199
+ * `inputModeValue` and the event handlers (`_input`, `doKeydown`, `doBlur`, `doFocus`).
200
+ */
201
+ get inputTemplate() {
202
+ return html`
203
+ <input
204
+ type="${this.inputType}"
205
+ id="textField"
206
+ name="${this.name}"
207
+ inputmode="${ifDefined(this.inputModeValue)}"
208
+ aria-label="${ifDefined(this.inputAriaLabel)}"
209
+ aria-invalid="${ifDefined(this.errored ? 'true' : undefined)}"
210
+ aria-describedby="${ifDefined(this.messageDescribedBy)}"
211
+ placeholder="${this.placeholder}"
212
+ ?disabled="${this.isDisabled}"
213
+ ?readonly="${this.readonly}"
214
+ autocomplete="${this.computeAutocomplete()}"
215
+ .value="${this.computeValue(this.value)}"
216
+ class="${this.errored ? 'errored' : ''}"
217
+ @keypress="${this._lookForEnter}"
218
+ @keydown="${this.doKeydown}"
219
+ @input="${this._input}"
220
+ @blur="${this.doBlur}"
221
+ @focus="${this.doFocus}"
222
+ />
223
+ `;
224
+ }
225
+
226
+ /** Content placed inside the field row, before the input (e.g. a prefix selector) */
227
+ get fieldStartTemplate() {
228
+ return '';
229
+ }
230
+
231
+ /** Content placed inside the field row, after the input (e.g. an action button) */
232
+ get fieldEndTemplate() {
233
+ return '';
234
+ }
235
+
236
+ get labelRightTemplate() {
237
+ return this.labelRight
238
+ ? html`<span class="labelright">${this.labelRight}</span>`
239
+ : '';
240
+ }
241
+
242
+ /** Type applied to the native input */
243
+ get inputType() {
244
+ return this.availableType(this.type);
245
+ }
246
+
247
+ /** inputmode applied to the native input. Undefined means no attribute. */
248
+ get inputModeValue() {
249
+ return undefined;
250
+ }
251
+
252
+ /** Value of the autocomplete attribute of the native input */
253
+ computeAutocomplete() {
254
+ if (this.disableAutocomplete) {
255
+ return 'off';
256
+ }
257
+ return this.autocomplete || 'on';
258
+ }
259
+
260
+ /** True when the field is disabled by its own property or by a disabled ancestor fieldset/form */
261
+ get isDisabled() {
262
+ return this.disabled || this._formDisabled;
263
+ }
264
+
265
+ /** Id of the element describing the input (the message), if any */
266
+ get messageDescribedBy() {
267
+ return this.message ? FIELD_MESSAGE_ID : undefined;
268
+ }
269
+
189
270
  /** aria-label for the inner input: accessibleLabel, only when there is no visible label */
190
271
  get inputAriaLabel() {
191
272
  return !this.label && this.accessibleLabel ? this.accessibleLabel : undefined;
@@ -215,7 +296,12 @@ export class DileInput extends DileFieldMessage(DileEmmitChange(LitElement)) {
215
296
  }
216
297
 
217
298
  get el() {
218
- return this.shadowRoot.querySelector('input');
299
+ return this.shadowRoot?.querySelector('input') ?? null;
300
+ }
301
+
302
+ /** Hook for the keydown event of the native input */
303
+ doKeydown() {
304
+ //
219
305
  }
220
306
 
221
307
  doBlur() {
@@ -229,10 +315,15 @@ export class DileInput extends DileFieldMessage(DileEmmitChange(LitElement)) {
229
315
  }
230
316
 
231
317
  computeValue(value) {
232
- return value;
318
+ return value ?? '';
233
319
  }
234
320
 
235
- focus() {
236
- this.el.focus();
321
+ /** Moves the focus to the native input. Waits for the first render if needed. */
322
+ focus(options) {
323
+ if (this.el) {
324
+ this.el.focus(options);
325
+ } else {
326
+ this.updateComplete.then(() => this.el?.focus(options));
327
+ }
237
328
  }
238
329
  }
@@ -1,7 +1,16 @@
1
- import { LitElement, html, css } from 'lit';
2
- import { ifDefined } from 'lit/directives/if-defined.js';
3
- import { DileInput } from '../../input/index.js';
1
+ import { html } from 'lit';
2
+ import { DileInput } from './DileInput.js';
3
+ import { FIELD_MESSAGE_ID } from '../../../mixins/form/index.js';
4
4
 
5
+ let deprecationWarned = false;
6
+
7
+ /**
8
+ * Input that validates Spanish phone / mobile / fax numbers or an email on blur.
9
+ *
10
+ * @deprecated Not maintained and not documented publicly. It will be removed in a future
11
+ * major version. Use `dile-input-phone` (from `@dile/utils`) for phone numbers and
12
+ * `dile-input` with `type="email"` plus form validation for emails.
13
+ */
5
14
  export class DileInputContact extends DileInput {
6
15
 
7
16
  static get properties() {
@@ -20,6 +29,14 @@ export class DileInputContact extends DileInput {
20
29
  this.valid = true;
21
30
  }
22
31
 
32
+ connectedCallback() {
33
+ super.connectedCallback();
34
+ if (!deprecationWarned) {
35
+ deprecationWarned = true;
36
+ console.warn('dile-input-contact is deprecated and will be removed in a future major version. Use dile-input-phone (@dile/utils) for phone numbers or dile-input type="email" for emails.');
37
+ }
38
+ }
39
+
23
40
  firstUpdated() {
24
41
  super.firstUpdated();
25
42
  if(this.value !== '' && this.value !== undefined) {
@@ -27,48 +44,26 @@ export class DileInputContact extends DileInput {
27
44
  }
28
45
  }
29
46
 
30
- render() {
31
- return html`
32
- <div>
33
- ${this.label ? this.renderLabel : ''}
34
- ${this.renderInput}
35
- ${this.errored && this.messageError != '' ? this.renderMsgError : ''}
36
- </div>
37
- `;
47
+ /** Shows messageError while the value is not valid, otherwise the regular message */
48
+ get messageTemplate() {
49
+ if (this.showMessageError) {
50
+ return html`
51
+ <div id="${FIELD_MESSAGE_ID}" class="message errored-msg"><span>${this.messageError}</span></div>
52
+ `;
53
+ }
54
+ return super.messageTemplate;
38
55
  }
39
56
 
40
- get renderLabel() {
41
- return html`
42
- <label for="textField">${this.label}</label>
43
- `;
57
+ get showMessageError() {
58
+ return this.errored && !!this.messageError;
44
59
  }
45
60
 
46
- get renderInput() {
47
- return html`
48
- <input
49
- type="${this.availableType(this.type)}"
50
- id="textField"
51
- name="${this.name}"
52
- aria-label="${ifDefined(this.inputAriaLabel)}"
53
- placeholder="${this.placeholder}"
54
- ?disabled="${this.disabled}"
55
- ?readonly="${this.readonly}"
56
- autocomplete="${this.disableAutocomplete ? "off" : "on"}"
57
- .value="${this.computeValue(this.value)}"
58
- class="${this.errored ? 'errored' : ''}"
59
- @keypress="${this._lookForEnter}"
60
- @input="${this._input}"
61
- @blur="${this._isValidInput}"
62
- @focus="${this.doFocus}"
63
- >
64
- </input>
65
- `;
61
+ get messageDescribedBy() {
62
+ return this.showMessageError ? FIELD_MESSAGE_ID : super.messageDescribedBy;
66
63
  }
67
64
 
68
- get renderMsgError() {
69
- return html`
70
- <div class="message ${this.errored ? 'errored-msg' : ''}"><span>${this.messageError}</span></div>
71
- `;
65
+ doBlur() {
66
+ this._isValidInput();
72
67
  }
73
68
 
74
69
  _input(ev) {
@@ -80,6 +75,9 @@ export class DileInputContact extends DileInput {
80
75
  value: this.value
81
76
  }
82
77
  }));
78
+ if (this.hideErrorOnInput && this.errored) {
79
+ this.clearError();
80
+ }
83
81
  }
84
82
 
85
83
  _isValidInput() {
@@ -105,6 +103,7 @@ export class DileInputContact extends DileInput {
105
103
  this.valid = false;
106
104
  }
107
105
  } else if(this.email) {
106
+ this._isMail = true;
108
107
  if(reMail.test(this.value) || this.value === ""){
109
108
  this.valid = true;
110
109
  }else{
@@ -113,7 +112,6 @@ export class DileInputContact extends DileInput {
113
112
  }
114
113
  }
115
114
  this.errored = !this.valid;
116
- console.log("Válido: " + this.valid);
117
115
  this.dispatchEvent(
118
116
  new CustomEvent('dile-input-contact-blur', {
119
117
  bubbles: true,