2015-08-14 10:03:45 -07:00
|
|
|
/**
|
|
|
|
* This indirection is needed to free up Component, etc symbols in the public API
|
|
|
|
* to be used by the decorator versions of these annotations.
|
|
|
|
*/
|
|
|
|
|
|
|
|
export {
|
|
|
|
QueryMetadata,
|
|
|
|
ViewQueryMetadata,
|
|
|
|
AttributeMetadata,
|
|
|
|
} from './metadata/di';
|
|
|
|
|
|
|
|
export {
|
|
|
|
ComponentMetadata,
|
|
|
|
DirectiveMetadata,
|
|
|
|
PipeMetadata,
|
|
|
|
LifecycleEvent
|
|
|
|
} from './metadata/directives';
|
|
|
|
|
|
|
|
export {ViewMetadata, ViewEncapsulation} from './metadata/view';
|
|
|
|
|
|
|
|
|
|
|
|
import {
|
|
|
|
QueryMetadata,
|
|
|
|
ViewQueryMetadata,
|
|
|
|
AttributeMetadata,
|
|
|
|
} from './metadata/di';
|
|
|
|
|
2015-08-07 11:41:38 -07:00
|
|
|
import {
|
2015-08-14 10:03:45 -07:00
|
|
|
ComponentMetadata,
|
|
|
|
DirectiveMetadata,
|
|
|
|
PipeMetadata,
|
2015-08-07 11:41:38 -07:00
|
|
|
LifecycleEvent
|
2015-08-14 10:03:45 -07:00
|
|
|
} from './metadata/directives';
|
|
|
|
|
|
|
|
import {ViewMetadata, ViewEncapsulation} from './metadata/view';
|
2015-08-26 11:44:59 -07:00
|
|
|
import {ChangeDetectionStrategy} from 'angular2/src/core/change_detection/change_detection';
|
2015-08-14 10:03:45 -07:00
|
|
|
|
2015-08-20 14:28:25 -07:00
|
|
|
import {makeDecorator, makeParamDecorator, TypeDecorator, Class} from './util/decorators';
|
|
|
|
import {Type} from 'angular2/src/core/facade/lang';
|
2015-06-12 23:51:42 -07:00
|
|
|
|
2015-07-07 08:15:58 +02:00
|
|
|
/**
|
2015-08-14 10:03:45 -07:00
|
|
|
* Interface for the {@link DirectiveMetadata} decorator function.
|
2015-07-07 08:15:58 +02:00
|
|
|
*
|
|
|
|
* See {@link DirectiveFactory}.
|
|
|
|
*/
|
2015-07-02 22:26:07 +02:00
|
|
|
export interface DirectiveDecorator extends TypeDecorator {}
|
2015-06-12 23:51:42 -07:00
|
|
|
|
2015-07-07 08:15:58 +02:00
|
|
|
/**
|
2015-08-14 10:03:45 -07:00
|
|
|
* Interface for the {@link ComponentMetadata} decorator function.
|
2015-07-07 08:15:58 +02:00
|
|
|
*
|
|
|
|
* See {@link ComponentFactory}.
|
|
|
|
*/
|
|
|
|
export interface ComponentDecorator extends TypeDecorator {
|
|
|
|
/**
|
2015-08-14 10:03:45 -07:00
|
|
|
* Chain {@link ViewMetadata} annotation.
|
2015-07-07 08:15:58 +02:00
|
|
|
*/
|
2015-07-07 22:09:19 +02:00
|
|
|
View(obj: {
|
|
|
|
templateUrl?: string,
|
|
|
|
template?: string,
|
|
|
|
directives?: List<Type | any | List<any>>,
|
2015-08-07 11:41:38 -07:00
|
|
|
pipes?: List<Type | any | List<any>>,
|
2015-07-07 22:09:19 +02:00
|
|
|
renderer?: string,
|
|
|
|
styles?: List<string>,
|
|
|
|
styleUrls?: List<string>,
|
|
|
|
}): ViewDecorator;
|
2015-07-07 08:15:58 +02:00
|
|
|
}
|
2015-06-12 23:51:42 -07:00
|
|
|
|
2015-07-07 08:15:58 +02:00
|
|
|
/**
|
2015-08-14 10:03:45 -07:00
|
|
|
* Interface for the {@link ViewMetadata} decorator function.
|
2015-07-07 08:15:58 +02:00
|
|
|
*
|
|
|
|
* See {@link ViewFactory}.
|
|
|
|
*/
|
|
|
|
export interface ViewDecorator extends TypeDecorator {
|
|
|
|
/**
|
2015-08-14 10:03:45 -07:00
|
|
|
* Chain {@link ViewMetadata} annotation.
|
2015-07-07 08:15:58 +02:00
|
|
|
*/
|
2015-07-07 22:09:19 +02:00
|
|
|
View(obj: {
|
|
|
|
templateUrl?: string,
|
|
|
|
template?: string,
|
|
|
|
directives?: List<Type | any | List<any>>,
|
2015-08-07 11:41:38 -07:00
|
|
|
pipes?: List<Type | any | List<any>>,
|
2015-07-07 22:09:19 +02:00
|
|
|
renderer?: string,
|
|
|
|
styles?: List<string>,
|
|
|
|
styleUrls?: List<string>,
|
2015-07-15 12:12:23 -07:00
|
|
|
}): ViewDecorator;
|
2015-07-07 08:15:58 +02:00
|
|
|
}
|
2015-06-12 23:51:42 -07:00
|
|
|
|
2015-07-07 08:15:58 +02:00
|
|
|
/**
|
2015-08-14 10:03:45 -07:00
|
|
|
* {@link DirectiveMetadata} factory for creating annotations, decorators or DSL.
|
2015-07-07 08:15:58 +02:00
|
|
|
*
|
|
|
|
* ## Example as TypeScript Decorator
|
|
|
|
*
|
|
|
|
* ```
|
|
|
|
* import {Directive} from "angular2/angular2";
|
|
|
|
*
|
|
|
|
* @Directive({...})
|
|
|
|
* class MyDirective {
|
|
|
|
* constructor() {
|
|
|
|
* ...
|
|
|
|
* }
|
|
|
|
* }
|
|
|
|
* ```
|
|
|
|
*
|
|
|
|
* ## Example as ES5 DSL
|
|
|
|
*
|
|
|
|
* ```
|
|
|
|
* var MyDirective = ng
|
|
|
|
* .Directive({...})
|
|
|
|
* .Class({
|
|
|
|
* constructor: function() {
|
|
|
|
* ...
|
|
|
|
* }
|
|
|
|
* })
|
|
|
|
* ```
|
|
|
|
*
|
|
|
|
* ## Example as ES5 annotation
|
|
|
|
*
|
|
|
|
* ```
|
|
|
|
* var MyDirective = function() {
|
|
|
|
* ...
|
|
|
|
* };
|
|
|
|
*
|
|
|
|
* MyDirective.annotations = [
|
|
|
|
* new ng.Directive({...})
|
|
|
|
* ]
|
|
|
|
* ```
|
|
|
|
*/
|
2015-07-02 22:26:07 +02:00
|
|
|
export interface DirectiveFactory {
|
2015-07-07 22:09:19 +02:00
|
|
|
(obj: {
|
|
|
|
selector?: string, properties?: List<string>, events?: List<string>,
|
2015-07-29 15:01:22 -07:00
|
|
|
host?: StringMap<string, string>, lifecycle?: List<LifecycleEvent>, bindings?: List<any>,
|
|
|
|
exportAs?: string, compileChildren?: boolean;
|
2015-07-07 22:09:19 +02:00
|
|
|
}): DirectiveDecorator;
|
|
|
|
new (obj: {
|
|
|
|
selector?: string, properties?: List<string>, events?: List<string>,
|
2015-07-29 15:01:22 -07:00
|
|
|
host?: StringMap<string, string>, lifecycle?: List<LifecycleEvent>, bindings?: List<any>,
|
|
|
|
exportAs?: string, compileChildren?: boolean;
|
2015-08-14 10:03:45 -07:00
|
|
|
}): DirectiveMetadata;
|
2015-06-12 23:51:42 -07:00
|
|
|
}
|
|
|
|
|
2015-07-07 08:15:58 +02:00
|
|
|
/**
|
|
|
|
* {@link ComponentAnnotation} factory for creating annotations, decorators or DSL.
|
|
|
|
*
|
|
|
|
* ## Example as TypeScript Decorator
|
|
|
|
*
|
|
|
|
* ```
|
|
|
|
* import {Component, View} from "angular2/angular2";
|
|
|
|
*
|
|
|
|
* @Component({...})
|
|
|
|
* @View({...})
|
|
|
|
* class MyComponent {
|
|
|
|
* constructor() {
|
|
|
|
* ...
|
|
|
|
* }
|
|
|
|
* }
|
|
|
|
* ```
|
|
|
|
*
|
|
|
|
* ## Example as ES5 DSL
|
|
|
|
*
|
|
|
|
* ```
|
|
|
|
* var MyComponent = ng
|
|
|
|
* .Component({...})
|
|
|
|
* .View({...})
|
|
|
|
* .Class({
|
|
|
|
* constructor: function() {
|
|
|
|
* ...
|
|
|
|
* }
|
|
|
|
* })
|
|
|
|
* ```
|
|
|
|
*
|
|
|
|
* ## Example as ES5 annotation
|
|
|
|
*
|
|
|
|
* ```
|
|
|
|
* var MyComponent = function() {
|
|
|
|
* ...
|
|
|
|
* };
|
|
|
|
*
|
|
|
|
* MyComponent.annotations = [
|
2015-08-19 11:42:59 +02:00
|
|
|
* new ng.Component({...}),
|
2015-07-07 08:15:58 +02:00
|
|
|
* new ng.View({...})
|
|
|
|
* ]
|
|
|
|
* ```
|
|
|
|
*/
|
2015-07-02 22:26:07 +02:00
|
|
|
export interface ComponentFactory {
|
2015-07-07 22:09:19 +02:00
|
|
|
(obj: {
|
|
|
|
selector?: string,
|
|
|
|
properties?: List<string>,
|
|
|
|
events?: List<string>,
|
|
|
|
host?: StringMap<string, string>,
|
|
|
|
lifecycle?: List<LifecycleEvent>,
|
2015-07-29 15:01:22 -07:00
|
|
|
bindings?: List<any>,
|
2015-07-07 22:09:19 +02:00
|
|
|
exportAs?: string,
|
|
|
|
compileChildren?: boolean,
|
2015-07-29 15:01:22 -07:00
|
|
|
viewBindings?: List<any>,
|
2015-08-26 11:44:59 -07:00
|
|
|
changeDetection?: ChangeDetectionStrategy,
|
2015-07-07 22:09:19 +02:00
|
|
|
}): ComponentDecorator;
|
|
|
|
new (obj: {
|
|
|
|
selector?: string,
|
|
|
|
properties?: List<string>,
|
|
|
|
events?: List<string>,
|
|
|
|
host?: StringMap<string, string>,
|
|
|
|
lifecycle?: List<LifecycleEvent>,
|
2015-07-29 15:01:22 -07:00
|
|
|
bindings?: List<any>,
|
2015-07-07 22:09:19 +02:00
|
|
|
exportAs?: string,
|
|
|
|
compileChildren?: boolean,
|
2015-07-29 15:01:22 -07:00
|
|
|
viewBindings?: List<any>,
|
2015-08-26 11:44:59 -07:00
|
|
|
changeDetection?: ChangeDetectionStrategy,
|
2015-08-14 10:03:45 -07:00
|
|
|
}): ComponentMetadata;
|
2015-06-12 23:51:42 -07:00
|
|
|
}
|
|
|
|
|
2015-07-07 08:15:58 +02:00
|
|
|
/**
|
|
|
|
* {@link ViewAnnotation} factory for creating annotations, decorators or DSL.
|
|
|
|
*
|
|
|
|
* ## Example as TypeScript Decorator
|
|
|
|
*
|
|
|
|
* ```
|
|
|
|
* import {Component, View} from "angular2/angular2";
|
|
|
|
*
|
|
|
|
* @Component({...})
|
|
|
|
* @View({...})
|
|
|
|
* class MyComponent {
|
|
|
|
* constructor() {
|
|
|
|
* ...
|
|
|
|
* }
|
|
|
|
* }
|
|
|
|
* ```
|
|
|
|
*
|
|
|
|
* ## Example as ES5 DSL
|
|
|
|
*
|
|
|
|
* ```
|
|
|
|
* var MyComponent = ng
|
|
|
|
* .Component({...})
|
|
|
|
* .View({...})
|
|
|
|
* .Class({
|
|
|
|
* constructor: function() {
|
|
|
|
* ...
|
|
|
|
* }
|
|
|
|
* })
|
|
|
|
* ```
|
|
|
|
*
|
|
|
|
* ## Example as ES5 annotation
|
|
|
|
*
|
|
|
|
* ```
|
|
|
|
* var MyComponent = function() {
|
|
|
|
* ...
|
|
|
|
* };
|
|
|
|
*
|
|
|
|
* MyComponent.annotations = [
|
2015-08-19 11:42:59 +02:00
|
|
|
* new ng.Component({...}),
|
2015-07-07 08:15:58 +02:00
|
|
|
* new ng.View({...})
|
|
|
|
* ]
|
|
|
|
* ```
|
|
|
|
*/
|
2015-07-02 22:26:07 +02:00
|
|
|
export interface ViewFactory {
|
2015-07-07 22:09:19 +02:00
|
|
|
(obj: {
|
|
|
|
templateUrl?: string,
|
|
|
|
template?: string,
|
|
|
|
directives?: List<Type | any | List<any>>,
|
2015-07-24 15:28:44 -07:00
|
|
|
encapsulation?: ViewEncapsulation,
|
2015-07-07 22:09:19 +02:00
|
|
|
styles?: List<string>,
|
|
|
|
styleUrls?: List<string>,
|
|
|
|
}): ViewDecorator;
|
|
|
|
new (obj: {
|
|
|
|
templateUrl?: string,
|
|
|
|
template?: string,
|
|
|
|
directives?: List<Type | any | List<any>>,
|
2015-07-24 15:28:44 -07:00
|
|
|
encapsulation?: ViewEncapsulation,
|
2015-07-07 22:09:19 +02:00
|
|
|
styles?: List<string>,
|
|
|
|
styleUrls?: List<string>,
|
2015-08-14 10:03:45 -07:00
|
|
|
}): ViewMetadata;
|
2015-06-12 23:51:42 -07:00
|
|
|
}
|
|
|
|
|
2015-07-07 08:15:58 +02:00
|
|
|
/**
|
2015-08-14 10:03:45 -07:00
|
|
|
* {@link AttributeMetadata} factory for creating annotations, decorators or DSL.
|
2015-07-07 08:15:58 +02:00
|
|
|
*
|
|
|
|
* ## Example as TypeScript Decorator
|
|
|
|
*
|
|
|
|
* ```
|
|
|
|
* import {Attribute, Component, View} from "angular2/angular2";
|
|
|
|
*
|
|
|
|
* @Component({...})
|
|
|
|
* @View({...})
|
|
|
|
* class MyComponent {
|
|
|
|
* constructor(@Attribute('title') title: string) {
|
|
|
|
* ...
|
|
|
|
* }
|
|
|
|
* }
|
|
|
|
* ```
|
|
|
|
*
|
|
|
|
* ## Example as ES5 DSL
|
|
|
|
*
|
|
|
|
* ```
|
|
|
|
* var MyComponent = ng
|
|
|
|
* .Component({...})
|
|
|
|
* .View({...})
|
|
|
|
* .Class({
|
|
|
|
* constructor: [new ng.Attribute('title'), function(title) {
|
|
|
|
* ...
|
|
|
|
* }]
|
|
|
|
* })
|
|
|
|
* ```
|
|
|
|
*
|
|
|
|
* ## Example as ES5 annotation
|
|
|
|
*
|
|
|
|
* ```
|
|
|
|
* var MyComponent = function(title) {
|
|
|
|
* ...
|
|
|
|
* };
|
|
|
|
*
|
|
|
|
* MyComponent.annotations = [
|
2015-08-19 11:42:59 +02:00
|
|
|
* new ng.Component({...}),
|
2015-07-07 08:15:58 +02:00
|
|
|
* new ng.View({...})
|
|
|
|
* ]
|
|
|
|
* MyComponent.parameters = [
|
|
|
|
* [new ng.Attribute('title')]
|
|
|
|
* ]
|
|
|
|
* ```
|
|
|
|
*/
|
2015-07-02 22:26:07 +02:00
|
|
|
export interface AttributeFactory {
|
|
|
|
(name: string): TypeDecorator;
|
2015-08-14 10:03:45 -07:00
|
|
|
new (name: string): AttributeMetadata;
|
2015-07-02 22:26:07 +02:00
|
|
|
}
|
|
|
|
|
2015-07-07 08:15:58 +02:00
|
|
|
/**
|
2015-08-14 10:03:45 -07:00
|
|
|
* {@link QueryMetadata} factory for creating annotations, decorators or DSL.
|
2015-07-07 08:15:58 +02:00
|
|
|
*
|
|
|
|
* ## Example as TypeScript Decorator
|
|
|
|
*
|
|
|
|
* ```
|
|
|
|
* import {Query, QueryList, Component, View} from "angular2/angular2";
|
|
|
|
*
|
|
|
|
* @Component({...})
|
|
|
|
* @View({...})
|
|
|
|
* class MyComponent {
|
|
|
|
* constructor(@Query(SomeType) queryList: QueryList) {
|
|
|
|
* ...
|
|
|
|
* }
|
|
|
|
* }
|
|
|
|
* ```
|
|
|
|
*
|
|
|
|
* ## Example as ES5 DSL
|
|
|
|
*
|
|
|
|
* ```
|
|
|
|
* var MyComponent = ng
|
|
|
|
* .Component({...})
|
|
|
|
* .View({...})
|
|
|
|
* .Class({
|
|
|
|
* constructor: [new ng.Query(SomeType), function(queryList) {
|
|
|
|
* ...
|
|
|
|
* }]
|
|
|
|
* })
|
|
|
|
* ```
|
|
|
|
*
|
|
|
|
* ## Example as ES5 annotation
|
|
|
|
*
|
|
|
|
* ```
|
|
|
|
* var MyComponent = function(queryList) {
|
|
|
|
* ...
|
|
|
|
* };
|
|
|
|
*
|
|
|
|
* MyComponent.annotations = [
|
2015-08-19 11:42:59 +02:00
|
|
|
* new ng.Component({...}),
|
2015-07-07 08:15:58 +02:00
|
|
|
* new ng.View({...})
|
|
|
|
* ]
|
|
|
|
* MyComponent.parameters = [
|
|
|
|
* [new ng.Query(SomeType)]
|
|
|
|
* ]
|
|
|
|
* ```
|
|
|
|
*/
|
2015-07-02 22:26:07 +02:00
|
|
|
export interface QueryFactory {
|
|
|
|
(selector: Type | string, {descendants}?: {descendants?: boolean}): ParameterDecorator;
|
2015-08-14 10:03:45 -07:00
|
|
|
new (selector: Type | string, {descendants}?: {descendants?: boolean}): QueryMetadata;
|
2015-07-02 22:26:07 +02:00
|
|
|
}
|
|
|
|
|
2015-08-07 11:41:38 -07:00
|
|
|
/**
|
2015-08-14 10:03:45 -07:00
|
|
|
* {@link PipeMetadata} factory for creating decorators.
|
2015-08-07 11:41:38 -07:00
|
|
|
*
|
|
|
|
* ## Example as TypeScript Decorator
|
|
|
|
*
|
|
|
|
* ```
|
|
|
|
* import {Pipe} from "angular2/angular2";
|
|
|
|
*
|
|
|
|
* @Pipe({...})
|
|
|
|
* class MyPipe {
|
|
|
|
* constructor() {
|
|
|
|
* ...
|
|
|
|
* }
|
|
|
|
*
|
|
|
|
* transform(v, args) {}
|
|
|
|
* }
|
|
|
|
* ```
|
|
|
|
*/
|
|
|
|
export interface PipeFactory {
|
|
|
|
(obj: {name: string}): any;
|
|
|
|
new (obj: {
|
|
|
|
name: string,
|
|
|
|
}): any;
|
|
|
|
}
|
2015-05-04 11:11:22 -07:00
|
|
|
|
2015-07-07 08:15:58 +02:00
|
|
|
/**
|
2015-08-14 10:03:45 -07:00
|
|
|
* {@link ComponentMetadata} factory function.
|
2015-07-07 08:15:58 +02:00
|
|
|
*/
|
2015-07-02 22:26:07 +02:00
|
|
|
export var Component: ComponentFactory =
|
2015-08-14 10:03:45 -07:00
|
|
|
<ComponentFactory>makeDecorator(ComponentMetadata, (fn: any) => fn.View = View);
|
2015-07-07 08:15:58 +02:00
|
|
|
/**
|
2015-08-14 10:03:45 -07:00
|
|
|
* {@link DirectiveMetadata} factory function.
|
2015-07-07 08:15:58 +02:00
|
|
|
*/
|
2015-08-14 10:03:45 -07:00
|
|
|
export var Directive: DirectiveFactory = <DirectiveFactory>makeDecorator(DirectiveMetadata);
|
2015-05-04 11:11:22 -07:00
|
|
|
|
2015-07-07 08:15:58 +02:00
|
|
|
/**
|
2015-08-14 10:03:45 -07:00
|
|
|
* {@link ViewMetadata} factory function.
|
2015-07-07 08:15:58 +02:00
|
|
|
*/
|
2015-07-02 22:26:07 +02:00
|
|
|
export var View: ViewFactory =
|
2015-08-14 10:03:45 -07:00
|
|
|
<ViewFactory>makeDecorator(ViewMetadata, (fn: any) => fn.View = View);
|
2015-05-04 11:11:22 -07:00
|
|
|
|
2015-07-07 08:15:58 +02:00
|
|
|
/**
|
2015-08-14 10:03:45 -07:00
|
|
|
* {@link AttributeMetadata} factory function.
|
2015-07-07 08:15:58 +02:00
|
|
|
*/
|
2015-08-14 10:03:45 -07:00
|
|
|
export var Attribute: AttributeFactory = makeParamDecorator(AttributeMetadata);
|
2015-07-07 08:15:58 +02:00
|
|
|
|
|
|
|
/**
|
2015-08-14 10:03:45 -07:00
|
|
|
* {@link QueryMetadata} factory function.
|
2015-07-07 08:15:58 +02:00
|
|
|
*/
|
2015-08-14 10:03:45 -07:00
|
|
|
export var Query: QueryFactory = makeParamDecorator(QueryMetadata);
|
2015-07-10 10:30:31 -07:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
2015-08-18 16:32:56 -07:00
|
|
|
* {@link di/ViewQueryMetadata} factory function.
|
2015-07-10 10:30:31 -07:00
|
|
|
*/
|
2015-08-14 10:03:45 -07:00
|
|
|
export var ViewQuery: QueryFactory = makeParamDecorator(ViewQueryMetadata);
|
2015-08-07 11:41:38 -07:00
|
|
|
|
|
|
|
/**
|
2015-08-14 10:03:45 -07:00
|
|
|
* {@link PipeMetadata} factory function.
|
2015-08-07 11:41:38 -07:00
|
|
|
*/
|
2015-08-14 10:03:45 -07:00
|
|
|
export var Pipe: PipeFactory = <PipeFactory>makeDecorator(PipeMetadata);
|