diff --git a/package.json b/package.json index 447e137469..eeac9f9335 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "flow.changelog": "conventional-changelog -i CHANGELOG.md -s -p angular -v", "flow.github-release": "conventional-github-releaser -p angular", "build": "ngm build -p src", + "build.watch": "ngm build -p src --watch --skip-bundles", "start": "ng serve --aot", "generate-bs4": "node scripts/generate-bs4.js", "pretest": "run-s lint build link", @@ -90,7 +91,7 @@ "lodash": "4.17.2", "markdown-loader": "github:valorkin/markdown-loader", "marked": "0.3.6", - "ngm-cli": "0.3.4", + "ngm-cli": "^0.3.6", "npm-run-all": "3.1.2", "pre-commit": "1.2.1", "protractor": "4.0.13", diff --git a/src/component-loader/component-loader.class.ts b/src/component-loader/component-loader.class.ts index 6c4114aa9f..5c7af43a6c 100644 --- a/src/component-loader/component-loader.class.ts +++ b/src/component-loader/component-loader.class.ts @@ -3,7 +3,8 @@ // todo: add global positioning configuration? import { NgZone, ViewContainerRef, ComponentFactoryResolver, Injector, Renderer, - ElementRef, ComponentRef, ComponentFactory, Type, TemplateRef, EventEmitter + ElementRef, ComponentRef, ComponentFactory, Type, TemplateRef, EventEmitter, + Provider, ReflectiveInjector } from '@angular/core'; import { ContentRef } from './content-ref.class'; import { PositioningService, PositioningOptions } from '../positioning'; @@ -26,6 +27,7 @@ export class ComponentLoader { public instance: T; public _componentRef: ComponentRef; + private _providers: Provider[] = []; private _componentFactory: ComponentFactory; private _elementRef: ElementRef; private _zoneSubscription: any; @@ -104,14 +106,20 @@ export class ComponentLoader { return this; } + public provide(provider: Provider): ComponentLoader { + this._providers.push(provider); + return this; + } + public show(content?: string | TemplateRef, mixin?: any): ComponentRef { this._subscribePositioning(); if (!this._componentRef) { this.onBeforeShow.emit(); this._contentRef = this._getContentRef(content); + const injector = ReflectiveInjector.resolveAndCreate(this._providers, this._injector); this._componentRef = this._viewContainerRef - .createComponent(this._componentFactory, 0, this._injector, this._contentRef.nodes); + .createComponent(this._componentFactory, 0, injector, this._contentRef.nodes); this.instance = this._componentRef.instance; Object.assign(this._componentRef.instance, mixin || {}); diff --git a/src/popover/popover-container.component.ts b/src/popover/popover-container.component.ts index c1018838ea..1758b73d92 100644 --- a/src/popover/popover-container.component.ts +++ b/src/popover/popover-container.component.ts @@ -1,4 +1,5 @@ import { ChangeDetectionStrategy, Input, Component } from '@angular/core'; +import { PopoverConfig } from './popover-config'; @Component({ selector: 'popover-container', @@ -11,6 +12,10 @@ import { ChangeDetectionStrategy, Input, Component } from '@angular/core'; ` }) export class PopoverContainerComponent { - @Input() public placement: string = 'top'; + @Input() public placement: string; @Input() public title: string; + + public constructor(config: PopoverConfig) { + Object.assign(this, config); + } } diff --git a/src/popover/popover.directive.ts b/src/popover/popover.directive.ts index a2331d602b..e3968d7d9c 100644 --- a/src/popover/popover.directive.ts +++ b/src/popover/popover.directive.ts @@ -61,7 +61,8 @@ export class PopoverDirective implements OnInit, OnDestroy { _config: PopoverConfig, cis: ComponentLoaderFactory) { this._popover = cis - .createLoader(_elementRef, _viewContainerRef, _renderer); + .createLoader(_elementRef, _viewContainerRef, _renderer) + .provide({provide: PopoverConfig, useValue: _config}); Object.assign(this, _config); this.onShown = this._popover.onShown; this.onHidden = this._popover.onHidden; diff --git a/src/tooltip/tooltip-container.component.ts b/src/tooltip/tooltip-container.component.ts index 58153c8b09..c2b4dfecac 100644 --- a/src/tooltip/tooltip-container.component.ts +++ b/src/tooltip/tooltip-container.component.ts @@ -1,13 +1,16 @@ import { - AfterViewInit, ChangeDetectorRef, Component, ElementRef, TemplateRef, - ChangeDetectionStrategy + AfterViewInit, Component, ChangeDetectionStrategy, Inject } from '@angular/core'; +import { TooltipConfig } from './tooltip.config'; @Component({ selector: 'bs-tooltip-container', changeDetection: ChangeDetectionStrategy.OnPush, // tslint:disable-next-line - host: {'[class]': '"tooltip in tooltip-" + placement + " " + placement', role: 'tooltip'}, + host: { + '[class]': '"tooltip in tooltip-" + placement + " " + placement', + role: 'tooltip' + }, template: `
@@ -38,6 +41,10 @@ export class TooltipContainerComponent implements AfterViewInit { public popupClass: string; public animation: boolean; + public constructor(config: TooltipConfig) { + Object.assign(this, config); + } + public ngAfterViewInit(): void { this.classMap = {in: false, fade: false}; this.classMap[this.placement] = true; diff --git a/src/tooltip/tooltip.directive.ts b/src/tooltip/tooltip.directive.ts index 6551e86987..716489c72d 100644 --- a/src/tooltip/tooltip.directive.ts +++ b/src/tooltip/tooltip.directive.ts @@ -47,7 +47,7 @@ export class TooltipDirective implements OnInit, OnDestroy { /** * Allows to disable tooltip */ - @Input() public isDisabled:boolean; + @Input() public isDisabled: boolean; /** * Emits an event when the tooltip is shown @@ -60,54 +60,67 @@ export class TooltipDirective implements OnInit, OnDestroy { /* tslint:disable */ /** @deprecated */ - @Input('tooltipHtml') public set htmlContent(value: string | TemplateRef){ + @Input('tooltipHtml') + public set htmlContent(value: string | TemplateRef) { console.warn('tooltipHtml was deprecated, please use `tooltip` instead'); this.tooltip = value; } + /** @deprecated */ - @Input('tooltipPlacement') public set _placement(value: string){ + @Input('tooltipPlacement') + public set _placement(value: string) { console.warn('tooltipPlacement was deprecated, please use `placement` instead'); this.placement = value; } + /** @deprecated */ - @Input('tooltipIsOpen') public set _isOpen(value:boolean) { + @Input('tooltipIsOpen') + public set _isOpen(value: boolean) { console.warn('tooltipIsOpen was deprecated, please use `isOpen` instead'); this.isOpen = value; } - public get _isOpen():boolean { + + public get _isOpen(): boolean { console.warn('tooltipIsOpen was deprecated, please use `isOpen` instead'); return this.isOpen; } /** @deprecated */ - @Input('tooltipEnable') public set _enable(value: boolean){ + @Input('tooltipEnable') + public set _enable(value: boolean) { console.warn('tooltipEnable was deprecated, please use `isDisabled` instead'); this.isDisabled = value === true; } - public get _enable(): boolean{ + + public get _enable(): boolean { console.warn('tooltipEnable was deprecated, please use `isDisabled` instead'); return this.isDisabled === true; } /** @deprecated */ - @Input('tooltipAppendToBody') public set _appendToBody(value: boolean) { + @Input('tooltipAppendToBody') + public set _appendToBody(value: boolean) { console.warn('tooltipAppendToBody was deprecated, please use `container="body"` instead'); this.container = value ? 'body' : this.container; } - public get _appendToBody():boolean { + public get _appendToBody(): boolean { console.warn('tooltipAppendToBody was deprecated, please use `container="body"` instead'); return this.container === 'body'; } /** @deprecated */ @Input('tooltipAnimation') public _animation: boolean = true; + /** @deprecated */ - @Input('tooltipClass') public set _popupClass(value: string){ + @Input('tooltipClass') + public set _popupClass(value: string) { console.warn('tooltipClass deprecated'); } + /** @deprecated */ - @Input('tooltipContext') public set _tooltipContext(value: any){ + @Input('tooltipContext') + public set _tooltipContext(value: any) { console.warn('tooltipContext deprecated'); } @@ -117,15 +130,17 @@ export class TooltipDirective implements OnInit, OnDestroy { @Input('tooltipFadeDuration') public _fadeDuration: number = 150; /** @deprecated */ - @Input('tooltipTrigger') public get _tooltipTrigger():string|Array{ + @Input('tooltipTrigger') + public get _tooltipTrigger(): string|Array { console.warn('tooltipTrigger was deprecated, please use `triggers` instead'); return this.triggers; }; - public set _tooltipTrigger(value:string|Array){ + public set _tooltipTrigger(value: string|Array) { console.warn('tooltipTrigger was deprecated, please use `triggers` instead'); this.triggers = (value || '').toString(); }; + /* tslint:enable */ @Output() public tooltipStateChanged: EventEmitter = new EventEmitter(); @@ -141,7 +156,8 @@ export class TooltipDirective implements OnInit, OnDestroy { cis: ComponentLoaderFactory, config: TooltipConfig) { this._tooltip = cis - .createLoader(_elementRef, _viewContainerRef, _renderer); + .createLoader(_elementRef, _viewContainerRef, _renderer) + .provide({provide: TooltipConfig, useValue: config}); Object.assign(this, config); this.onShown = this._tooltip.onShown; diff --git a/yarn.lock b/yarn.lock index 12e98a037e..25b6a12506 100644 --- a/yarn.lock +++ b/yarn.lock @@ -129,14 +129,14 @@ version "2.0.29" resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-2.0.29.tgz#5002e14f75e2d71e564281df0431c8c1b4a2a36a" -"@types/node@*", "@types/node@6.0.49": - version "6.0.49" - resolved "https://registry.yarnpkg.com/@types/node/-/node-6.0.49.tgz#c644f7305e0d64bd797c939af833f22d150e1d33" - -"@types/node@6.0.48", "@types/node@^6.0.46": +"@types/node@*", "@types/node@6.0.48", "@types/node@^6.0.46": version "6.0.48" resolved "https://registry.yarnpkg.com/@types/node/-/node-6.0.48.tgz#86ccc15f66b73cbbc5eb3483398936c585122b3c" +"@types/node@6.0.49": + version "6.0.49" + resolved "https://registry.yarnpkg.com/@types/node/-/node-6.0.49.tgz#c644f7305e0d64bd797c939af833f22d150e1d33" + "@types/q@^0.0.32": version "0.0.32" resolved "https://registry.yarnpkg.com/@types/q/-/q-0.0.32.tgz#bd284e57c84f1325da702babfc82a5328190c0c5" @@ -609,7 +609,7 @@ async@2.0.0-rc.4: dependencies: lodash "^4.3.0" -async@2.0.1: +async@2.0.1, async@^2.0.0, async@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/async/-/async-2.0.1.tgz#b709cc0280a9c36f09f4536be823c838a9049e25" dependencies: @@ -619,7 +619,7 @@ async@^0.9.0, async@~0.9.0: version "0.9.2" resolved "https://registry.yarnpkg.com/async/-/async-0.9.2.tgz#aea74d5e61c1f899613bf64bda66d4c78f2fd17d" -async@^2.0.0, async@^2.0.1, async@^2.1.2: +async@^2.1.2: version "2.1.4" resolved "https://registry.yarnpkg.com/async/-/async-2.1.4.tgz#2d2160c7788032e4dd6cbe2502f1f9a2c8f6cde4" dependencies: @@ -4994,14 +4994,14 @@ nested-error-stacks@^2.0.0: dependencies: inherits "~2.0.1" -ngm-cli@0.3.4: - version "0.3.4" - resolved "https://registry.yarnpkg.com/ngm-cli/-/ngm-cli-0.3.4.tgz#adcbedcc84a444b246aaa9cf34672403b7174a14" +ngm-cli@^0.3.6: + version "0.3.6" + resolved "https://registry.yarnpkg.com/ngm-cli/-/ngm-cli-0.3.6.tgz#790a1f1b9153295973d729f542baa61cf7552ce4" dependencies: "@angular/compiler-cli" "^2.2.0" "@angular/tsc-wrapped" "0.4.0" awesome-typescript-loader "3.0.0-beta.9" - npm-submodules "0.3.4" + npm-submodules "0.3.6" reflect-metadata "0.1.8" rxjs "5.0.0-beta.12" zone.js "0.7.2" @@ -5168,9 +5168,9 @@ npm-run-path@^2.0.0: dependencies: path-key "^2.0.0" -npm-submodules@0.3.4: - version "0.3.4" - resolved "https://registry.yarnpkg.com/npm-submodules/-/npm-submodules-0.3.4.tgz#76a725821a743083a8a1749ae37c3b0618ffbd47" +npm-submodules@0.3.6: + version "0.3.6" + resolved "https://registry.yarnpkg.com/npm-submodules/-/npm-submodules-0.3.6.tgz#b03254569f3f3acf6c7cc9d52ce31cbb65fe3f00" dependencies: "@angular/compiler" "^2.2.0" "@angular/core" "^2.2.0" @@ -5190,7 +5190,7 @@ npm-submodules@0.3.4: split "1.0.0" stream-to-observable "0.2.0" tsconfig "5.0.3" - typescript "2.0.10" + typescript "2.1.1" update-notifier "1.0.2" webpack "2.1.0-beta.27" write-pkg "2.0.0" @@ -7471,6 +7471,10 @@ typescript@2.0.6: version "2.0.6" resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.0.6.tgz#5385499ac9811508c2c43e0ea07a1ddca435e111" +typescript@2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.1.1.tgz#41c2b64472f529331b2055c0424862b44ce58d42" + ua-parser-js@0.7.10: version "0.7.10" resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.10.tgz#917559ddcce07cbc09ece7d80495e4c268f4ef9f"