All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.src.vaadin-text-field.js Maven / Gradle / Ivy

/**
 * @license
 * Copyright (c) 2017 - 2024 Vaadin Ltd.
 * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
 */
import '@vaadin/input-container/src/vaadin-input-container.js';
import { html, PolymerElement } from '@polymer/polymer';
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
import { TooltipController } from '@vaadin/component-base/src/tooltip-controller.js';
import { inputFieldShared } from '@vaadin/field-base/src/styles/input-field-shared-styles.js';
import { registerStyles, ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
import { TextFieldMixin } from './vaadin-text-field-mixin.js';

registerStyles('vaadin-text-field', inputFieldShared, { moduleId: 'vaadin-text-field-styles' });

/**
 * `` is a web component that allows the user to input and edit text.
 *
 * ```html
 * 
 * ```
 *
 * ### Prefixes and suffixes
 *
 * These are child elements of a `` that are displayed
 * inline with the input, before or after.
 * In order for an element to be considered as a prefix, it must have the slot
 * attribute set to `prefix` (and similarly for `suffix`).
 *
 * ```html
 * 
 *   
Sent to:
*
@vaadin.com
*
* ``` * * ### Styling * * The following custom properties are available for styling: * * Custom property | Description | Default * -------------------------------|----------------------------|--------- * `--vaadin-field-default-width` | Default width of the field | `12em` * * The following shadow DOM parts are available for styling: * * Part name | Description * ---------------------|---------------- * `label` | The label element * `input-field` | The element that wraps prefix, value and suffix * `clear-button` | The clear button * `error-message` | The error message element * `helper-text` | The helper text element wrapper * `required-indicator` | The `required` state indicator element * * The following state attributes are available for styling: * * Attribute | Description | Part name * --------------------|-------------|------------ * `disabled` | Set to a disabled text field | :host * `has-value` | Set when the element has a value | :host * `has-label` | Set when the element has a label | :host * `has-helper` | Set when the element has helper text or slot | :host * `has-error-message` | Set when the element has an error message | :host * `invalid` | Set when the element is invalid | :host * `input-prevented` | Temporarily set when invalid input is prevented | :host * `focused` | Set when the element is focused | :host * `focus-ring` | Set when the element is keyboard focused | :host * `readonly` | Set to a readonly text field | :host * * See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation. * * @fires {Event} input - Fired when the value is changed by the user: on every typing keystroke, and the value is cleared using the clear button. * @fires {Event} change - Fired when the user commits a value change. * @fires {CustomEvent} invalid-changed - Fired when the `invalid` property changes. * @fires {CustomEvent} value-changed - Fired when the `value` property changes. * @fires {CustomEvent} validated - Fired whenever the field is validated. * * @customElement * @extends HTMLElement * @mixes ElementMixin * @mixes ThemableMixin * @mixes TextFieldMixin */ export class TextField extends TextFieldMixin(ThemableMixin(ElementMixin(PolymerElement))) { static get is() { return 'vaadin-text-field'; } static get template() { return html`
`; } static get properties() { return { /** * Maximum number of characters (in Unicode code points) that the user can enter. */ maxlength: { type: Number, }, /** * Minimum number of characters (in Unicode code points) that the user can enter. */ minlength: { type: Number, }, }; } /** @protected */ ready() { super.ready(); this._tooltipController = new TooltipController(this); this._tooltipController.setPosition('top'); this._tooltipController.setAriaTarget(this.inputElement); this.addController(this._tooltipController); } } defineCustomElement(TextField);




© 2015 - 2024 Weber Informatics LLC | Privacy Policy