@@ -4,6 +4,9 @@ import { Application } from '../application';
44import { EventDispatcher , Event , EventMap } from './events' ;
55import { DeclarationOption } from './options/declaration' ;
66
7+ /**
8+ * Exposes a reference to the root Application component.
9+ */
710export interface ComponentHost {
811 readonly application : Application ;
912}
@@ -16,14 +19,21 @@ export interface ComponentClass<T extends Component, O extends ComponentHost = C
1619 new ( owner : O ) : T ;
1720}
1821
22+ /**
23+ * Option-bag passed to Component decorator.
24+ */
1925export interface ComponentOptions {
2026 name ?: string ;
27+ /** Specify valid child component class. Used to prove that children are valid via `instanceof` checks */
2128 childClass ?: Function ;
2229 internal ?: boolean ;
2330}
2431
2532const childMappings : { host : ChildableComponent < any , any > , child : Function } [ ] = [ ] ;
2633
34+ /**
35+ * Class decorator applied to Components
36+ */
2737export function Component ( options : ComponentOptions ) : ClassDecorator {
2838 return ( target : Function ) => {
2939 const proto = target . prototype ;
@@ -63,6 +73,11 @@ export function Component(options: ComponentOptions): ClassDecorator {
6373 } ;
6474}
6575
76+ /**
77+ * Decorator that declares a configuration option.
78+ *
79+ * Use it on an instance property of a Component class.
80+ */
6681export function Option ( options : DeclarationOption ) : PropertyDecorator {
6782 return function ( target : object , propertyKey : string | symbol ) {
6883 if ( ! ( target instanceof AbstractComponent ) ) {
@@ -107,7 +122,10 @@ export class ComponentEvent extends Event {
107122export const DUMMY_APPLICATION_OWNER = Symbol ( ) ;
108123
109124/**
110- * Component base class.
125+ * Component base class. Has an owner (unless it's the application root component),
126+ * can dispatch events to its children, and has access to the root Application component.
127+ *
128+ * @template O type of component's owner.
111129 */
112130export abstract class AbstractComponent < O extends ComponentHost > extends EventDispatcher implements ComponentHost {
113131 /**
@@ -176,7 +194,10 @@ export abstract class AbstractComponent<O extends ComponentHost> extends EventDi
176194}
177195
178196/**
179- * Component base class.
197+ * Component that can have child components.
198+ *
199+ * @template O type of Component's owner
200+ * @template C type of Component's children
180201 */
181202export abstract class ChildableComponent < O extends ComponentHost , C extends Component > extends AbstractComponent < O > {
182203 /**
0 commit comments