feat(input): add getInputElement() (#17183)

expose internal <input> element

fixes #17174
This commit is contained in:
Manu MA
2019-01-21 17:19:40 +01:00
committed by GitHub
parent cf9f53b833
commit a90084c077
9 changed files with 72 additions and 3 deletions

View File

@ -1644,6 +1644,10 @@ export namespace Components {
*/
'disabled': boolean;
/**
* Returns the native `<input>` element used under the hood.
*/
'getInputElement': () => Promise<HTMLInputElement>;
/**
* A hint to the browser for which keyboard to display. This attribute applies when the value of the type attribute is `"text"`, `"password"`, `"email"`, or `"url"`. Possible values are: `"verbatim"`, `"latin"`, `"latin-name"`, `"latin-prose"`, `"full-width-latin"`, `"kana"`, `"katakana"`, `"numeric"`, `"tel"`, `"email"`, `"url"`.
*/
'inputmode'?: string;
@ -3692,6 +3696,10 @@ export namespace Components {
*/
'debounce': number;
/**
* Returns the native `<input>` element used under the hood.
*/
'getInputElement': () => Promise<HTMLInputElement>;
/**
* The mode determines which platform styles to use.
*/
'mode': Mode;
@ -4531,6 +4539,10 @@ export namespace Components {
*/
'disabled': boolean;
/**
* Returns the native `<textarea>` element used under the hood.
*/
'getInputElement': () => Promise<HTMLTextAreaElement>;
/**
* If the value of the type attribute is `text`, `email`, `search`, `password`, `tel`, or `url`, this attribute specifies the maximum number of characters that the user can enter.
*/
'maxlength'?: number;

View File

@ -247,6 +247,14 @@ export class Input implements ComponentInterface {
}
}
/**
* Returns the native `<input>` element used under the hood.
*/
@Method()
getInputElement(): Promise<HTMLInputElement> {
return Promise.resolve(this.nativeInput!);
}
private getValue(): string {
return this.value || '';
}

View File

@ -150,6 +150,16 @@ It is meant for text `type` inputs only, such as `"text"`, `"password"`, `"email
## Methods
### `getInputElement() => Promise<HTMLInputElement>`
Returns the native `<input>` element used under the hood.
#### Returns
Type: `Promise<HTMLInputElement>`
### `setFocus() => void`
Sets focus on the specified `ion-input`. Use this method instead of the global

View File

@ -115,6 +115,16 @@ A Searchbar should be used instead of an input to search lists. A clear button i
## Methods
### `getInputElement() => Promise<HTMLInputElement>`
Returns the native `<input>` element used under the hood.
#### Returns
Type: `Promise<HTMLInputElement>`
### `setFocus() => void`
Sets focus on the specified `ion-searchbar`. Use this method instead of the global

View File

@ -168,6 +168,14 @@ export class Searchbar implements ComponentInterface {
}
}
/**
* Returns the native `<input>` element used under the hood.
*/
@Method()
getInputElement(): Promise<HTMLInputElement> {
return Promise.resolve(this.nativeInput!);
}
/**
* Clears the input field and triggers the control change.
*/

View File

@ -132,6 +132,16 @@ The textarea component accepts the [native textarea attributes](https://develope
## Methods
### `getInputElement() => Promise<HTMLTextAreaElement>`
Returns the native `<textarea>` element used under the hood.
#### Returns
Type: `Promise<HTMLTextAreaElement>`
### `setFocus() => void`
Sets focus on the specified `ion-textarea`. Use this method instead of the global

View File

@ -182,6 +182,14 @@ export class Textarea implements ComponentInterface {
}
}
/**
* Returns the native `<textarea>` element used under the hood.
*/
@Method()
getInputElement(): Promise<HTMLTextAreaElement> {
return Promise.resolve(this.nativeInput!);
}
private emitStyle() {
this.ionStyle.emit({
'interactive': true,