| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575 |
- import { Injectable, Component, ChangeDetectionStrategy, Directive, ViewContainerRef, ElementRef, Renderer2, Input, Output, HostBinding, EventEmitter, NgModule } from '@angular/core';
- import { isBs3, warnOnce, parseTriggers, OnChange } from 'ngx-bootstrap/utils';
- import { __decorate, __metadata } from 'tslib';
- import { ComponentLoaderFactory } from 'ngx-bootstrap/component-loader';
- import { PositioningService } from 'ngx-bootstrap/positioning';
- import { timer } from 'rxjs';
- import { CommonModule } from '@angular/common';
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- /**
- * Default values provider for tooltip
- */
- var TooltipConfig = /** @class */ (function () {
- function TooltipConfig() {
- /**
- * sets disable adaptive position
- */
- this.adaptivePosition = true;
- /**
- * tooltip placement, supported positions: 'top', 'bottom', 'left', 'right'
- */
- this.placement = 'top';
- /**
- * array of event names which triggers tooltip opening
- */
- this.triggers = 'hover focus';
- /**
- * delay before showing the tooltip
- */
- this.delay = 0;
- }
- TooltipConfig.decorators = [
- { type: Injectable }
- ];
- return TooltipConfig;
- }());
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- var TooltipContainerComponent = /** @class */ (function () {
- function TooltipContainerComponent(config) {
- Object.assign(this, config);
- }
- Object.defineProperty(TooltipContainerComponent.prototype, "isBs3", {
- get: /**
- * @return {?}
- */
- function () {
- return isBs3();
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @return {?}
- */
- TooltipContainerComponent.prototype.ngAfterViewInit = /**
- * @return {?}
- */
- function () {
- this.classMap = { in: false, fade: false };
- this.classMap[this.placement] = true;
- this.classMap["tooltip-" + this.placement] = true;
- this.classMap.in = true;
- if (this.animation) {
- this.classMap.fade = true;
- }
- if (this.containerClass) {
- this.classMap[this.containerClass] = true;
- }
- };
- TooltipContainerComponent.decorators = [
- { type: Component, args: [{
- selector: 'bs-tooltip-container',
- changeDetection: ChangeDetectionStrategy.OnPush,
- // tslint:disable-next-line
- host: {
- '[class]': '"tooltip in tooltip-" + placement + " " + "bs-tooltip-" + placement + " " + placement + " " + containerClass',
- '[class.show]': '!isBs3',
- '[class.bs3]': 'isBs3',
- '[attr.id]': 'this.id',
- role: 'tooltip'
- },
- template: "\n <div class=\"tooltip-arrow arrow\"></div>\n <div class=\"tooltip-inner\"><ng-content></ng-content></div>\n ",
- styles: ["\n :host.tooltip {\n display: block;\n pointer-events: none;\n }\n :host.bs3.tooltip.top>.arrow {\n margin-left: -2px;\n }\n :host.bs3.tooltip.bottom {\n margin-top: 0px;\n }\n :host.bs3.bs-tooltip-left, :host.bs3.bs-tooltip-right{\n margin: 0px;\n }\n :host.bs3.bs-tooltip-right .arrow, :host.bs3.bs-tooltip-left .arrow {\n margin: .3rem 0;\n }\n "]
- }] }
- ];
- /** @nocollapse */
- TooltipContainerComponent.ctorParameters = function () { return [
- { type: TooltipConfig }
- ]; };
- return TooltipContainerComponent;
- }());
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- /** @type {?} */
- var id = 0;
- var TooltipDirective = /** @class */ (function () {
- function TooltipDirective(_viewContainerRef, cis, config, _elementRef, _renderer, _positionService) {
- this._elementRef = _elementRef;
- this._renderer = _renderer;
- this._positionService = _positionService;
- this.tooltipId = id++;
- /**
- * Fired when tooltip content changes
- */
- /* tslint:disable-next-line:no-any */
- this.tooltipChange = new EventEmitter();
- /**
- * Css class for tooltip container
- */
- this.containerClass = '';
- /**
- * @deprecated - removed, will be added to configuration
- */
- this.tooltipAnimation = true;
- /**
- * @deprecated
- */
- this.tooltipFadeDuration = 150;
- this.ariaDescribedby = "tooltip-" + this.tooltipId;
- /**
- * @deprecated
- */
- this.tooltipStateChanged = new EventEmitter();
- this._tooltip = cis
- .createLoader(this._elementRef, _viewContainerRef, this._renderer)
- .provide({ provide: TooltipConfig, useValue: config });
- Object.assign(this, config);
- this.onShown = this._tooltip.onShown;
- this.onHidden = this._tooltip.onHidden;
- }
- Object.defineProperty(TooltipDirective.prototype, "isOpen", {
- /**
- * Returns whether or not the tooltip is currently being shown
- */
- get: /**
- * Returns whether or not the tooltip is currently being shown
- * @return {?}
- */
- function () {
- return this._tooltip.isShown;
- },
- set: /**
- * @param {?} value
- * @return {?}
- */
- function (value) {
- if (value) {
- this.show();
- }
- else {
- this.hide();
- }
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(TooltipDirective.prototype, "htmlContent", {
- /** @deprecated - please use `tooltip` instead */
- set: /**
- * @deprecated - please use `tooltip` instead
- * @param {?} value
- * @return {?}
- */
- function (value) {
- warnOnce('tooltipHtml was deprecated, please use `tooltip` instead');
- this.tooltip = value;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(TooltipDirective.prototype, "_placement", {
- /** @deprecated - please use `placement` instead */
- set: /**
- * @deprecated - please use `placement` instead
- * @param {?} value
- * @return {?}
- */
- function (value) {
- warnOnce('tooltipPlacement was deprecated, please use `placement` instead');
- this.placement = value;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(TooltipDirective.prototype, "_isOpen", {
- get: /**
- * @return {?}
- */
- function () {
- warnOnce('tooltipIsOpen was deprecated, please use `isOpen` instead');
- return this.isOpen;
- },
- /** @deprecated - please use `isOpen` instead */
- set: /**
- * @deprecated - please use `isOpen` instead
- * @param {?} value
- * @return {?}
- */
- function (value) {
- warnOnce('tooltipIsOpen was deprecated, please use `isOpen` instead');
- this.isOpen = value;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(TooltipDirective.prototype, "_enable", {
- get: /**
- * @return {?}
- */
- function () {
- warnOnce('tooltipEnable was deprecated, please use `isDisabled` instead');
- return this.isDisabled;
- },
- /** @deprecated - please use `isDisabled` instead */
- set: /**
- * @deprecated - please use `isDisabled` instead
- * @param {?} value
- * @return {?}
- */
- function (value) {
- warnOnce('tooltipEnable was deprecated, please use `isDisabled` instead');
- this.isDisabled = !value;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(TooltipDirective.prototype, "_appendToBody", {
- get: /**
- * @return {?}
- */
- function () {
- warnOnce('tooltipAppendToBody was deprecated, please use `container="body"` instead');
- return this.container === 'body';
- },
- /** @deprecated - please use `container="body"` instead */
- set: /**
- * @deprecated - please use `container="body"` instead
- * @param {?} value
- * @return {?}
- */
- function (value) {
- warnOnce('tooltipAppendToBody was deprecated, please use `container="body"` instead');
- this.container = value ? 'body' : this.container;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(TooltipDirective.prototype, "_popupClass", {
- /** @deprecated - will replaced with customClass */
- set: /**
- * @deprecated - will replaced with customClass
- * @param {?} value
- * @return {?}
- */
- function (value) {
- warnOnce('tooltipClass deprecated');
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(TooltipDirective.prototype, "_tooltipContext", {
- /** @deprecated - removed */
- set: /**
- * @deprecated - removed
- * @param {?} value
- * @return {?}
- */
- function (value) {
- warnOnce('tooltipContext deprecated');
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(TooltipDirective.prototype, "_tooltipPopupDelay", {
- /** @deprecated */
- set: /**
- * @deprecated
- * @param {?} value
- * @return {?}
- */
- function (value) {
- warnOnce('tooltipPopupDelay is deprecated, use `delay` instead');
- this.delay = value;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(TooltipDirective.prototype, "_tooltipTrigger", {
- /** @deprecated - please use `triggers` instead */
- get: /**
- * @deprecated - please use `triggers` instead
- * @return {?}
- */
- function () {
- warnOnce('tooltipTrigger was deprecated, please use `triggers` instead');
- return this.triggers;
- },
- set: /**
- * @param {?} value
- * @return {?}
- */
- function (value) {
- warnOnce('tooltipTrigger was deprecated, please use `triggers` instead');
- this.triggers = (value || '').toString();
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @return {?}
- */
- TooltipDirective.prototype.ngOnInit = /**
- * @return {?}
- */
- function () {
- var _this = this;
- this._tooltip.listen({
- triggers: this.triggers,
- show: (/**
- * @return {?}
- */
- function () { return _this.show(); })
- });
- /* tslint:disable-next-line:no-any */
- this.tooltipChange.subscribe((/**
- * @param {?} value
- * @return {?}
- */
- function (value) {
- if (!value) {
- _this._tooltip.hide();
- }
- }));
- };
- /**
- * Toggles an element’s tooltip. This is considered a “manual” triggering of
- * the tooltip.
- */
- /**
- * Toggles an element’s tooltip. This is considered a “manual” triggering of
- * the tooltip.
- * @return {?}
- */
- TooltipDirective.prototype.toggle = /**
- * Toggles an element’s tooltip. This is considered a “manual” triggering of
- * the tooltip.
- * @return {?}
- */
- function () {
- if (this.isOpen) {
- return this.hide();
- }
- this.show();
- };
- /**
- * Opens an element’s tooltip. This is considered a “manual” triggering of
- * the tooltip.
- */
- /**
- * Opens an element’s tooltip. This is considered a “manual” triggering of
- * the tooltip.
- * @return {?}
- */
- TooltipDirective.prototype.show = /**
- * Opens an element’s tooltip. This is considered a “manual” triggering of
- * the tooltip.
- * @return {?}
- */
- function () {
- var _this = this;
- this._positionService.setOptions({
- modifiers: {
- flip: {
- enabled: this.adaptivePosition
- },
- preventOverflow: {
- enabled: this.adaptivePosition
- }
- }
- });
- if (this.isOpen ||
- this.isDisabled ||
- this._delayTimeoutId ||
- !this.tooltip) {
- return;
- }
- /** @type {?} */
- var showTooltip = (/**
- * @return {?}
- */
- function () {
- if (_this._delayTimeoutId) {
- _this._delayTimeoutId = undefined;
- }
- _this._tooltip
- .attach(TooltipContainerComponent)
- .to(_this.container)
- .position({ attachment: _this.placement })
- .show({
- content: _this.tooltip,
- placement: _this.placement,
- containerClass: _this.containerClass,
- id: _this.ariaDescribedby
- });
- });
- /** @type {?} */
- var cancelDelayedTooltipShowing = (/**
- * @return {?}
- */
- function () {
- if (_this._tooltipCancelShowFn) {
- _this._tooltipCancelShowFn();
- }
- });
- if (this.delay) {
- /** @type {?} */
- var _timer_1 = timer(this.delay).subscribe((/**
- * @return {?}
- */
- function () {
- showTooltip();
- cancelDelayedTooltipShowing();
- }));
- if (this.triggers) {
- parseTriggers(this.triggers)
- .forEach((/**
- * @param {?} trigger
- * @return {?}
- */
- function (trigger) {
- _this._tooltipCancelShowFn = _this._renderer.listen(_this._elementRef.nativeElement, trigger.close, (/**
- * @return {?}
- */
- function () {
- _timer_1.unsubscribe();
- cancelDelayedTooltipShowing();
- }));
- }));
- }
- }
- else {
- showTooltip();
- }
- };
- /**
- * Closes an element’s tooltip. This is considered a “manual” triggering of
- * the tooltip.
- */
- /**
- * Closes an element’s tooltip. This is considered a “manual” triggering of
- * the tooltip.
- * @return {?}
- */
- TooltipDirective.prototype.hide = /**
- * Closes an element’s tooltip. This is considered a “manual” triggering of
- * the tooltip.
- * @return {?}
- */
- function () {
- var _this = this;
- if (this._delayTimeoutId) {
- clearTimeout(this._delayTimeoutId);
- this._delayTimeoutId = undefined;
- }
- if (!this._tooltip.isShown) {
- return;
- }
- this._tooltip.instance.classMap.in = false;
- setTimeout((/**
- * @return {?}
- */
- function () {
- _this._tooltip.hide();
- }), this.tooltipFadeDuration);
- };
- /**
- * @return {?}
- */
- TooltipDirective.prototype.ngOnDestroy = /**
- * @return {?}
- */
- function () {
- this._tooltip.dispose();
- };
- TooltipDirective.decorators = [
- { type: Directive, args: [{
- selector: '[tooltip], [tooltipHtml]',
- exportAs: 'bs-tooltip'
- },] }
- ];
- /** @nocollapse */
- TooltipDirective.ctorParameters = function () { return [
- { type: ViewContainerRef },
- { type: ComponentLoaderFactory },
- { type: TooltipConfig },
- { type: ElementRef },
- { type: Renderer2 },
- { type: PositioningService }
- ]; };
- TooltipDirective.propDecorators = {
- adaptivePosition: [{ type: Input }],
- tooltip: [{ type: Input }],
- tooltipChange: [{ type: Output }],
- placement: [{ type: Input }],
- triggers: [{ type: Input }],
- container: [{ type: Input }],
- containerClass: [{ type: Input }],
- isOpen: [{ type: Input }],
- isDisabled: [{ type: Input }],
- delay: [{ type: Input }],
- onShown: [{ type: Output }],
- onHidden: [{ type: Output }],
- htmlContent: [{ type: Input, args: ['tooltipHtml',] }],
- _placement: [{ type: Input, args: ['tooltipPlacement',] }],
- _isOpen: [{ type: Input, args: ['tooltipIsOpen',] }],
- _enable: [{ type: Input, args: ['tooltipEnable',] }],
- _appendToBody: [{ type: Input, args: ['tooltipAppendToBody',] }],
- tooltipAnimation: [{ type: Input }],
- _popupClass: [{ type: Input, args: ['tooltipClass',] }],
- _tooltipContext: [{ type: Input, args: ['tooltipContext',] }],
- _tooltipPopupDelay: [{ type: Input, args: ['tooltipPopupDelay',] }],
- tooltipFadeDuration: [{ type: Input }],
- _tooltipTrigger: [{ type: Input, args: ['tooltipTrigger',] }],
- ariaDescribedby: [{ type: HostBinding, args: ['attr.aria-describedby',] }],
- tooltipStateChanged: [{ type: Output }]
- };
- __decorate([
- OnChange(),
- __metadata("design:type", Object)
- ], TooltipDirective.prototype, "tooltip", void 0);
- return TooltipDirective;
- }());
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- var TooltipModule = /** @class */ (function () {
- function TooltipModule() {
- }
- /**
- * @return {?}
- */
- TooltipModule.forRoot = /**
- * @return {?}
- */
- function () {
- return {
- ngModule: TooltipModule,
- providers: [TooltipConfig, ComponentLoaderFactory, PositioningService]
- };
- };
- TooltipModule.decorators = [
- { type: NgModule, args: [{
- imports: [CommonModule],
- declarations: [TooltipDirective, TooltipContainerComponent],
- exports: [TooltipDirective],
- entryComponents: [TooltipContainerComponent]
- },] }
- ];
- return TooltipModule;
- }());
- export { TooltipConfig, TooltipContainerComponent, TooltipDirective, TooltipModule };
- //# sourceMappingURL=ngx-bootstrap-tooltip.js.map
|