Merge branch 'feature-7.0' into 7-sync-09-23-22

This commit is contained in:
Liam DeBeasi
2022-09-23 16:34:53 -05:00
committed by GitHub
15 changed files with 280 additions and 33 deletions

View File

@ -5,7 +5,7 @@ import { ValueAccessor } from './value-accessor';
@Directive({
/* tslint:disable-next-line:directive-selector */
selector: 'ion-textarea,ion-searchbar',
selector: 'ion-searchbar',
providers: [
{
provide: NG_VALUE_ACCESSOR,
@ -26,7 +26,7 @@ export class TextValueAccessorDirective extends ValueAccessor {
}
@Directive({
selector: 'ion-input:not([type=number])',
selector: 'ion-input:not([type=number]),ion-textarea',
providers: [
{
provide: NG_VALUE_ACCESSOR,
@ -35,6 +35,7 @@ export class TextValueAccessorDirective extends ValueAccessor {
},
],
})
// TODO rename this value accessor to `TextValueAccessorDirective` when search-bar is updated
export class InputValueAccessorDirective extends ValueAccessor {
constructor(injector: Injector, el: ElementRef) {
super(injector, el);

View File

@ -1816,13 +1816,19 @@ export class IonText {
import type { TextareaChangeEventDetail as ITextareaTextareaChangeEventDetail } from '@ionic/core';
export declare interface IonTextarea extends Components.IonTextarea {
/**
* Emitted when the input value has changed.
* The `ionChange` event is fired for `<ion-textarea>` elements when the user
modifies the element's value. Unlike the `ionInput` event, the `ionChange`
event is not necessarily fired for each alteration to an element's value.
The `ionChange` event is fired when the element loses focus after its value
has been modified.
*/
ionChange: EventEmitter<CustomEvent<ITextareaTextareaChangeEventDetail>>;
/**
* Emitted when a keyboard input occurred.
* Ths `ionInput` event fires when the `value` of an `<ion-textarea>` element
has been changed.
*/
ionInput: EventEmitter<CustomEvent<InputEvent>>;
ionInput: EventEmitter<CustomEvent<InputEvent | null>>;
/**
* Emitted when the input loses focus.
*/

View File

@ -0,0 +1,18 @@
describe('Textarea', () => {
beforeEach(() => cy.visit('/textarea'));
it('should become valid', () => {
cy.get('#status').should('have.text', 'INVALID');
cy.get('ion-textarea').type('hello');
cy.get('#status').should('have.text', 'VALID');
});
it('should update the form control value when typing', () => {
cy.get('#value').contains(`"textarea": ""`);
cy.get('ion-textarea').type('hello');
cy.get('#value').contains(`"textarea": "hello"`);
});
});

View File

@ -25,6 +25,7 @@ const routes: Routes = [
{ path: 'accordions', component: AccordionComponent },
{ path: 'alerts', component: AlertComponent },
{ path: 'inputs', component: InputsComponent },
{ path: 'textarea', loadChildren: () => import('./textarea/textarea.module').then(m => m.TextareaModule) },
{ path: 'form', component: FormComponent },
{ path: 'modals', component: ModalComponent },
{ path: 'modal-inline', loadChildren: () => import('./modal-inline').then(m => m.ModalInlineModule) },

View File

@ -61,7 +61,7 @@
Form Status: <span id="status">{{ profileForm.status }}</span>
</p>
<p>
Form Status: <span id="data">{{ profileForm.value | json }}</span>
Form value: <span id="data">{{ profileForm.value | json }}</span>
</p>
<p>
Form Submit: <span id="submit">{{submitted}}</span>

View File

@ -0,0 +1,16 @@
import { NgModule } from "@angular/core";
import { RouterModule } from "@angular/router";
import { TextareaComponent } from "./textarea.component";
@NgModule({
imports: [
RouterModule.forChild([
{
path: '',
component: TextareaComponent
}
])
],
exports: [RouterModule]
})
export class TextareaRoutingModule { }

View File

@ -0,0 +1,16 @@
<ion-content>
<form [formGroup]="form">
<ion-list>
<ion-item>
<ion-label>Textarea</ion-label>
<ion-textarea formControlName="textarea"></ion-textarea>
</ion-item>
</ion-list>
</form>
<p>
Form status: <span id="status">{{ form.status }}</span>
</p>
<p>
Form value: <span id="value">{{ form.value | json }}</span>
</p>
</ion-content>

View File

@ -0,0 +1,17 @@
import { Component } from '@angular/core';
import { FormBuilder, Validators } from '@angular/forms';
@Component({
selector: 'app-textarea',
templateUrl: 'textarea.component.html',
})
export class TextareaComponent {
form = this.fb.group({
textarea: ['', Validators.required]
})
constructor(private fb: FormBuilder) { }
}

View File

@ -0,0 +1,21 @@
import { CommonModule } from "@angular/common";
import { NgModule } from "@angular/core";
import { FormsModule, ReactiveFormsModule } from "@angular/forms";
import { IonicModule } from "@ionic/angular";
import { TextareaRoutingModule } from "./textarea-routing.module";
import { TextareaComponent } from "./textarea.component";
@NgModule({
imports: [
CommonModule,
FormsModule,
ReactiveFormsModule,
IonicModule,
TextareaRoutingModule
],
declarations: [
TextareaComponent
]
})
export class TextareaModule { }