ngx-bootstrap-fix-datepicker
Version:
Native Angular Bootstrap Components
773 lines (765 loc) • 24.1 kB
JavaScript
import { Injectable, Component, ChangeDetectionStrategy, EventEmitter, Directive, ViewContainerRef, ElementRef, Renderer2, Input, Output, 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;
}());
if (false) {
/**
* sets disable adaptive position
* @type {?}
*/
TooltipConfig.prototype.adaptivePosition;
/**
* tooltip placement, supported positions: 'top', 'bottom', 'left', 'right'
* @type {?}
*/
TooltipConfig.prototype.placement;
/**
* array of event names which triggers tooltip opening
* @type {?}
*/
TooltipConfig.prototype.triggers;
/**
* a selector specifying the element the tooltip should be appended to.
* @type {?}
*/
TooltipConfig.prototype.container;
/**
* delay before showing the tooltip
* @type {?}
*/
TooltipConfig.prototype.delay;
}
/**
* @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;
}());
if (false) {
/** @type {?} */
TooltipContainerComponent.prototype.classMap;
/** @type {?} */
TooltipContainerComponent.prototype.placement;
/** @type {?} */
TooltipContainerComponent.prototype.containerClass;
/** @type {?} */
TooltipContainerComponent.prototype.animation;
/** @type {?} */
TooltipContainerComponent.prototype.id;
}
/**
* @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;
/**
* @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();
}
}));
this.onShown.subscribe((/**
* @return {?}
*/
function () {
_this.setAriaDescribedBy();
}));
this.onHidden.subscribe((/**
* @return {?}
*/
function () {
_this.setAriaDescribedBy();
}));
};
/**
* @return {?}
*/
TooltipDirective.prototype.setAriaDescribedBy = /**
* @return {?}
*/
function () {
this._ariaDescribedby = this.isOpen ? "tooltip-" + this.tooltipId : null;
if (this._ariaDescribedby) {
this._renderer.setAttribute(this._elementRef.nativeElement, 'aria-describedby', this._ariaDescribedby);
}
else {
this._renderer.removeAttribute(this._elementRef.nativeElement, 'aria-describedby');
}
};
/**
* 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: "tooltip-" + _this.tooltipId
});
});
/** @type {?} */
var cancelDelayedTooltipShowing = (/**
* @return {?}
*/
function () {
if (_this._tooltipCancelShowFn) {
_this._tooltipCancelShowFn();
}
});
if (this.delay) {
if (this._delaySubscription) {
this._delaySubscription.unsubscribe();
}
this._delaySubscription = 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 () {
_this._delaySubscription.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();
this.tooltipChange.unsubscribe();
if (this._delaySubscription) {
this._delaySubscription.unsubscribe();
}
this.onShown.unsubscribe();
this.onHidden.unsubscribe();
};
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',] }],
tooltipStateChanged: [{ type: Output }]
};
__decorate([
OnChange(),
__metadata("design:type", Object)
], TooltipDirective.prototype, "tooltip", void 0);
return TooltipDirective;
}());
if (false) {
/** @type {?} */
TooltipDirective.prototype.tooltipId;
/**
* sets disable adaptive position
* @type {?}
*/
TooltipDirective.prototype.adaptivePosition;
/**
* Content to be displayed as tooltip.
* @type {?}
*/
TooltipDirective.prototype.tooltip;
/**
* Fired when tooltip content changes
* @type {?}
*/
TooltipDirective.prototype.tooltipChange;
/**
* Placement of a tooltip. Accepts: "top", "bottom", "left", "right"
* @type {?}
*/
TooltipDirective.prototype.placement;
/**
* Specifies events that should trigger. Supports a space separated list of
* event names.
* @type {?}
*/
TooltipDirective.prototype.triggers;
/**
* A selector specifying the element the tooltip should be appended to.
* @type {?}
*/
TooltipDirective.prototype.container;
/**
* Css class for tooltip container
* @type {?}
*/
TooltipDirective.prototype.containerClass;
/**
* Allows to disable tooltip
* @type {?}
*/
TooltipDirective.prototype.isDisabled;
/**
* Delay before showing the tooltip
* @type {?}
*/
TooltipDirective.prototype.delay;
/**
* Emits an event when the tooltip is shown
* @type {?}
*/
TooltipDirective.prototype.onShown;
/**
* Emits an event when the tooltip is hidden
* @type {?}
*/
TooltipDirective.prototype.onHidden;
/**
* @deprecated - removed, will be added to configuration
* @type {?}
*/
TooltipDirective.prototype.tooltipAnimation;
/**
* @deprecated
* @type {?}
*/
TooltipDirective.prototype.tooltipFadeDuration;
/**
* @deprecated
* @type {?}
*/
TooltipDirective.prototype.tooltipStateChanged;
/**
* @type {?}
* @protected
*/
TooltipDirective.prototype._delayTimeoutId;
/**
* @type {?}
* @protected
*/
TooltipDirective.prototype._tooltipCancelShowFn;
/**
* @type {?}
* @private
*/
TooltipDirective.prototype._tooltip;
/**
* @type {?}
* @private
*/
TooltipDirective.prototype._delaySubscription;
/**
* @type {?}
* @private
*/
TooltipDirective.prototype._ariaDescribedby;
/**
* @type {?}
* @private
*/
TooltipDirective.prototype._elementRef;
/**
* @type {?}
* @private
*/
TooltipDirective.prototype._renderer;
/**
* @type {?}
* @private
*/
TooltipDirective.prototype._positionService;
}
/**
* @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;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
export { TooltipConfig, TooltipContainerComponent, TooltipDirective, TooltipModule };
//# sourceMappingURL=ngx-bootstrap-tooltip.js.map