mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
Compare commits
1 Commits
sp/pnpm-re
...
sp/default
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1675a9b5de |
@@ -556,6 +556,7 @@ ion-input,prop,color,"danger" | "dark" | "light" | "medium" | "primary" | "secon
|
||||
ion-input,prop,counter,boolean,false,false,false
|
||||
ion-input,prop,counterFormatter,((inputLength: number, maxLength: number) => string) | undefined,undefined,false,false
|
||||
ion-input,prop,debounce,number | undefined,undefined,false,false
|
||||
ion-input,prop,defaultValue,null | number | string | undefined,this.getValue(),false,false
|
||||
ion-input,prop,disabled,boolean,false,false,false
|
||||
ion-input,prop,enterkeyhint,"done" | "enter" | "go" | "next" | "previous" | "search" | "send" | undefined,undefined,false,false
|
||||
ion-input,prop,errorText,string | undefined,undefined,false,false
|
||||
|
||||
10
core/src/components.d.ts
vendored
10
core/src/components.d.ts
vendored
@@ -17,7 +17,7 @@ import { CheckboxChangeEventDetail } from "./components/checkbox/checkbox-interf
|
||||
import { ScrollBaseDetail, ScrollDetail } from "./components/content/content-interface";
|
||||
import { DatetimeChangeEventDetail, DatetimeHighlight, DatetimeHighlightCallback, DatetimePresentation, TitleSelectedDatesFormatter } from "./components/datetime/datetime-interface";
|
||||
import { SpinnerTypes } from "./components/spinner/spinner-configs";
|
||||
import { InputChangeEventDetail, InputInputEventDetail } from "./components/input/input-interface";
|
||||
import { InputChangeEventDetail, InputInputEventDetail, InputValue } from "./components/input/input-interface";
|
||||
import { CounterFormatter } from "./components/item/item-interface";
|
||||
import { MenuChangeEventDetail, Side } from "./components/menu/menu-interface";
|
||||
import { ModalBreakpointChangeEventDetail, ModalHandleBehavior } from "./components/modal/modal-interface";
|
||||
@@ -53,7 +53,7 @@ export { CheckboxChangeEventDetail } from "./components/checkbox/checkbox-interf
|
||||
export { ScrollBaseDetail, ScrollDetail } from "./components/content/content-interface";
|
||||
export { DatetimeChangeEventDetail, DatetimeHighlight, DatetimeHighlightCallback, DatetimePresentation, TitleSelectedDatesFormatter } from "./components/datetime/datetime-interface";
|
||||
export { SpinnerTypes } from "./components/spinner/spinner-configs";
|
||||
export { InputChangeEventDetail, InputInputEventDetail } from "./components/input/input-interface";
|
||||
export { InputChangeEventDetail, InputInputEventDetail, InputValue } from "./components/input/input-interface";
|
||||
export { CounterFormatter } from "./components/item/item-interface";
|
||||
export { MenuChangeEventDetail, Side } from "./components/menu/menu-interface";
|
||||
export { ModalBreakpointChangeEventDetail, ModalHandleBehavior } from "./components/modal/modal-interface";
|
||||
@@ -1189,6 +1189,7 @@ export namespace Components {
|
||||
* Set the amount of time, in milliseconds, to wait to trigger the `ionInput` event after each keystroke.
|
||||
*/
|
||||
"debounce"?: number;
|
||||
"defaultValue"?: InputValue;
|
||||
/**
|
||||
* If `true`, the user cannot interact with the input.
|
||||
*/
|
||||
@@ -1297,7 +1298,7 @@ export namespace Components {
|
||||
/**
|
||||
* The value of the input.
|
||||
*/
|
||||
"value"?: string | number | null;
|
||||
"value"?: InputValue;
|
||||
}
|
||||
interface IonItem {
|
||||
/**
|
||||
@@ -5248,6 +5249,7 @@ declare namespace LocalJSX {
|
||||
* Set the amount of time, in milliseconds, to wait to trigger the `ionInput` event after each keystroke.
|
||||
*/
|
||||
"debounce"?: number;
|
||||
"defaultValue"?: InputValue;
|
||||
/**
|
||||
* If `true`, the user cannot interact with the input.
|
||||
*/
|
||||
@@ -5368,7 +5370,7 @@ declare namespace LocalJSX {
|
||||
/**
|
||||
* The value of the input.
|
||||
*/
|
||||
"value"?: string | number | null;
|
||||
"value"?: InputValue;
|
||||
}
|
||||
interface IonItem {
|
||||
/**
|
||||
|
||||
@@ -19,3 +19,5 @@ export interface InputCustomEvent<T = InputChangeEventDetail> extends CustomEven
|
||||
detail: T;
|
||||
target: HTMLIonInputElement;
|
||||
}
|
||||
|
||||
export type InputValue = string | number | null | undefined;
|
||||
|
||||
@@ -13,7 +13,7 @@ import { closeCircle, closeSharp } from 'ionicons/icons';
|
||||
import { getIonMode } from '../../global/ionic-global';
|
||||
import type { AutocompleteTypes, Color, StyleEventDetail, TextFieldTypes } from '../../interface';
|
||||
|
||||
import type { InputChangeEventDetail, InputInputEventDetail } from './input-interface';
|
||||
import type { InputChangeEventDetail, InputInputEventDetail, InputValue } from './input-interface';
|
||||
import { getCounterText } from './input.utils';
|
||||
|
||||
/**
|
||||
@@ -53,7 +53,7 @@ export class Input implements ComponentInterface {
|
||||
/**
|
||||
* The value of the input when the input is focused.
|
||||
*/
|
||||
private focusedValue?: string | number | null;
|
||||
private focusedValue?: InputValue;
|
||||
|
||||
@State() hasFocus = false;
|
||||
|
||||
@@ -279,7 +279,9 @@ export class Input implements ComponentInterface {
|
||||
/**
|
||||
* The value of the input.
|
||||
*/
|
||||
@Prop({ mutable: true }) value?: string | number | null = '';
|
||||
@Prop({ mutable: true }) value?: InputValue = '';
|
||||
|
||||
@Prop({ mutable: true }) defaultValue?: InputValue = this.getValue();
|
||||
|
||||
/**
|
||||
* The `ionInput` event is fired each time the user modifies the input's value.
|
||||
@@ -352,6 +354,11 @@ export class Input implements ComponentInterface {
|
||||
this.emitStyle();
|
||||
}
|
||||
|
||||
@Watch('defaultValue')
|
||||
protected defaultValueChanged(newValue: InputValue) {
|
||||
this.value = this.defaultValue = this.getValue(newValue);
|
||||
}
|
||||
|
||||
componentWillLoad() {
|
||||
this.inheritedAttributes = {
|
||||
...inheritAriaAttributes(this.el),
|
||||
@@ -383,6 +390,12 @@ export class Input implements ComponentInterface {
|
||||
|
||||
componentDidLoad() {
|
||||
this.originalIonInput = this.ionInput;
|
||||
|
||||
if (this.value === '' || this.value == null) {
|
||||
if (this.defaultValue !== '') {
|
||||
this.value = this.getValue(this.defaultValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
componentDidRender() {
|
||||
@@ -466,8 +479,8 @@ export class Input implements ComponentInterface {
|
||||
return clearOnEdit === undefined ? type === 'password' : clearOnEdit;
|
||||
}
|
||||
|
||||
private getValue(): string {
|
||||
return typeof this.value === 'number' ? this.value.toString() : (this.value || '').toString();
|
||||
private getValue(value = this.value): string {
|
||||
return typeof value === 'number' ? value.toString() : (value || '').toString();
|
||||
}
|
||||
|
||||
private emitStyle() {
|
||||
@@ -685,6 +698,7 @@ export class Input implements ComponentInterface {
|
||||
const { disabled, fill, readonly, shape, inputId, labelPlacement } = this;
|
||||
const mode = getIonMode(this);
|
||||
const value = this.getValue();
|
||||
const defaultValue = this.getValue(this.defaultValue);
|
||||
const inItem = hostContext('ion-item', this.el);
|
||||
const shouldRenderHighlight = mode === 'md' && fill !== 'outline' && !inItem;
|
||||
|
||||
@@ -732,6 +746,7 @@ export class Input implements ComponentInterface {
|
||||
size={this.size}
|
||||
type={this.type}
|
||||
value={value}
|
||||
defaultValue={defaultValue}
|
||||
onInput={this.onInput}
|
||||
onChange={this.onChange}
|
||||
onBlur={this.onBlur}
|
||||
@@ -796,6 +811,7 @@ Developers can dismiss this warning by removing their usage of the "legacy" prop
|
||||
|
||||
const mode = getIonMode(this);
|
||||
const value = this.getValue();
|
||||
const defaultValue = this.getValue(this.defaultValue);
|
||||
const labelId = this.inputId + '-lbl';
|
||||
const label = findItemLabel(this.el);
|
||||
if (label) {
|
||||
@@ -840,6 +856,7 @@ Developers can dismiss this warning by removing their usage of the "legacy" prop
|
||||
size={this.size}
|
||||
type={this.type}
|
||||
value={value}
|
||||
defaultValue={defaultValue}
|
||||
onInput={this.onInput}
|
||||
onChange={this.onChange}
|
||||
onBlur={this.onBlur}
|
||||
|
||||
@@ -977,7 +977,7 @@ export declare interface IonInfiniteScrollContent extends Components.IonInfinite
|
||||
|
||||
|
||||
@ProxyCmp({
|
||||
inputs: ['accept', 'autocapitalize', 'autocomplete', 'autocorrect', 'autofocus', 'clearInput', 'clearOnEdit', 'color', 'counter', 'counterFormatter', 'debounce', 'disabled', 'enterkeyhint', 'errorText', 'fill', 'helperText', 'inputmode', 'label', 'labelPlacement', 'legacy', 'max', 'maxlength', 'min', 'minlength', 'mode', 'multiple', 'name', 'pattern', 'placeholder', 'readonly', 'required', 'shape', 'size', 'spellcheck', 'step', 'type', 'value'],
|
||||
inputs: ['accept', 'autocapitalize', 'autocomplete', 'autocorrect', 'autofocus', 'clearInput', 'clearOnEdit', 'color', 'counter', 'counterFormatter', 'debounce', 'defaultValue', 'disabled', 'enterkeyhint', 'errorText', 'fill', 'helperText', 'inputmode', 'label', 'labelPlacement', 'legacy', 'max', 'maxlength', 'min', 'minlength', 'mode', 'multiple', 'name', 'pattern', 'placeholder', 'readonly', 'required', 'shape', 'size', 'spellcheck', 'step', 'type', 'value'],
|
||||
methods: ['setFocus', 'getInputElement']
|
||||
})
|
||||
@Component({
|
||||
@@ -985,7 +985,7 @@ export declare interface IonInfiniteScrollContent extends Components.IonInfinite
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
template: '<ng-content></ng-content>',
|
||||
// eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
|
||||
inputs: ['accept', 'autocapitalize', 'autocomplete', 'autocorrect', 'autofocus', 'clearInput', 'clearOnEdit', 'color', 'counter', 'counterFormatter', 'debounce', 'disabled', 'enterkeyhint', 'errorText', 'fill', 'helperText', 'inputmode', 'label', 'labelPlacement', 'legacy', 'max', 'maxlength', 'min', 'minlength', 'mode', 'multiple', 'name', 'pattern', 'placeholder', 'readonly', 'required', 'shape', 'size', 'spellcheck', 'step', 'type', 'value'],
|
||||
inputs: ['accept', 'autocapitalize', 'autocomplete', 'autocorrect', 'autofocus', 'clearInput', 'clearOnEdit', 'color', 'counter', 'counterFormatter', 'debounce', 'defaultValue', 'disabled', 'enterkeyhint', 'errorText', 'fill', 'helperText', 'inputmode', 'label', 'labelPlacement', 'legacy', 'max', 'maxlength', 'min', 'minlength', 'mode', 'multiple', 'name', 'pattern', 'placeholder', 'readonly', 'required', 'shape', 'size', 'spellcheck', 'step', 'type', 'value'],
|
||||
})
|
||||
export class IonInput {
|
||||
protected el: HTMLElement;
|
||||
|
||||
@@ -429,6 +429,7 @@ export const IonInput = /*@__PURE__*/ defineContainer<JSX.IonInput, JSX.IonInput
|
||||
'size',
|
||||
'type',
|
||||
'value',
|
||||
'defaultValue',
|
||||
'ionInput',
|
||||
'ionChange',
|
||||
'ionBlur',
|
||||
|
||||
Reference in New Issue
Block a user