/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import { getNullInjector } from '../di/r3_injector';
import { ComponentFactory } from './component_ref';
import { getComponentDef } from './definition';
import { assertComponentDef } from './errors';
/**
* Creates a `ComponentRef` instance based on provided component type and a set of options.
*
* @usageNotes
*
* The example below demonstrates how the `createComponent` function can be used
* to create an instance of a ComponentRef dynamically and attach it to an ApplicationRef,
* so that it gets included into change detection cycles.
*
* Note: the example uses standalone components, but the function can also be used for
* non-standalone components (declared in an NgModule) as well.
*
* ```typescript
* @Component({
* standalone: true,
* template: `Hello {{ name }}!`
* })
* class HelloComponent {
* name = 'Angular';
* }
*
* @Component({
* standalone: true,
* template: `
`
* })
* class RootComponent {}
*
* // Bootstrap an application.
* const applicationRef = await bootstrapApplication(RootComponent);
*
* // Locate a DOM node that would be used as a host.
* const hostElement = document.getElementById('hello-component-host');
*
* // Get an `EnvironmentInjector` instance from the `ApplicationRef`.
* const environmentInjector = applicationRef.injector;
*
* // We can now create a `ComponentRef` instance.
* const componentRef = createComponent(HelloComponent, {hostElement, environmentInjector});
*
* // Last step is to register the newly created ref using the `ApplicationRef` instance
* // to include the component view into change detection cycles.
* applicationRef.attachView(componentRef.hostView);
* componentRef.changeDetectorRef.detectChanges();
* ```
*
* @param component Component class reference.
* @param options Set of options to use:
* * `environmentInjector`: An `EnvironmentInjector` instance to be used for the component, see
* additional info about it [here](/guide/standalone-components#environment-injectors).
* * `hostElement` (optional): A DOM node that should act as a host node for the component. If not
* provided, Angular creates one based on the tag name used in the component selector (and falls
* back to using `div` if selector doesn't have tag name info).
* * `elementInjector` (optional): An `ElementInjector` instance, see additional info about it
* [here](/guide/hierarchical-dependency-injection#elementinjector).
* * `projectableNodes` (optional): A list of DOM nodes that should be projected through
* [``](api/core/ng-content) of the new component instance.
* @returns ComponentRef instance that represents a given Component.
*
* @publicApi
*/
export function createComponent(component, options) {
ngDevMode && assertComponentDef(component);
const componentDef = getComponentDef(component);
const elementInjector = options.elementInjector || getNullInjector();
const factory = new ComponentFactory(componentDef);
return factory.create(elementInjector, options.projectableNodes, options.hostElement, options.environmentInjector);
}
/**
* Creates an object that allows to retrieve component metadata.
*
* @usageNotes
*
* The example below demonstrates how to use the function and how the fields
* of the returned object map to the component metadata.
*
* ```typescript
* @Component({
* standalone: true,
* selector: 'foo-component',
* template: `
*
*
* `,
* })
* class FooComponent {
* @Input('inputName') inputPropName: string;
* @Output('outputName') outputPropName = new EventEmitter();
* }
*
* const mirror = reflectComponentType(FooComponent);
* expect(mirror.type).toBe(FooComponent);
* expect(mirror.selector).toBe('foo-component');
* expect(mirror.isStandalone).toBe(true);
* expect(mirror.inputs).toEqual([{propName: 'inputName', templateName: 'inputPropName'}]);
* expect(mirror.outputs).toEqual([{propName: 'outputName', templateName: 'outputPropName'}]);
* expect(mirror.ngContentSelectors).toEqual([
* '*', // first `` in a template, the selector defaults to `*`
* 'content-selector-a' // second `` in a template
* ]);
* ```
*
* @param component Component class reference.
* @returns An object that allows to retrieve component metadata.
*
* @publicApi
*/
export function reflectComponentType(component) {
const componentDef = getComponentDef(component);
if (!componentDef)
return null;
const factory = new ComponentFactory(componentDef);
return {
get selector() {
return factory.selector;
},
get type() {
return factory.componentType;
},
get inputs() {
return factory.inputs;
},
get outputs() {
return factory.outputs;
},
get ngContentSelectors() {
return factory.ngContentSelectors;
},
get isStandalone() {
return componentDef.standalone;
},
get isSignal() {
return componentDef.signals;
},
};
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tcG9uZW50LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vcGFja2FnZXMvY29yZS9zcmMvcmVuZGVyMy9jb21wb25lbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HO0FBR0gsT0FBTyxFQUFzQixlQUFlLE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