2015-02-06 13:19:47 -08:00
|
|
|
import {ABSTRACT, CONST, normalizeBlank, isPresent} from 'angular2/src/facade/lang';
|
|
|
|
import {ListWrapper, List} from 'angular2/src/facade/collection';
|
2014-11-21 21:19:23 -08:00
|
|
|
import {TemplateConfig} from './template_config';
|
|
|
|
|
|
|
|
@ABSTRACT()
|
|
|
|
export class Directive {
|
|
|
|
selector:any; //string;
|
|
|
|
bind:any;
|
|
|
|
lightDomServices:any; //List;
|
|
|
|
implementsTypes:any; //List;
|
2015-01-13 16:17:43 -08:00
|
|
|
lifecycle:any; //List
|
2014-11-21 21:19:23 -08:00
|
|
|
@CONST()
|
|
|
|
constructor({
|
|
|
|
selector,
|
|
|
|
bind,
|
|
|
|
lightDomServices,
|
2015-01-13 16:17:43 -08:00
|
|
|
implementsTypes,
|
|
|
|
lifecycle
|
2014-11-21 21:19:23 -08:00
|
|
|
}:{
|
|
|
|
selector:string,
|
|
|
|
bind:any,
|
|
|
|
lightDomServices:List,
|
2015-01-13 16:17:43 -08:00
|
|
|
implementsTypes:List,
|
|
|
|
lifecycle:List
|
2014-11-21 21:19:23 -08:00
|
|
|
}={})
|
|
|
|
{
|
|
|
|
this.selector = selector;
|
|
|
|
this.lightDomServices = lightDomServices;
|
|
|
|
this.implementsTypes = implementsTypes;
|
|
|
|
this.bind = bind;
|
2015-01-13 16:17:43 -08:00
|
|
|
this.lifecycle = lifecycle;
|
2014-11-21 21:19:23 -08:00
|
|
|
}
|
2015-02-06 13:19:47 -08:00
|
|
|
|
|
|
|
hasLifecycleHook(hook:string):boolean {
|
|
|
|
return isPresent(this.lifecycle) ? ListWrapper.contains(this.lifecycle, hook) : false;
|
|
|
|
}
|
2014-11-21 21:19:23 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
export class Component extends Directive {
|
|
|
|
//TODO: vsavkin: uncomment it once the issue with defining fields in a sublass works
|
|
|
|
template:any; //TemplateConfig;
|
|
|
|
lightDomServices:any; //List;
|
|
|
|
shadowDomServices:any; //List;
|
|
|
|
componentServices:any; //List;
|
2015-01-13 16:17:43 -08:00
|
|
|
lifecycle:any; //List
|
2014-11-21 21:19:23 -08:00
|
|
|
|
2015-01-13 16:17:43 -08:00
|
|
|
@CONST()
|
2014-11-21 21:19:23 -08:00
|
|
|
constructor({
|
|
|
|
selector,
|
|
|
|
bind,
|
|
|
|
template,
|
|
|
|
lightDomServices,
|
|
|
|
shadowDomServices,
|
|
|
|
componentServices,
|
2014-12-23 10:45:20 -08:00
|
|
|
implementsTypes,
|
2015-01-13 16:17:43 -08:00
|
|
|
lifecycle
|
2014-11-21 21:19:23 -08:00
|
|
|
}:{
|
2015-01-13 16:17:43 -08:00
|
|
|
selector:String,
|
2014-11-21 21:19:23 -08:00
|
|
|
bind:Object,
|
|
|
|
template:TemplateConfig,
|
|
|
|
lightDomServices:List,
|
|
|
|
shadowDomServices:List,
|
|
|
|
componentServices:List,
|
2014-12-23 10:45:20 -08:00
|
|
|
implementsTypes:List,
|
2015-01-13 16:17:43 -08:00
|
|
|
lifecycle:List
|
|
|
|
}={})
|
2014-11-21 21:19:23 -08:00
|
|
|
{
|
|
|
|
super({
|
|
|
|
selector: selector,
|
|
|
|
bind: bind,
|
|
|
|
lightDomServices: lightDomServices,
|
2015-01-13 16:17:43 -08:00
|
|
|
implementsTypes: implementsTypes,
|
|
|
|
lifecycle: lifecycle
|
|
|
|
});
|
2014-11-21 21:19:23 -08:00
|
|
|
|
|
|
|
this.template = template;
|
|
|
|
this.lightDomServices = lightDomServices;
|
|
|
|
this.shadowDomServices = shadowDomServices;
|
|
|
|
this.componentServices = componentServices;
|
2015-01-13 16:17:43 -08:00
|
|
|
this.lifecycle = lifecycle;
|
2014-11-21 21:19:23 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export class Decorator extends Directive {
|
2015-01-07 17:32:46 +01:00
|
|
|
compileChildren: boolean;
|
2014-11-21 21:19:23 -08:00
|
|
|
@CONST()
|
|
|
|
constructor({
|
|
|
|
selector,
|
|
|
|
bind,
|
|
|
|
lightDomServices,
|
2015-01-07 18:20:29 +01:00
|
|
|
implementsTypes,
|
2015-01-13 16:17:43 -08:00
|
|
|
lifecycle,
|
|
|
|
compileChildren = true,
|
2014-11-21 21:19:23 -08:00
|
|
|
}:{
|
|
|
|
selector:string,
|
|
|
|
bind:any,
|
|
|
|
lightDomServices:List,
|
2015-01-07 18:20:29 +01:00
|
|
|
implementsTypes:List,
|
2015-01-13 16:17:43 -08:00
|
|
|
lifecycle:List,
|
2015-01-07 18:20:29 +01:00
|
|
|
compileChildren:boolean
|
2014-11-21 21:19:23 -08:00
|
|
|
}={})
|
|
|
|
{
|
2015-01-07 18:20:29 +01:00
|
|
|
this.compileChildren = compileChildren;
|
2014-11-21 21:19:23 -08:00
|
|
|
super({
|
|
|
|
selector: selector,
|
|
|
|
bind: bind,
|
|
|
|
lightDomServices: lightDomServices,
|
2015-01-13 16:17:43 -08:00
|
|
|
implementsTypes: implementsTypes,
|
|
|
|
lifecycle: lifecycle
|
2014-11-21 21:19:23 -08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export class Template extends Directive {
|
|
|
|
@CONST()
|
|
|
|
constructor({
|
|
|
|
selector,
|
|
|
|
bind,
|
|
|
|
lightDomServices,
|
2015-01-13 16:17:43 -08:00
|
|
|
implementsTypes,
|
|
|
|
lifecycle
|
2014-11-21 21:19:23 -08:00
|
|
|
}:{
|
|
|
|
selector:string,
|
|
|
|
bind:any,
|
|
|
|
lightDomServices:List,
|
2015-01-13 16:17:43 -08:00
|
|
|
implementsTypes:List,
|
|
|
|
lifecycle:List
|
2014-11-21 21:19:23 -08:00
|
|
|
}={})
|
|
|
|
{
|
|
|
|
super({
|
|
|
|
selector: selector,
|
|
|
|
bind: bind,
|
|
|
|
lightDomServices: lightDomServices,
|
2015-01-13 16:17:43 -08:00
|
|
|
implementsTypes: implementsTypes,
|
|
|
|
lifecycle: lifecycle
|
2014-11-21 21:19:23 -08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2015-01-13 16:17:43 -08:00
|
|
|
|
2015-02-06 13:19:47 -08:00
|
|
|
export const onDestroy = "onDestroy";
|
|
|
|
export const onChange = "onChange";
|