|
1 | 1 | import { FormControlMixin, LabelMixin } from '@umbraco-ui/uui-base/lib/mixins';
|
2 | 2 | import { defineElement } from '@umbraco-ui/uui-base/lib/registration';
|
3 |
| -import { css, html, LitElement, nothing, PropertyValueMap } from 'lit'; |
| 3 | +import { css, html, LitElement, PropertyValueMap } from 'lit'; |
4 | 4 | import { property, query } from 'lit/decorators.js';
|
5 | 5 | import { ifDefined } from 'lit/directives/if-defined.js';
|
6 | 6 |
|
@@ -401,34 +401,41 @@ export class UUIInputElement extends FormControlMixin(
|
401 | 401 | render() {
|
402 | 402 | return html`
|
403 | 403 | ${this.renderPrepend()}
|
404 |
| - <div id="control"> |
405 |
| - <input |
406 |
| - id="input" |
407 |
| - .type=${this.type} |
408 |
| - .value=${this.value as string} |
409 |
| - .name=${this.name} |
410 |
| - pattern=${ifDefined(this.pattern)} |
411 |
| - min=${ifDefined(this.min)} |
412 |
| - max=${ifDefined(this.max)} |
413 |
| - step=${ifDefined(this.step)} |
414 |
| - spellcheck=${this.spellcheck} |
415 |
| - autocomplete=${ifDefined(this.autocomplete as any)} |
416 |
| - placeholder=${ifDefined(this.placeholder)} |
417 |
| - aria-label=${ifDefined(this.label)} |
418 |
| - inputmode=${ifDefined(this.inputMode)} |
419 |
| - ?disabled=${this.disabled} |
420 |
| - ?autofocus=${this.autofocus} |
421 |
| - ?required=${this.required} |
422 |
| - ?readonly=${this.readonly} |
423 |
| - @input=${this.onInput} |
424 |
| - @change=${this.onChange} /> |
425 |
| - ${this.autoWidth ? this.renderAutoWidth() : nothing} |
426 |
| - </div> |
| 404 | + ${this.autoWidth ? this.renderInputWithAutoWidth() : this.renderInput()} |
427 | 405 | ${this.renderAppend()}
|
428 | 406 | `;
|
429 | 407 | }
|
430 | 408 |
|
431 |
| - private renderAutoWidth() { |
| 409 | + private renderInputWithAutoWidth() { |
| 410 | + html`<div id="control"> |
| 411 | + ${this.renderInput()}${this.renderAutoWidthBackground()} |
| 412 | + </div>`; |
| 413 | + } |
| 414 | + |
| 415 | + renderInput() { |
| 416 | + return html`<input |
| 417 | + id="input" |
| 418 | + .type=${this.type} |
| 419 | + .value=${this.value as string} |
| 420 | + .name=${this.name} |
| 421 | + pattern=${ifDefined(this.pattern)} |
| 422 | + min=${ifDefined(this.min)} |
| 423 | + max=${ifDefined(this.max)} |
| 424 | + step=${ifDefined(this.step)} |
| 425 | + spellcheck=${this.spellcheck} |
| 426 | + autocomplete=${ifDefined(this.autocomplete as any)} |
| 427 | + placeholder=${ifDefined(this.placeholder)} |
| 428 | + aria-label=${ifDefined(this.label)} |
| 429 | + inputmode=${ifDefined(this.inputMode)} |
| 430 | + ?disabled=${this.disabled} |
| 431 | + ?autofocus=${this.autofocus} |
| 432 | + ?required=${this.required} |
| 433 | + ?readonly=${this.readonly} |
| 434 | + @input=${this.onInput} |
| 435 | + @change=${this.onChange} />`; |
| 436 | + } |
| 437 | + |
| 438 | + private renderAutoWidthBackground() { |
432 | 439 | return html` <div id="auto" aria-hidden="true">${this.renderText()}</div>`;
|
433 | 440 | }
|
434 | 441 |
|
|
0 commit comments