Skip to content

Commit

Permalink
refactor(forms): make DefaultValueAccessor standalone
Browse files Browse the repository at this point in the history
By make `DefaultValueAccessor` we'll allow developers to use as a host directive.

Fixes #48607
  • Loading branch information
JeanMeche committed May 11, 2024
1 parent 85ac2de commit bdc3159
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion goldens/public-api/forms/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export class DefaultValueAccessor extends BaseControlValueAccessor implements Co
constructor(renderer: Renderer2, elementRef: ElementRef, _compositionMode: boolean);
writeValue(value: any): void;
// (undocumented)
static ɵdir: i0.ɵɵDirectiveDeclaration<DefaultValueAccessor, "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]", never, {}, {}, never, never, false, never>;
static ɵdir: i0.ɵɵDirectiveDeclaration<DefaultValueAccessor, "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]", never, {}, {}, never, never, true, never>;
// (undocumented)
static ɵfac: i0.ɵɵFactoryDeclaration<DefaultValueAccessor, [null, null, { optional: true; }]>;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/forms/src/directives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ export const SHARED_FORM_DIRECTIVES: Type<any>[] = [
NgNoValidate,
NgSelectOption,
NgSelectMultipleOption,
DefaultValueAccessor,
NumberValueAccessor,
RangeValueAccessor,
CheckboxControlValueAccessor,
Expand Down Expand Up @@ -106,8 +105,9 @@ export const REACTIVE_DRIVEN_DIRECTIVES: Type<any>[] = [
* Internal module used for sharing directives between FormsModule and ReactiveFormsModule
*/
@NgModule({
imports: [DefaultValueAccessor],
declarations: SHARED_FORM_DIRECTIVES,
exports: SHARED_FORM_DIRECTIVES,
exports: [...SHARED_FORM_DIRECTIVES, DefaultValueAccessor],
})
export class ɵInternalFormsSharedModule {}

Expand Down
1 change: 1 addition & 0 deletions packages/forms/src/directives/default_value_accessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export const COMPOSITION_BUFFER_MODE = new InjectionToken<boolean>(
'(compositionend)': '$any(this)._compositionEnd($event.target.value)',
},
providers: [DEFAULT_VALUE_ACCESSOR],
standalone: true,
})
export class DefaultValueAccessor extends BaseControlValueAccessor implements ControlValueAccessor {
/** Whether the user is creating a composition string (IME events). */
Expand Down

0 comments on commit bdc3159

Please sign in to comment.