2016-06-23 09:47:54 -07:00
|
|
|
/**
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright Google Inc. 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
|
|
|
|
|
*/
|
|
|
|
|
|
2016-05-25 12:46:22 -07:00
|
|
|
import {AnimationEntryMetadata} from '../animation/metadata';
|
2015-07-24 15:28:44 -07:00
|
|
|
|
2015-10-05 10:10:07 -07:00
|
|
|
/**
|
2016-07-07 23:02:35 -07:00
|
|
|
* Defines template and style encapsulation options available for Component's {@link Component}.
|
2015-10-05 10:10:07 -07:00
|
|
|
*
|
|
|
|
|
* See {@link ViewMetadata#encapsulation}.
|
2016-05-25 15:00:05 -07:00
|
|
|
* @stable
|
2015-10-05 10:10:07 -07:00
|
|
|
*/
|
|
|
|
|
export enum ViewEncapsulation {
|
|
|
|
|
/**
|
|
|
|
|
* Emulate `Native` scoping of styles by adding an attribute containing surrogate id to the Host
|
|
|
|
|
* Element and pre-processing the style rules provided via
|
|
|
|
|
* {@link ViewMetadata#styles} or {@link ViewMetadata#stylesUrls}, and adding the new Host Element
|
|
|
|
|
* attribute to all selectors.
|
|
|
|
|
*
|
|
|
|
|
* This is the default option.
|
|
|
|
|
*/
|
|
|
|
|
Emulated,
|
|
|
|
|
/**
|
|
|
|
|
* Use the native encapsulation mechanism of the renderer.
|
|
|
|
|
*
|
|
|
|
|
* For the DOM this means using [Shadow DOM](https://w3c.github.io/webcomponents/spec/shadow/) and
|
|
|
|
|
* creating a ShadowRoot for Component's Host Element.
|
|
|
|
|
*/
|
|
|
|
|
Native,
|
|
|
|
|
/**
|
|
|
|
|
* Don't provide any template or style encapsulation.
|
|
|
|
|
*/
|
|
|
|
|
None
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-17 19:22:13 +00:00
|
|
|
/**
|
2015-09-28 19:58:38 -07:00
|
|
|
* Metadata properties available for configuring Views.
|
2015-03-30 17:19:27 -07:00
|
|
|
*
|
2016-09-12 19:14:17 -07:00
|
|
|
* For details on the `@Component` annotation, see {@link Component}.
|
2015-03-30 17:19:27 -07:00
|
|
|
*
|
2015-10-19 15:37:32 +01:00
|
|
|
* ### Example
|
2015-03-30 17:19:27 -07:00
|
|
|
*
|
|
|
|
|
* ```
|
|
|
|
|
* @Component({
|
2015-10-11 07:41:19 -07:00
|
|
|
* selector: 'greet',
|
2015-04-10 11:15:01 -07:00
|
|
|
* template: 'Hello {{name}}!',
|
2015-03-30 17:19:27 -07:00
|
|
|
* })
|
|
|
|
|
* class Greet {
|
|
|
|
|
* name: string;
|
|
|
|
|
*
|
|
|
|
|
* constructor() {
|
|
|
|
|
* this.name = 'World';
|
|
|
|
|
* }
|
|
|
|
|
* }
|
|
|
|
|
* ```
|
2016-06-27 12:27:23 -07:00
|
|
|
*
|
2016-09-12 19:14:17 -07:00
|
|
|
* @deprecated Use Component instead.
|
2016-09-20 14:14:57 -07:00
|
|
|
*
|
|
|
|
|
* {@link Component}
|
2015-03-17 19:22:13 +00:00
|
|
|
*/
|
2015-08-14 10:03:45 -07:00
|
|
|
export class ViewMetadata {
|
2016-09-20 14:14:57 -07:00
|
|
|
/** {@link Component.templateUrl} */
|
2015-07-06 16:32:29 -07:00
|
|
|
templateUrl: string;
|
2016-09-20 14:14:57 -07:00
|
|
|
/** {@link Component.template} */
|
2015-07-07 22:09:19 +02:00
|
|
|
template: string;
|
2016-09-20 14:14:57 -07:00
|
|
|
/** {@link Component.stylesUrl} */
|
2015-08-28 11:29:19 -07:00
|
|
|
styleUrls: string[];
|
2016-09-20 14:14:57 -07:00
|
|
|
/** {@link Component.styles} */
|
2015-08-28 11:29:19 -07:00
|
|
|
styles: string[];
|
2016-09-20 14:14:57 -07:00
|
|
|
/** {@link Component.encapsulation} */
|
2015-07-24 15:28:44 -07:00
|
|
|
encapsulation: ViewEncapsulation;
|
2016-09-20 14:14:57 -07:00
|
|
|
/** {@link Component.animation} */
|
2016-05-25 12:46:22 -07:00
|
|
|
animations: AnimationEntryMetadata[];
|
2016-09-20 14:14:57 -07:00
|
|
|
/** {@link Component.interpolation} */
|
2016-06-20 09:52:41 -07:00
|
|
|
interpolation: [string, string];
|
|
|
|
|
|
2016-06-08 16:38:52 -07:00
|
|
|
constructor(
|
2016-08-19 13:51:45 -07:00
|
|
|
{templateUrl, template, encapsulation, styles, styleUrls, animations, interpolation}: {
|
2016-06-08 16:38:52 -07:00
|
|
|
templateUrl?: string,
|
|
|
|
|
template?: string,
|
|
|
|
|
encapsulation?: ViewEncapsulation,
|
|
|
|
|
styles?: string[],
|
|
|
|
|
styleUrls?: string[],
|
2016-06-20 09:52:41 -07:00
|
|
|
animations?: AnimationEntryMetadata[],
|
|
|
|
|
interpolation?: [string, string]
|
2016-06-08 16:38:52 -07:00
|
|
|
} = {}) {
|
2015-07-07 22:09:19 +02:00
|
|
|
this.templateUrl = templateUrl;
|
|
|
|
|
this.template = template;
|
|
|
|
|
this.styleUrls = styleUrls;
|
|
|
|
|
this.styles = styles;
|
2015-07-24 15:28:44 -07:00
|
|
|
this.encapsulation = encapsulation;
|
2016-05-25 12:46:22 -07:00
|
|
|
this.animations = animations;
|
2016-06-20 09:52:41 -07:00
|
|
|
this.interpolation = interpolation;
|
2015-07-07 22:09:19 +02:00
|
|
|
}
|
2015-06-12 23:51:42 -07:00
|
|
|
}
|