Skip to content

Commit

Permalink
feat(forms): make DefaultValueAccessor directive standalone
Browse files Browse the repository at this point in the history
This commit make the DefaultValueAccessor directive standalone allowing it to be used as hostDirective

Fixes: angular#48607
  • Loading branch information
JeanMeche committed Jan 1, 2023
1 parent 27da733 commit 9c63aba
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 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 @@ -198,7 +198,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
7 changes: 3 additions & 4 deletions packages/forms/src/directives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,10 @@ export {NgSelectOption, SelectControlValueAccessor} from './directives/select_co
export {NgSelectMultipleOption, SelectMultipleControlValueAccessor} from './directives/select_multiple_control_value_accessor';
export {CALL_SET_DISABLED_STATE} from './directives/shared';

export const SHARED_FORM_DIRECTIVES: Type<any>[] = [
const SHARED_FORM_DIRECTIVES: Type<any>[] = [
NgNoValidate,
NgSelectOption,
NgSelectMultipleOption,
DefaultValueAccessor,
NumberValueAccessor,
RangeValueAccessor,
CheckboxControlValueAccessor,
Expand Down Expand Up @@ -78,8 +77,8 @@ export const REACTIVE_DRIVEN_DIRECTIVES: Type<any>[] =
*/
@NgModule({
declarations: SHARED_FORM_DIRECTIVES,
imports: [RadioControlRegistryModule],
exports: SHARED_FORM_DIRECTIVES,
imports: [RadioControlRegistryModule, DefaultValueAccessor],
exports: [...SHARED_FORM_DIRECTIVES, DefaultValueAccessor],
})
export class ɵInternalFormsSharedModule {
}
Expand Down
3 changes: 2 additions & 1 deletion packages/forms/src/directives/default_value_accessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ export const COMPOSITION_BUFFER_MODE = new InjectionToken<boolean>('CompositionE
'(compositionstart)': '$any(this)._compositionStart()',
'(compositionend)': '$any(this)._compositionEnd($event.target.value)'
},
providers: [DEFAULT_VALUE_ACCESSOR]
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 9c63aba

Please sign in to comment.