mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
feat(searchbar): add inputmode property (#18980)
This commit is contained in:
8
core/src/components.d.ts
vendored
8
core/src/components.d.ts
vendored
@@ -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";
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -113,13 +119,13 @@ export const SearchbarExample: React.FunctionComponent = () => (
|
||||
<IonContent>
|
||||
{/*-- Default Searchbar --*/}
|
||||
<IonSearchbar></IonSearchbar>
|
||||
|
||||
|
||||
{/*-- Searchbar with cancel button always shown --*/}
|
||||
<IonSearchbar showCancelButton="always"></IonSearchbar>
|
||||
|
||||
|
||||
{/*-- Searchbar with cancel button never shown --*/}
|
||||
<IonSearchbar showCancelButton="never"></IonSearchbar>
|
||||
|
||||
|
||||
{/*-- Searchbar with cancel button shown on focus --*/}
|
||||
<IonSearchbar showCancelButton="focus"></IonSearchbar>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -207,24 +219,25 @@ 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'` |
|
||||
| `cancelButtonIcon` | `cancel-button-icon` | Set the cancel button icon. Only applies to `md` mode. | `string` | `'md-arrow-back'` |
|
||||
| `cancelButtonText` | `cancel-button-text` | Set the the cancel button text. Only applies to `ios` mode. | `string` | `'Cancel'` |
|
||||
| `clearIcon` | `clear-icon` | Set the clear icon. Defaults to `"close-circle"` for `ios` and `"close"` for `md`. | `string \| undefined` | `undefined` |
|
||||
| `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` |
|
||||
| `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 `<Ionic>` 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'` |
|
||||
| `showCancelButton` | `show-cancel-button` | Sets the behavior for the cancel button. Defaults to `"never"`. Setting to `"focus"` shows the cancel button on focus. Setting to `"never"` hides the cancel button. Setting to `"always"` shows the cancel button regardless of focus state. | `boolean \| string` | `'never'` |
|
||||
| `spellcheck` | `spellcheck` | If `true`, enable spellcheck on the input. | `boolean` | `false` |
|
||||
| `type` | `type` | Set the type of the input. | `"email" \| "number" \| "password" \| "search" \| "tel" \| "text" \| "url"` | `'search'` |
|
||||
| `value` | `value` | the value of the searchbar. | `null \| string \| undefined` | `''` |
|
||||
| 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'` |
|
||||
| `cancelButtonIcon` | `cancel-button-icon` | Set the cancel button icon. Only applies to `md` mode. | `string` | `'md-arrow-back'` |
|
||||
| `cancelButtonText` | `cancel-button-text` | Set the the cancel button text. Only applies to `ios` mode. | `string` | `'Cancel'` |
|
||||
| `clearIcon` | `clear-icon` | Set the clear icon. Defaults to `"close-circle"` for `ios` and `"close"` for `md`. | `string \| undefined` | `undefined` |
|
||||
| `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 `<Ionic>` 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'` |
|
||||
| `showCancelButton` | `show-cancel-button` | Sets the behavior for the cancel button. Defaults to `"never"`. Setting to `"focus"` shows the cancel button on focus. Setting to `"never"` hides the cancel button. Setting to `"always"` shows the cancel button regardless of focus state. | `boolean \| string` | `'never'` |
|
||||
| `spellcheck` | `spellcheck` | If `true`, enable spellcheck on the input. | `boolean` | `false` |
|
||||
| `type` | `type` | Set the type of the input. | `"email" \| "number" \| "password" \| "search" \| "tel" \| "text" \| "url"` | `'search'` |
|
||||
| `value` | `value` | the value of the searchbar. | `null \| string \| undefined` | `''` |
|
||||
|
||||
|
||||
## Events
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -6,13 +6,13 @@ export const SearchbarExample: React.FunctionComponent = () => (
|
||||
<IonContent>
|
||||
{/*-- Default Searchbar --*/}
|
||||
<IonSearchbar></IonSearchbar>
|
||||
|
||||
|
||||
{/*-- Searchbar with cancel button always shown --*/}
|
||||
<IonSearchbar showCancelButton="always"></IonSearchbar>
|
||||
|
||||
|
||||
{/*-- Searchbar with cancel button never shown --*/}
|
||||
<IonSearchbar showCancelButton="never"></IonSearchbar>
|
||||
|
||||
|
||||
{/*-- Searchbar with cancel button shown on focus --*/}
|
||||
<IonSearchbar showCancelButton="focus"></IonSearchbar>
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user