Skip to content

Commit

Permalink
refactor(forms): deprecate unwanted control events aliases
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.
  • Loading branch information
JeanMeche committed May 10, 2024
1 parent 85ac2de commit f0487ff
Show file tree
Hide file tree
Showing 3 changed files with 43 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
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 f0487ff

Please sign in to comment.