Skip to content

Commit

Permalink
refactor(forms): deprecate unwanted control events aliases (#55698)
Browse files Browse the repository at this point in the history
This commit deprecates the aliases for the control events to ease the changes in G3
A follow-up commit will remove those deprecated entries.

PR Close #55698
  • Loading branch information
JeanMeche authored and atscott committed May 13, 2024
1 parent db4e466 commit 5f3742d
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 11 deletions.
12 changes: 12 additions & 0 deletions goldens/public-api/forms/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,10 @@ export class PatternValidator extends AbstractValidatorDirective {
}

// @public
export class PristineChangeEvent extends PristineEvent {
}

// @public @deprecated (undocumented)
export class PristineEvent extends ControlEvent {
constructor(pristine: boolean, source: AbstractControl);
// (undocumented)
Expand Down Expand Up @@ -894,6 +898,10 @@ export class SelectMultipleControlValueAccessor extends BuiltInControlValueAcces
export type SetDisabledStateOption = 'whenDisabledForLegacyCode' | 'always';

// @public
export class StatusChangeEvent extends StatusEvent {
}

// @public @deprecated (undocumented)
export class StatusEvent extends ControlEvent {
constructor(status: FormControlStatus, source: AbstractControl);
// (undocumented)
Expand All @@ -903,6 +911,10 @@ export class StatusEvent extends ControlEvent {
}

// @public
export class TouchedChangeEvent extends TouchedEvent {
}

// @public @deprecated (undocumented)
export class TouchedEvent extends ControlEvent {
constructor(touched: boolean, source: AbstractControl);
// (undocumented)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,9 @@
{
"name": "PristineChangeEvent"
},
{
"name": "PristineEvent"
},
{
"name": "R3Injector"
},
Expand Down Expand Up @@ -548,6 +551,9 @@
{
"name": "StatusChangeEvent"
},
{
"name": "StatusEvent"
},
{
"name": "Subject"
},
Expand Down Expand Up @@ -587,6 +593,9 @@
{
"name": "TouchedChangeEvent"
},
{
"name": "TouchedEvent"
},
{
"name": "USE_VALUE"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,9 @@
{
"name": "PristineChangeEvent"
},
{
"name": "PristineEvent"
},
{
"name": "R3Injector"
},
Expand Down Expand Up @@ -530,6 +533,9 @@
{
"name": "StatusChangeEvent"
},
{
"name": "StatusEvent"
},
{
"name": "Subject"
},
Expand Down Expand Up @@ -575,6 +581,9 @@
{
"name": "TouchedChangeEvent"
},
{
"name": "TouchedEvent"
},
{
"name": "USE_VALUE"
},
Expand Down
9 changes: 6 additions & 3 deletions packages/forms/src/forms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,12 @@ export {
FormControlStatus,
FormResetEvent,
FormSubmittedEvent,
PristineChangeEvent as PristineEvent,
StatusChangeEvent as StatusEvent,
TouchedChangeEvent as TouchedEvent,
PristineEvent,
StatusEvent,
TouchedEvent,
PristineChangeEvent,
StatusChangeEvent,
TouchedChangeEvent,
ValueChangeEvent,
ɵCoerceStrArrToNumArr,
ɵGetProperty,
Expand Down
33 changes: 25 additions & 8 deletions packages/forms/src/model/abstract_model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,10 @@ export class ValueChangeEvent<T> extends ControlEvent<T> {
}

/**
* Event fired when the control's pristine state changes (pristine <=> dirty).
*
* @publicApi
* @deprecated use `PristineChangeEvent` symbol instead.
*/
export class PristineChangeEvent extends ControlEvent {

export class PristineEvent extends ControlEvent {
constructor(
public readonly pristine: boolean,
public readonly source: AbstractControl,
Expand All @@ -117,11 +116,17 @@ export class PristineChangeEvent extends ControlEvent {
}

/**
* Event fired when the control's touched status changes (touched <=> untouched).
* Event fired when the control's pristine state changes (pristine <=> dirty).
*
* @publicApi
*/
export class TouchedChangeEvent extends ControlEvent {

export class PristineChangeEvent extends PristineEvent {}

/**
* @deprecated use `TouchedChangeEvent` symbol instead.
*/
export class TouchedEvent extends ControlEvent {
constructor(
public readonly touched: boolean,
public readonly source: AbstractControl,
Expand All @@ -131,11 +136,16 @@ export class TouchedChangeEvent extends ControlEvent {
}

/**
* Event fired when the control's status changes.
* Event fired when the control's touched status changes (touched <=> untouched).
*
* @publicApi
*/
export class StatusChangeEvent extends ControlEvent {
export class TouchedChangeEvent extends TouchedEvent {}

/**
* @deprecated use `StatusChangeEvent` symbol instead.
*/
export class StatusEvent extends ControlEvent {
constructor(
public readonly status: FormControlStatus,
public readonly source: AbstractControl,
Expand All @@ -144,6 +154,13 @@ export class StatusChangeEvent extends ControlEvent {
}
}

/**
* Event fired when the control's status changes.
*
* @publicApi
*/
export class StatusChangeEvent extends StatusEvent {}

/**
* Event fired when a form is submitted
*
Expand Down

0 comments on commit 5f3742d

Please sign in to comment.