feat(searchbar): add inputmode property (#18980)

This commit is contained in:
Simon
2019-08-08 20:13:34 +02:00
committed by Manu MA
parent 3c925bb27e
commit 1187dc2fc7
10 changed files with 71 additions and 26 deletions

View File

@ -676,7 +676,7 @@ export class IonRow {
}
export declare interface IonSearchbar extends Components.IonSearchbar {}
@Component({ selector: 'ion-searchbar', changeDetection: ChangeDetectionStrategy.OnPush, template: '<ng-content></ng-content>', inputs: ['animated', 'autocomplete', 'autocorrect', 'cancelButtonIcon', 'cancelButtonText', 'clearIcon', 'color', 'debounce', 'disabled', 'mode', 'placeholder', 'searchIcon', 'showCancelButton', 'spellcheck', 'type', 'value'] })
@Component({ selector: 'ion-searchbar', changeDetection: ChangeDetectionStrategy.OnPush, template: '<ng-content></ng-content>', inputs: ['animated', 'autocomplete', 'autocorrect', 'cancelButtonIcon', 'cancelButtonText', 'clearIcon', 'color', 'debounce', 'disabled', 'inputmode', 'mode', 'placeholder', 'searchIcon', 'showCancelButton', 'spellcheck', 'type', 'value'] })
export class IonSearchbar {
ionInput!: EventEmitter<CustomEvent>;
ionChange!: EventEmitter<CustomEvent>;
@ -692,7 +692,7 @@ export class IonSearchbar {
}
}
proxyMethods(IonSearchbar, ['setFocus', 'getInputElement']);
proxyInputs(IonSearchbar, ['animated', 'autocomplete', 'autocorrect', 'cancelButtonIcon', 'cancelButtonText', 'clearIcon', 'color', 'debounce', 'disabled', 'mode', 'placeholder', 'searchIcon', 'showCancelButton', 'spellcheck', 'type', 'value']);
proxyInputs(IonSearchbar, ['animated', 'autocomplete', 'autocorrect', 'cancelButtonIcon', 'cancelButtonText', 'clearIcon', 'color', 'debounce', 'disabled', 'inputmode', 'mode', 'placeholder', 'searchIcon', 'showCancelButton', 'spellcheck', 'type', 'value']);
export declare interface IonSegment extends Components.IonSegment {}
@Component({ selector: 'ion-segment', changeDetection: ChangeDetectionStrategy.OnPush, template: '<ng-content></ng-content>', inputs: ['color', 'disabled', 'mode', 'scrollable', 'value'] })

View File

@ -951,6 +951,7 @@ ion-searchbar,prop,clearIcon,string | undefined,undefined,false,false
ion-searchbar,prop,color,string | undefined,undefined,false,false
ion-searchbar,prop,debounce,number,250,false,false
ion-searchbar,prop,disabled,boolean,false,false,false
ion-searchbar,prop,inputmode,"decimal" | "email" | "none" | "numeric" | "search" | "tel" | "text" | "url",'search',false,false
ion-searchbar,prop,mode,"ios" | "md",undefined,false,false
ion-searchbar,prop,placeholder,string,'Search',false,false
ion-searchbar,prop,searchIcon,string,'search',false,false

View File

@ -2182,6 +2182,10 @@ export namespace Components {
*/
'getInputElement': () => Promise<HTMLInputElement>;
/**
* A hint to the browser for which keyboard to display. Possible values are: `"none"` | `"text"` | `"tel"` | `"url"` | `"email"` | `"numeric"` | `"decimal"` | `"search"`.
*/
'inputmode': 'none' | 'text' | 'tel' | 'url' | 'email' | 'numeric' | 'decimal' | 'search';
/**
* The mode determines which platform styles to use.
*/
'mode'?: "ios" | "md";
@ -5440,6 +5444,10 @@ declare namespace LocalJSX {
*/
'disabled'?: boolean;
/**
* A hint to the browser for which keyboard to display. Possible values are: `"none"` | `"text"` | `"tel"` | `"url"` | `"email"` | `"numeric"` | `"decimal"` | `"search"`.
*/
'inputmode'?: 'none' | 'text' | 'tel' | 'url' | 'email' | 'numeric' | 'decimal' | 'search';
/**
* The mode determines which platform styles to use.
*/
'mode'?: "ios" | "md";

View File

@ -35,6 +35,9 @@ A Searchbar should be used instead of an input to search lists. A clear button i
<!-- Searchbar with telephone type -->
<ion-searchbar type="tel"></ion-searchbar>
<!-- Searchbar with numeric inputmode -->
<ion-searchbar inputmode="numeric"></ion-searchbar>
<!-- Searchbar disabled -->
<ion-searchbar disabled="true"></ion-searchbar>
@ -81,6 +84,9 @@ A Searchbar should be used instead of an input to search lists. A clear button i
<!-- Searchbar with telephone type -->
<ion-searchbar type="tel"></ion-searchbar>
<!-- Searchbar with numeric inputmode -->
<ion-searchbar inputmode="numeric"></ion-searchbar>
<!-- Searchbar disabled -->
<ion-searchbar disabled="true"></ion-searchbar>
@ -132,6 +138,9 @@ export const SearchbarExample: React.FunctionComponent = () => (
{/*-- Searchbar with telephone type --*/}
<IonSearchbar type="tel"></IonSearchbar>
{/*-- Searchbar with numeric inputmode --*/}
<IonSearchbar inputmode="numeric"></IonSearchbar>
{/*-- Searchbar disabled --*/}
<IonSearchbar disabled={true}></IonSearchbar>
@ -181,6 +190,9 @@ export const SearchbarExample: React.FunctionComponent = () => (
<!-- Searchbar with telephone type -->
<ion-searchbar type="tel"></ion-searchbar>
<!-- Searchbar with numeric inputmode -->
<ion-searchbar inputmode="numeric"></ion-searchbar>
<!-- Searchbar disabled -->
<ion-searchbar disabled="true"></ion-searchbar>
@ -208,7 +220,7 @@ export const SearchbarExample: React.FunctionComponent = () => (
## Properties
| Property | Attribute | Description | Type | Default |
| ------------------ | -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------- | ----------------- |
| ------------------ | -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | ----------------- |
| `animated` | `animated` | If `true`, enable searchbar animation. | `boolean` | `false` |
| `autocomplete` | `autocomplete` | Set the input's autocomplete property. | `"off" \| "on"` | `'off'` |
| `autocorrect` | `autocorrect` | Set the input's autocorrect property. | `"off" \| "on"` | `'off'` |
@ -218,6 +230,7 @@ export const SearchbarExample: React.FunctionComponent = () => (
| `color` | `color` | The color to use from your application's color palette. Default options are: `"primary"`, `"secondary"`, `"tertiary"`, `"success"`, `"warning"`, `"danger"`, `"light"`, `"medium"`, and `"dark"`. For more information on colors, see [theming](/docs/theming/basics). | `string \| undefined` | `undefined` |
| `debounce` | `debounce` | Set the amount of time, in milliseconds, to wait to trigger the `ionChange` event after each keystroke. | `number` | `250` |
| `disabled` | `disabled` | If `true`, the user cannot interact with the input. | `boolean` | `false` |
| `inputmode` | `inputmode` | A hint to the browser for which keyboard to display. Possible values are: `"none"` \| `"text"` \| `"tel"` \| `"url"` \| `"email"` \| `"numeric"` \| `"decimal"` \| `"search"`. | `"decimal" \| "email" \| "none" \| "numeric" \| "search" \| "tel" \| "text" \| "url"` | `'search'` |
| `mode` | `mode` | The mode determines which platform styles to use. | `"ios" \| "md"` | `undefined` |
| `placeholder` | `placeholder` | Set the input's placeholder. `placeholder` can accept either plaintext or HTML as a string. To display characters normally reserved for HTML, they must be escaped. For example `<Ionic>` would become `&lt;Ionic&gt;` For more information: [Security Documentation](https://ionicframework.com/docs/faq/security) | `string` | `'Search'` |
| `searchIcon` | `search-icon` | The icon to use as the search icon. | `string` | `'search'` |

View File

@ -81,6 +81,12 @@ export class Searchbar implements ComponentInterface {
*/
@Prop() disabled = false;
/**
* A hint to the browser for which keyboard to display.
* Possible values are: `"none"` | `"text"` | `"tel"` | `"url"` | `"email"` | `"numeric"` | `"decimal"` | `"search"`.
*/
@Prop() inputmode: 'none' | 'text' | 'tel' | 'url' | 'email' | 'numeric' | 'decimal' | 'search' = 'search';
/**
* Set the input's placeholder.
* `placeholder` can accept either plaintext or HTML as a string.
@ -442,6 +448,7 @@ export class Searchbar implements ComponentInterface {
disabled={this.disabled}
ref={el => this.nativeInput = el}
class="searchbar-input"
inputMode={this.inputmode}
onInput={this.onInput}
onBlur={this.onBlur}
onFocus={this.onFocus}

View File

@ -49,6 +49,10 @@
<ion-searchbar id="noCancel" value="after view" autocorrect="off" autocomplete="off" spellcheck="true" type="text" show-cancel-button="focus">
</ion-searchbar>
<h5 class="ion-padding-start ion-padding-top"> Search - Input mode set to numeric</h5>
<ion-searchbar id="noCancel" value="after view" inputmode="numeric" autocorrect="off" autocomplete="off" spellcheck="true" type="text" show-cancel-button="focus">
</ion-searchbar>
<h5 class="ion-padding-start ion-padding-top"> Search - Disabled </h5>
<ion-searchbar id="disabled" value="disabled" type="text" disabled="true">
</ion-searchbar>

View File

@ -20,6 +20,9 @@
<!-- Searchbar with telephone type -->
<ion-searchbar type="tel"></ion-searchbar>
<!-- Searchbar with numeric inputmode -->
<ion-searchbar inputmode="numeric"></ion-searchbar>
<!-- Searchbar disabled -->
<ion-searchbar disabled="true"></ion-searchbar>

View File

@ -20,6 +20,9 @@
<!-- Searchbar with telephone type -->
<ion-searchbar type="tel"></ion-searchbar>
<!-- Searchbar with numeric inputmode -->
<ion-searchbar inputmode="numeric"></ion-searchbar>
<!-- Searchbar disabled -->
<ion-searchbar disabled="true"></ion-searchbar>

View File

@ -25,6 +25,9 @@ export const SearchbarExample: React.FunctionComponent = () => (
{/*-- Searchbar with telephone type --*/}
<IonSearchbar type="tel"></IonSearchbar>
{/*-- Searchbar with numeric inputmode --*/}
<IonSearchbar inputmode="numeric"></IonSearchbar>
{/*-- Searchbar disabled --*/}
<IonSearchbar disabled={true}></IonSearchbar>

View File

@ -21,6 +21,9 @@
<!-- Searchbar with telephone type -->
<ion-searchbar type="tel"></ion-searchbar>
<!-- Searchbar with numeric inputmode -->
<ion-searchbar inputmode="numeric"></ion-searchbar>
<!-- Searchbar disabled -->
<ion-searchbar disabled="true"></ion-searchbar>