diff --git a/packages/core/src/components/input/input-base.tsx b/packages/core/src/components/input/input-base.tsx
new file mode 100644
index 0000000000..268426e744
--- /dev/null
+++ b/packages/core/src/components/input/input-base.tsx
@@ -0,0 +1,58 @@
+// Shared Interfaces
+
+import { EventEmitter } from '@stencil/core';
+
+export interface InputBaseComponent {
+ ionStyle: EventEmitter;
+ ionBlur: EventEmitter;
+ ionFocus: EventEmitter;
+
+ clearOnEdit: boolean;
+ didBlurAfterEdit: boolean;
+ styleTmr: number;
+
+ // Shared Attributes
+ autocapitalize: string;
+ autocomplete: string;
+ autofocus: boolean;
+ disabled: boolean;
+ minlength: number;
+ maxlength: number;
+ name: string;
+ placeholder: string;
+ readonly: boolean;
+ required: boolean;
+ spellcheck: boolean;
+ value: string;
+
+ // Shared Methods
+ inputBlurred: (ev: any) => void;
+ inputChanged: (ev: any) => void;
+ inputFocused: (ev: any) => void;
+ inputKeydown: (ev: any) => void;
+}
+
+export interface InputComponent extends InputBaseComponent {
+ clearInput: boolean;
+
+ // Input Attributes
+ accept: string;
+ autocorrect: string;
+ inputmode: string;
+ min: string;
+ max: string;
+ multiple: boolean;
+ pattern: string;
+ results: number;
+ step: string;
+ size: number;
+ type: string;
+}
+
+export interface TextareaComponent extends InputBaseComponent {
+
+ // Textarea Attributes
+ cols: number;
+ rows: number;
+ wrap: string;
+}
\ No newline at end of file
diff --git a/packages/core/src/components/input/input.tsx b/packages/core/src/components/input/input.tsx
index 4e159f2f5b..2fbc3a6b3b 100644
--- a/packages/core/src/components/input/input.tsx
+++ b/packages/core/src/components/input/input.tsx
@@ -2,6 +2,7 @@ import { Component, Element, Event, EventEmitter, Prop, PropDidChange } from '@s
import { createThemedClasses } from '../../utils/theme';
+import { InputComponent } from './input-base';
@Component({
tag: 'ion-input',
@@ -14,11 +15,12 @@ import { createThemedClasses } from '../../utils/theme';
theme: 'input'
}
})
-export class Input {
- mode: any;
- color: any;
- styleTmr: any;
+export class Input implements InputComponent {
+ mode: string;
+ color: string;
+
didBlurAfterEdit: boolean;
+ styleTmr: number;
@Element() el: HTMLElement;
@@ -37,6 +39,16 @@ export class Input {
*/
@Event() ionFocus: EventEmitter;
+ /**
+ * @input {string} If the value of the type attribute is `"file"`, then this attribute will indicate the types of files that the server accepts, otherwise it will be ignored. The value must be a comma-separated list of unique content type specifiers.
+ */
+ @Prop() accept: string;
+
+ /**
+ * @input {string} Indicates whether and how the text value should be automatically capitalized as it is entered/edited by the user. Defaults to `"none"`.
+ */
+ @Prop() autocapitalize: string = 'none';
+
/**
* @input {string} Indicates whether the value of the control can be automatically completed by the browser. Defaults to `"off"`.
*/
@@ -50,7 +62,7 @@ export class Input {
/**
* @input {string} This Boolean attribute lets you specify that a form control should have input focus when the page loads. Defaults to `false`.
*/
- @Prop() autofocus: boolean;
+ @Prop() autofocus: boolean = false;
/**
* @input {boolean} If true and the type is `checkbox` or `radio`, the control is selected by default. Defaults to `false`.
@@ -72,9 +84,9 @@ export class Input {
@Prop() clearInput: boolean = false;
/**
- * @input {boolean} If true, the value will be cleared after focus upon edit. Defaults to `true` when `type` is `"password"`, `false` for all other types. Defaults to `false`.
+ * @input {boolean} If true, the value will be cleared after focus upon edit. Defaults to `true` when `type` is `"password"`, `false` for all other types.
*/
- @Prop({state: true}) clearOnEdit: boolean;
+ @Prop({ state: true }) clearOnEdit: boolean;
/**
* @input {boolean} If true, the user cannot interact with this element. Defaults to `false`.
@@ -90,14 +102,44 @@ export class Input {
}
/**
- * @input {any} The minimum value, which must not be greater than its maximum (max attribute) value.
+ * @input {string} 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"`.
+ */
+ @Prop() inputmode: string;
+
+ /**
+ * @input {string} The maximum value, which must not be less than its minimum (min attribute) value.
+ */
+ @Prop() max: string;
+
+ /**
+ * @input {number} 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.
+ */
+ @Prop() maxlength: number;
+
+ /**
+ * @input {string} The minimum value, which must not be greater than its maximum (max attribute) value.
*/
@Prop() min: string;
/**
- * @input {any} The maximum value, which must not be less than its minimum (min attribute) value.
+ * @input {number} If the value of the type attribute is `text`, `email`, `search`, `password`, `tel`, or `url`, this attribute specifies the minimum number of characters that the user can enter.
*/
- @Prop() max: string;
+ @Prop() minlength: number;
+
+ /**
+ * @input {boolean} If true, the user can enter more than one value. This attribute applies when the type attribute is set to `"email"` or `"file"`, otherwise it is ignored.
+ */
+ @Prop() multiple: boolean;
+
+ /**
+ * @input {string} The name of the control, which is submitted with the form data.
+ */
+ @Prop() name: string;
+
+ /**
+ * @input {string} A regular expression that the value is checked against. The pattern must match the entire value, not just some subset. Use the title attribute to describe the pattern to help the user. This attribute applies when the value of the type attribute is `"text"`, `"search"`, `"tel"`, `"url"`, `"email"`, or `"password"`, otherwise it is ignored.
+ */
+ @Prop() pattern: string;
/**
* @input {string} Instructional text that shows before the input has a value.
@@ -109,16 +151,31 @@ export class Input {
*/
@Prop() readonly: boolean = false;
+ /**
+ * @input {boolean} If true, the user must fill in a value before submitting a form.
+ */
+ @Prop() required: boolean = false;
+
+ /**
+ * @input {number} This is a nonstandard attribute supported by Safari that only applies when the type is `"search"`. Its value should be a nonnegative decimal integer.
+ */
+ @Prop() results: number;
+
/**
* @input {string} If true, the element will have its spelling and grammar checked. Defaults to `false`.
*/
@Prop() spellcheck: boolean = false;
/**
- * @input {any} Works with the min and max attributes to limit the increments at which a value can be set.
+ * @input {string} Works with the min and max attributes to limit the increments at which a value can be set. Possible values are: `"any"` or a positive floating point number.
*/
@Prop() step: string;
+ /**
+ * @input {number} The initial size of the control. This value is in pixels unless the value of the type attribute is `"text"` or `"password"`, in which case it is an integer number of characters. This attribute applies only when the `type` attribute is set to `"text"`, `"search"`, `"tel"`, `"url"`, `"email"`, or `"password"`, otherwise it is ignored.
+ */
+ @Prop() size: number;
+
/**
* @input {string} The type of control to display. The default type is text. Possible values are: `"text"`, `"password"`, `"email"`, `"number"`, `"search"`, `"tel"`, or `"url"`.
*/
@@ -129,7 +186,6 @@ export class Input {
*/
@Prop({ state: true }) value: string;
-
ionViewDidLoad() {
this.emitStyle();
@@ -155,13 +211,6 @@ export class Input {
});
}
- /**
- * @hidden
- */
- hasValue(): boolean {
- return (this.value !== null && this.value !== undefined && this.value !== '');
- }
-
/**
* @hidden
@@ -194,15 +243,6 @@ export class Input {
}
- /**
- * @hidden
- */
- hasFocus(): boolean {
- // check if an input has focus or not
- return this.el && (this.el.querySelector(':focus') === this.el.querySelector('input'));
- }
-
-
/**
* @hidden
*/
@@ -241,7 +281,6 @@ export class Input {
this.didBlurAfterEdit = false;
}
-
/**
* @hidden
*/
@@ -250,32 +289,52 @@ export class Input {
this.value = '';
}
+ /**
+ * @hidden
+ */
+ hasFocus(): boolean {
+ // check if an input has focus or not
+ return this.el && (this.el.querySelector(':focus') === this.el.querySelector('input'));
+ }
+
+
+ /**
+ * @hidden
+ */
+ hasValue(): boolean {
+ return (this.value !== null && this.value !== undefined && this.value !== '');
+ }
+
render() {
const themedClasses = createThemedClasses(this.mode, this.color, 'text-input');
// TODO aria-labelledby={this.item.labelId}
- // OLD RENDER
- // '' +
- // '' +
- // '' +
- // '