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 28fb385 commit 8fa4ebc
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 9 deletions.
16 changes: 14 additions & 2 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,23 +898,31 @@ export class SelectMultipleControlValueAccessor extends BuiltInControlValueAcces
export type SetDisabledStateOption = 'whenDisabledForLegacyCode' | 'always';

// @public
export class StatusEvent extends ControlEvent {
export class StatusChangeEvent extends ControlEvent {
constructor(status: FormControlStatus, source: AbstractControl);
// (undocumented)
readonly source: AbstractControl;
// (undocumented)
readonly status: FormControlStatus;
}

// @public @deprecated (undocumented)
export class StatusEvent extends StatusChangeEvent {
}

// @public
export class TouchedEvent extends ControlEvent {
export class TouchedChangeEvent extends ControlEvent {
constructor(touched: boolean, source: AbstractControl);
// (undocumented)
readonly source: AbstractControl;
// (undocumented)
readonly touched: boolean;
}

// @public @deprecated (undocumented)
export class TouchedEvent extends TouchedChangeEvent {
}

// @public
export type UntypedFormArray = FormArray<any>;

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
25 changes: 21 additions & 4 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 @@ -116,6 +115,14 @@ export class PristineChangeEvent extends ControlEvent {
}
}

/**
* Event fired when the control's pristine state changes (pristine <=> dirty).
*
* @publicApi
*/

export class PristineChangeEvent extends PristineEvent {}

/**
* Event fired when the control's touched status changes (touched <=> untouched).
*
Expand All @@ -130,6 +137,11 @@ export class TouchedChangeEvent extends ControlEvent {
}
}

/**
* @deprecated use `TouchedChangeEvent` symbol instead.
*/
export class TouchedEvent extends TouchedChangeEvent {}

/**
* Event fired when the control's status changes.
*
Expand Down Expand Up @@ -165,6 +177,11 @@ export class FormResetEvent extends ControlEvent {
}
}

/**
* @deprecated use `StatusChangeEvent` symbol instead.
*/
export class StatusEvent extends StatusChangeEvent {}

/**
* Gets validators from either an options object or given validators.
*/
Expand Down

0 comments on commit 8fa4ebc

Please sign in to comment.