@ngneat/helipopper
Advanced tools
Comparing version 1.6.0 to 2.0.0-beta.1
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('tippy.js'), require('rxjs'), require('rxjs/operators')) : | ||
typeof define === 'function' && define.amd ? define('@ngneat/helipopper', ['exports', '@angular/core', '@angular/common', 'tippy.js', 'rxjs', 'rxjs/operators'], factory) : | ||
(global = global || self, factory((global.ngneat = global.ngneat || {}, global.ngneat.helipopper = {}), global.ng.core, global.ng.common, global.tippy, global.rxjs, global.rxjs.operators)); | ||
}(this, (function (exports, core, common, tippy, rxjs, operators) { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('tippy.js'), require('rxjs'), require('rxjs/operators'), require('@ngneat/overview'), require('@angular/common')) : | ||
typeof define === 'function' && define.amd ? define('@ngneat/helipopper', ['exports', '@angular/core', 'tippy.js', 'rxjs', 'rxjs/operators', '@ngneat/overview', '@angular/common'], factory) : | ||
(global = global || self, factory((global.ngneat = global.ngneat || {}, global.ngneat.helipopper = {}), global.ng.core, global.tippy, global.rxjs, global.rxjs.operators, global.ngneatOverview, global.ng.common)); | ||
}(this, (function (exports, core, tippy, rxjs, operators, overview, common) { 'use strict'; | ||
@@ -228,3 +228,15 @@ tippy = tippy && Object.prototype.hasOwnProperty.call(tippy, 'default') ? tippy['default'] : tippy; | ||
var supportsIntersectionObserver = false, supportsResizeObserver = false; | ||
var TIPPY_CONFIG = new core.InjectionToken("Tippy config", { | ||
providedIn: "root", | ||
factory: function () { | ||
return {}; | ||
} | ||
}); | ||
var TIPPY_REF = new core.InjectionToken("TIPPY_REF"); | ||
function coerceElement(element) { | ||
return element instanceof core.ElementRef ? element.nativeElement : element; | ||
} | ||
var supportsIntersectionObserver = false; | ||
var supportsResizeObserver = false; | ||
if (typeof window !== 'undefined') { | ||
@@ -234,3 +246,3 @@ supportsIntersectionObserver = 'IntersectionObserver' in window; | ||
} | ||
function inView(element, options) { | ||
function inView(host, options) { | ||
if (options === void 0) { options = { | ||
@@ -240,2 +252,3 @@ root: null, | ||
}; } | ||
var element = coerceElement(host); | ||
return new rxjs.Observable(function (subscriber) { | ||
@@ -245,4 +258,2 @@ if (!supportsIntersectionObserver) { | ||
subscriber.complete(); | ||
// If the browser doesn't support the `IntersectionObserver` then | ||
// we "return" since it will throw `IntersectionObserver is not defined`. | ||
return; | ||
@@ -252,3 +263,3 @@ } | ||
// Several changes may occur in the same tick, we want to check the latest entry state. | ||
var entry = last(entries); | ||
var entry = entries[entries.length - 1]; | ||
if (entry.isIntersecting) { | ||
@@ -263,271 +274,149 @@ subscriber.next(); | ||
} | ||
var AUDIT_TIME = 150; | ||
function dimensionsChanges(target, options) { | ||
return supportsResizeObserver | ||
? resizeObserverStrategy(target, options).pipe(operators.auditTime(AUDIT_TIME)) | ||
: resizeWindowStrategy(target); | ||
function isElementOverflow(host) { | ||
var parentEl = host.parentElement; | ||
var parentTest = host.offsetWidth > parentEl.offsetWidth; | ||
var elementTest = host.offsetWidth < host.scrollWidth; | ||
return parentTest || elementTest; | ||
} | ||
function resizeWindowStrategy(target) { | ||
return rxjs.fromEvent(window, 'resize').pipe(operators.auditTime(AUDIT_TIME), operators.map(function () { return ({ | ||
width: target.offsetWidth, | ||
height: target.offsetHeight | ||
}); }), operators.distinctUntilChanged(function (prev, current) { | ||
return prev.width === current.width && prev.height === current.height; | ||
function overflowChanges(host) { | ||
var element = coerceElement(host); | ||
return dimensionsChanges(element).pipe(operators.map(function () { | ||
return isElementOverflow(element); | ||
})); | ||
} | ||
function resizeObserverStrategy(target, options) { | ||
if (options === void 0) { options = { box: 'border-box' }; } | ||
function dimensionsChanges(target) { | ||
return resizeObserverStrategy(target).pipe(operators.auditTime(150)); | ||
} | ||
function resizeObserverStrategy(target) { | ||
return new rxjs.Observable(function (subscriber) { | ||
var observer = new ResizeObserver(function (_a) { | ||
var _b = __read(_a, 1), entry = _b[0]; | ||
// Currently, only Firefox supports `borderBoxSize` property which | ||
// gives the border-box value include padding and border | ||
if (entry.borderBoxSize) { | ||
subscriber.next({ | ||
width: entry.borderBoxSize.inlineSize, | ||
height: entry.borderBoxSize.blockSize | ||
}); | ||
} | ||
else { | ||
subscriber.next({ | ||
width: entry.target.offsetWidth, | ||
height: entry.target.offsetHeight | ||
}); | ||
} | ||
}); | ||
observer.observe(target, options); | ||
if (!supportsResizeObserver) { | ||
subscriber.next(); | ||
subscriber.complete(); | ||
return; | ||
} | ||
var observer = new ResizeObserver(function () { return subscriber.next(true); }); | ||
observer.observe(target); | ||
return function () { return observer.disconnect(); }; | ||
}); | ||
} | ||
function coerceElement(elementOrRef) { | ||
return elementOrRef instanceof core.ElementRef ? elementOrRef.nativeElement : elementOrRef; | ||
} | ||
function isString(value) { | ||
return typeof value === 'string'; | ||
} | ||
function addClass(element, className) { | ||
if (Array.isArray(className)) { | ||
className.forEach(function (name) { return element.classList.add(name); }); | ||
var TippyDirective = /** @class */ (function () { | ||
function TippyDirective(platformId, globalConfig, injector, viewService, vcr, zone, host) { | ||
this.platformId = platformId; | ||
this.globalConfig = globalConfig; | ||
this.injector = injector; | ||
this.viewService = viewService; | ||
this.vcr = vcr; | ||
this.zone = zone; | ||
this.host = host; | ||
this.onlyTextOverflow = false; | ||
this.useHostWidth = false; | ||
this.visible = new core.EventEmitter(); | ||
this.isVisible = false; | ||
this.destroyed = new rxjs.Subject(); | ||
this.enabled = true; | ||
this.variationDefined = false; | ||
} | ||
else { | ||
element.classList.add(className); | ||
} | ||
} | ||
function addStyle(element, prop, value) { | ||
element.style[prop] = value; | ||
} | ||
function createElement(tagName) { | ||
return document.createElement(tagName); | ||
} | ||
function closest(element, selector) { | ||
if (window['Element'] && !Element.prototype.closest) { | ||
Element.prototype.closest = function (s) { | ||
var matches = (this.document || this.ownerDocument).querySelectorAll(s), i, el = this; | ||
do { | ||
i = matches.length; | ||
while (--i >= 0 && matches.item(i) !== el) { } | ||
} while (i < 0 && (el = el.parentElement)); | ||
return el; | ||
}; | ||
} | ||
return element.closest(selector); | ||
} | ||
var TemplatePortal = /** @class */ (function () { | ||
function TemplatePortal(tpl) { | ||
var _a; | ||
this.wrapper = null; | ||
this.viewRef = tpl.createEmbeddedView({}); | ||
this.viewRef.detectChanges(); | ||
if (this.viewRef.rootNodes.length === 1) { | ||
this.elementRef = this.viewRef.rootNodes[0]; | ||
TippyDirective.prototype.ngOnChanges = function (changes) { | ||
if (common.isPlatformServer(this.platformId)) | ||
return; | ||
if (changes.content) { | ||
this.view = changes.content.currentValue; | ||
} | ||
else { | ||
this.wrapper = document.createElement('div'); | ||
// The `node` might be an instance of the `Comment` class, | ||
// which is an `ng-container` element. We shouldn't filter it | ||
// out since there can be `ngIf` or any other directive bound | ||
// to the `ng-container`. | ||
(_a = this.wrapper).append.apply(_a, __spread(this.viewRef.rootNodes)); | ||
this.elementRef = this.wrapper; | ||
var props = Object.keys(changes).reduce(function (acc, change) { | ||
acc[change] = changes[change].currentValue; | ||
return acc; | ||
}, {}); | ||
var variation; | ||
if (isChanged("variation", changes)) { | ||
variation = changes.variation.currentValue; | ||
} | ||
} | ||
TemplatePortal.prototype.destroy = function () { | ||
if (this.wrapper !== null) { | ||
this.wrapper.parentNode.removeChild(this.wrapper); | ||
this.wrapper = null; | ||
else if (!this.variationDefined) { | ||
variation = this.globalConfig.defaultVariation; | ||
this.variationDefined = true; | ||
} | ||
this.viewRef.destroy(); | ||
if (variation) { | ||
props = __assign(__assign({}, this.globalConfig.variations[variation]), props); | ||
} | ||
if (isChanged("isEnable", changes)) { | ||
this.enabled = changes.isEnable.currentValue; | ||
this.setStatus(); | ||
} | ||
// We don't want to save the content, we control it manually | ||
delete props.content; | ||
this.setProps(props); | ||
}; | ||
return TemplatePortal; | ||
}()); | ||
function last(arr) { | ||
return arr[arr.length - 1]; | ||
} | ||
var HELIPOPPER_CONFIG = new core.InjectionToken('HELIPOPPER_CONFIG'); | ||
var INITIAL_HELIPOPPER_OPTIONS = new core.InjectionToken('InitialHelipopperOptions', { | ||
providedIn: 'root', | ||
factory: function () { | ||
var document = core.inject(common.DOCUMENT); | ||
// The code actually shouldn't be executed on the server-side, | ||
// but these options are "statically" initialized, thus Universal | ||
// will throw an error "document is not defined". | ||
return { | ||
options: {}, | ||
textOverflow: false, | ||
appendTo: document.body, | ||
placement: 'top', | ||
variation: 'tooltip', | ||
disabled: false, | ||
allowClose: true | ||
}; | ||
} | ||
}); | ||
var icon = "\n <svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 24 24\" fit=\"\" preserveAspectRatio=\"xMidYMid meet\" focusable=\"false\">\n<path d=\"M12.793 12l4.039-4.025c0.219-0.219 0.224-0.578 0.012-0.802-0.213-0.225-0.563-0.231-0.782-0.011l-4.062 4.049-4.062-4.049c-0.219-0.22-0.569-0.213-0.782 0.011s-0.208 0.583 0.012 0.802l4.039 4.025-4.039 4.025c-0.22 0.219-0.224 0.578-0.012 0.802 0.108 0.115 0.252 0.172 0.397 0.172 0.138 0 0.278-0.053 0.385-0.161l4.062-4.049 4.062 4.049c0.107 0.108 0.245 0.161 0.385 0.161 0.144 0 0.287-0.058 0.397-0.172 0.212-0.225 0.207-0.583-0.012-0.802l-4.039-4.025z\"></path>\n</svg>\n "; | ||
var HelipopperDirective = /** @class */ (function () { | ||
function HelipopperDirective(host, appRef, zone, resolver, hostInjector, platformId, config, initialOptions) { | ||
this.host = host; | ||
this.appRef = appRef; | ||
this.zone = zone; | ||
this.resolver = resolver; | ||
this.hostInjector = hostInjector; | ||
this.platformId = platformId; | ||
this.initialOptions = initialOptions; | ||
this.helipopperOptions = this.initialOptions.options; | ||
this.showOnlyOnTextOverflow = this.initialOptions.textOverflow; | ||
this.helipopperAppendTo = this.initialOptions.appendTo; | ||
this.helipopperUseHostWidth = false; | ||
this.helipopperAllowClose = this.initialOptions.allowClose; | ||
this.helipopperClose = new rxjs.Subject(); | ||
this.helipopperVisible = new rxjs.Subject(); | ||
this._destroy = new rxjs.Subject(); | ||
this._placement = this.initialOptions.placement; | ||
this._disabled = false; | ||
this._variation = this.initialOptions.variation; | ||
this.whenStable = new rxjs.Subject(); | ||
this.isVisible = false; | ||
this.mergedConfig = this.createConfig(config); | ||
} | ||
Object.defineProperty(HelipopperDirective.prototype, "placement", { | ||
set: function (placement) { | ||
this._placement = placement; | ||
this.setProps({ placement: placement }); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(HelipopperDirective.prototype, "variation", { | ||
set: function (variation) { | ||
this._variation = variation; | ||
this.setProps(this.resolveTheme()); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(HelipopperDirective.prototype, "disabled", { | ||
set: function (disabled) { | ||
this._disabled = disabled; | ||
this.markDisabled(this._disabled); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(HelipopperDirective.prototype, "sticky", { | ||
set: function (isSticky) { | ||
if (!this.instance) { | ||
return; | ||
TippyDirective.prototype.ngOnInit = function () { | ||
if (this.useHostWidth) { | ||
this.props.maxWidth = this.hostWidth; | ||
} | ||
}; | ||
TippyDirective.prototype.ngAfterViewInit = function () { | ||
var _this = this; | ||
if (this.lazy) { | ||
if (this.onlyTextOverflow) { | ||
inView(this.host) | ||
.pipe(operators.switchMap(function () { return overflowChanges(_this.host); }), operators.takeUntil(this.destroyed)) | ||
.subscribe(function (isElementOverflow) { | ||
_this.checkOverflow(isElementOverflow); | ||
}); | ||
} | ||
if (isSticky) { | ||
this.setProps({ trigger: 'manual', hideOnClick: false }); | ||
this.show(); | ||
} | ||
else { | ||
this.hide(); | ||
this.setProps({ trigger: this.helipopperTrigger }); | ||
} | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(HelipopperDirective.prototype, "helipopper", { | ||
set: function (content) { | ||
var _this = this; | ||
// We shouldn't do anything on the server side, | ||
// it will throw `requestAnimationFrame is not defined`, | ||
// we could replace it with `setTimeout` on the server side, | ||
// but `tippy.js` should be initialized only on the client side. | ||
// The `tippy.js` library is browser-compatible only! | ||
// It doesn't have any checks inside like `typeof window !== 'undefined`' | ||
// and should it be called only if the code is executed on the client side. | ||
if (common.isPlatformServer(this.platformId)) { | ||
return; | ||
} | ||
// Clear previously created view | ||
this.destroyView(); | ||
this._content = content; | ||
if (this.instance) { | ||
this.checkOverflow(); | ||
} | ||
else { | ||
requestAnimationFrame(function () { | ||
inView(_this.host.nativeElement) | ||
.pipe(operators.takeUntil(_this._destroy)) | ||
.subscribe(function () { return _this.create(); }); | ||
inView(this.host) | ||
.pipe(operators.takeUntil(this.destroyed)) | ||
.subscribe(function () { | ||
_this.createInstance(); | ||
}); | ||
} | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(HelipopperDirective.prototype, "_tooltipTarget", { | ||
get: function () { | ||
return coerceElement(this.triggerTarget) || this.host.nativeElement; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(HelipopperDirective.prototype, "_tooltipHost", { | ||
get: function () { | ||
return coerceElement(this.helipopperHost) || this.host.nativeElement; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(HelipopperDirective.prototype, "isTooltip", { | ||
get: function () { | ||
return this._variation === 'tooltip'; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(HelipopperDirective.prototype, "isPopper", { | ||
get: function () { | ||
return this._variation === 'popper'; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
HelipopperDirective.prototype.setProps = function (props) { | ||
this.instance && this.instance.setProps(props); | ||
} | ||
else if (this.onlyTextOverflow) { | ||
overflowChanges(this.host) | ||
.pipe(operators.takeUntil(this.destroyed)) | ||
.subscribe(function (isElementOverflow) { | ||
_this.checkOverflow(isElementOverflow); | ||
}); | ||
} | ||
else { | ||
this.createInstance(); | ||
} | ||
}; | ||
HelipopperDirective.prototype.hide = function () { | ||
this.instance.hide(); | ||
TippyDirective.prototype.ngOnDestroy = function () { | ||
var _a; | ||
this.destroyed.next(); | ||
(_a = this.instance) === null || _a === void 0 ? void 0 : _a.destroy(); | ||
this.destroyView(); | ||
}; | ||
HelipopperDirective.prototype.show = function () { | ||
this.instance.show(); | ||
TippyDirective.prototype.destroyView = function () { | ||
var _a; | ||
(_a = this.viewRef) === null || _a === void 0 ? void 0 : _a.destroy(); | ||
this.viewRef = null; | ||
}; | ||
HelipopperDirective.prototype.ngOnDestroy = function () { | ||
this.destroyView(); | ||
this.instance && this.instance.destroy(); | ||
this.instance = null; | ||
this._destroy.next(); | ||
TippyDirective.prototype.show = function () { | ||
var _a; | ||
(_a = this.instance) === null || _a === void 0 ? void 0 : _a.show(); | ||
}; | ||
HelipopperDirective.prototype.destroy = function () { | ||
this.ngOnDestroy(); | ||
TippyDirective.prototype.hide = function () { | ||
var _a; | ||
(_a = this.instance) === null || _a === void 0 ? void 0 : _a.hide(); | ||
}; | ||
Object.defineProperty(HelipopperDirective.prototype, "hostWidth", { | ||
TippyDirective.prototype.enable = function () { | ||
var _a; | ||
(_a = this.instance) === null || _a === void 0 ? void 0 : _a.enable(); | ||
}; | ||
TippyDirective.prototype.disable = function () { | ||
var _a; | ||
(_a = this.instance) === null || _a === void 0 ? void 0 : _a.disable(); | ||
}; | ||
TippyDirective.prototype.setProps = function (props) { | ||
var _a; | ||
this.props = props; | ||
(_a = this.instance) === null || _a === void 0 ? void 0 : _a.setProps(props); | ||
}; | ||
TippyDirective.prototype.setStatus = function () { | ||
var _a, _b; | ||
this.enabled ? (_a = this.instance) === null || _a === void 0 ? void 0 : _a.enable() : (_b = this.instance) === null || _b === void 0 ? void 0 : _b.disable(); | ||
}; | ||
Object.defineProperty(TippyDirective.prototype, "hostWidth", { | ||
get: function () { | ||
return this._tooltipHost.getBoundingClientRect().width + "px"; | ||
return this.host.nativeElement.getBoundingClientRect().width + "px"; | ||
}, | ||
@@ -537,237 +426,193 @@ enumerable: true, | ||
}); | ||
HelipopperDirective.prototype.destroyView = function () { | ||
this.tplPortal && this.destroyTemplate(); | ||
this.innerComponentRef && this.destroyComponent(); | ||
}; | ||
HelipopperDirective.prototype.create = function () { | ||
TippyDirective.prototype.createInstance = function () { | ||
var _this = this; | ||
this.zone.runOutsideAngular(function () { return _this.createInstance(); }); | ||
}; | ||
HelipopperDirective.prototype.createInstance = function () { | ||
var _this = this; | ||
if (this.showOnlyOnTextOverflow) { | ||
dimensionsChanges(this._tooltipHost) | ||
.pipe(operators.takeUntil(this._destroy)) | ||
.subscribe(function () { | ||
_this.markDisabled(_this.isElementOverflow() === false); | ||
}); | ||
} | ||
this.helipopperTrigger = this.resolveTrigger(); | ||
var maxWidth = this.helipopperUseHostWidth ? this.hostWidth : this.helipopperMaxWidth; | ||
this.instance = tippy(this._tooltipHost, __assign(__assign({ content: undefined, appendTo: this.getParent(), arrow: !this.isTooltip, allowHTML: true, zIndex: 1000000, trigger: this.helipopperTrigger, placement: this._placement, triggerTarget: this._tooltipTarget, maxWidth: maxWidth, hideOnClick: this.helipopperAllowClose, | ||
// TODO: Merge the following methods with the passed config | ||
onMount: function () { | ||
this.instance = tippy(this.host.nativeElement, __assign(__assign(__assign({ allowHTML: true }, this.globalConfig), this.props), { onMount: function (instance) { | ||
var _a, _b; | ||
_this.isVisible = true; | ||
_this.helipopperVisible.next(true); | ||
_this.visible.next(true); | ||
(_b = (_a = _this.globalConfig).onMount) === null || _b === void 0 ? void 0 : _b.call(_a, instance); | ||
}, onCreate: function (instance) { | ||
_this.helipopperClass && addClass(instance.popper, _this.helipopperClass); | ||
_this.helipopperUseHostWidth && addStyle(instance.popper, 'width', _this.hostWidth); | ||
var _a, _b; | ||
_this.className && instance.popper.classList.add(_this.className); | ||
if (_this.useHostWidth) { | ||
instance.popper.style.width = _this.hostWidth; | ||
} | ||
(_b = (_a = _this.globalConfig).onCreate) === null || _b === void 0 ? void 0 : _b.call(_a, instance); | ||
}, onShow: function (instance) { | ||
var _a, _b; | ||
_this.zone.run(function () { return _this.instance.setContent(_this.resolveContent()); }); | ||
_this.helipopperAllowClose && _this.isPopper && _this.addCloseButton(instance); | ||
(_b = (_a = _this.globalConfig).onShow) === null || _b === void 0 ? void 0 : _b.call(_a, instance); | ||
}, onHidden: function (instance) { | ||
_this.helipopperAllowClose && _this.isPopper && _this.removeCloseButton(instance); | ||
var _a, _b; | ||
_this.destroyView(); | ||
_this.isVisible = false; | ||
_this.helipopperClose.next(); | ||
_this.helipopperVisible.next(false); | ||
} }, this.resolveTheme()), this.helipopperOptions)); | ||
this.whenStable.next(true); | ||
this.markDisabled(this._disabled); | ||
_this.visible.next(false); | ||
(_b = (_a = _this.globalConfig).onHidden) === null || _b === void 0 ? void 0 : _b.call(_a, instance); | ||
} })); | ||
this.setStatus(); | ||
this.setProps(this.props); | ||
this.variation === "contextMenu" && this.handleContextMenu(); | ||
}; | ||
HelipopperDirective.prototype.resolveTrigger = function () { | ||
return this.helipopperTrigger || (this.isTooltip ? 'mouseenter' : 'click'); | ||
}; | ||
HelipopperDirective.prototype.resolveTemplate = function (content) { | ||
if (this.tplPortal) { | ||
this.destroyTemplate(); | ||
TippyDirective.prototype.resolveContent = function () { | ||
if (!this.viewOptions$ && !overview.isString(this.content)) { | ||
if (overview.isComponent(this.content)) { | ||
this.viewOptions$ = { | ||
injector: core.Injector.create({ | ||
providers: [{ provide: TIPPY_REF, useValue: this.instance }], | ||
parent: this.injector | ||
}) | ||
}; | ||
} | ||
else if (overview.isTemplateRef(this.content)) { | ||
this.viewOptions$ = { | ||
context: { | ||
$implicit: this.hide.bind(this), | ||
data: this.data | ||
} | ||
}; | ||
} | ||
} | ||
this.tplPortal = new TemplatePortal(content); | ||
this.appRef.attachView(this.tplPortal.viewRef); | ||
return this.tplPortal.elementRef; | ||
}; | ||
HelipopperDirective.prototype.isElementOverflow = function () { | ||
var element = this._tooltipTarget; | ||
var parentEl = element.parentElement; | ||
var parentTest = element.offsetWidth > parentEl.offsetWidth; | ||
var elementTest = element.offsetWidth < element.scrollWidth; | ||
return parentTest || elementTest; | ||
}; | ||
HelipopperDirective.prototype.getParent = function () { | ||
var containerElement; | ||
if (isString(this.helipopperAppendTo)) { | ||
containerElement = closest(this.host.nativeElement, this.helipopperAppendTo); | ||
this.viewRef = this.viewService.createView(this.content, __assign({ vcr: this.vcr }, this.viewOptions$)); | ||
var content = this.viewRef.getElement(); | ||
if (overview.isString(content) && this.globalConfig.beforeRender) { | ||
content = this.globalConfig.beforeRender(content); | ||
} | ||
else { | ||
containerElement = this.helipopperAppendTo; | ||
} | ||
return containerElement || document.body; | ||
return content; | ||
}; | ||
HelipopperDirective.prototype.markDisabled = function (disabled) { | ||
if (disabled === void 0) { disabled = true; } | ||
if (this.instance) { | ||
disabled ? this.instance.disable() : this.instance.enable(); | ||
} | ||
}; | ||
HelipopperDirective.prototype.resolveTheme = function () { | ||
return { | ||
offset: this.helipopperOffset || [0, this.isTooltip ? 5 : 10], | ||
theme: this.isTooltip ? null : 'light', | ||
arrow: this.isTooltip === false, | ||
animation: this.isTooltip ? "scale" : null, | ||
interactive: !this.isTooltip | ||
}; | ||
}; | ||
HelipopperDirective.prototype.addCloseButton = function (instance) { | ||
TippyDirective.prototype.handleContextMenu = function () { | ||
var _this = this; | ||
var popper = instance.popper; | ||
var closeIcon = this.mergedConfig.closeIcon; | ||
var closeButtonElement = createElement('div'); | ||
addClass(closeButtonElement, 'tippy-close'); | ||
closeButtonElement.innerHTML = closeIcon; | ||
var closeButtonSubscription = rxjs.fromEvent(closeButtonElement, 'click').subscribe(function () { return _this.hide(); }); | ||
popper.appendChild(closeButtonElement); | ||
instance.closeButtonElement = closeButtonElement; | ||
instance.closeButtonSubscription = closeButtonSubscription; | ||
rxjs.fromEvent(this.host.nativeElement, "contextmenu") | ||
.pipe(operators.takeUntil(this.destroyed)) | ||
.subscribe(function (event) { | ||
event.preventDefault(); | ||
_this.instance.setProps({ | ||
getReferenceClientRect: function () { return ({ | ||
width: 0, | ||
height: 0, | ||
top: event.clientY, | ||
bottom: event.clientY, | ||
left: event.clientX, | ||
right: event.clientX | ||
}); } | ||
}); | ||
_this.instance.show(); | ||
}); | ||
}; | ||
HelipopperDirective.prototype.removeCloseButton = function (instance) { | ||
instance.popper.removeChild(instance.closeButtonElement); | ||
instance.closeButtonSubscription.unsubscribe(); | ||
instance.closeButtonElement = null; | ||
instance.closeButtonSubscription = null; | ||
}; | ||
HelipopperDirective.prototype.checkOverflow = function () { | ||
var _this = this; | ||
if (this.showOnlyOnTextOverflow) { | ||
requestAnimationFrame(function () { return _this.markDisabled(_this.isElementOverflow() === false); }); | ||
} | ||
}; | ||
HelipopperDirective.prototype.destroyTemplate = function () { | ||
this.appRef.detachView(this.tplPortal.viewRef); | ||
this.tplPortal.destroy(); | ||
this.tplPortal = null; | ||
}; | ||
HelipopperDirective.prototype.createConfig = function (config) { | ||
var defaults = { | ||
closeIcon: icon, | ||
beforeRender: function (content) { | ||
return content; | ||
TippyDirective.prototype.checkOverflow = function (isElementOverflow) { | ||
var _a; | ||
if (isElementOverflow) { | ||
if (!this.instance) { | ||
this.createInstance(); | ||
} | ||
}; | ||
return __assign(__assign({}, defaults), config); | ||
}; | ||
HelipopperDirective.prototype.resolveComponent = function (content) { | ||
var factory = this.resolver.resolveComponentFactory(content); | ||
var injector = this.injector || this.hostInjector; | ||
this.innerComponentRef = factory.create(injector); | ||
this.appRef.attachView(this.innerComponentRef.hostView); | ||
this.innerComponentRef.hostView.detectChanges(); | ||
return this.innerComponentRef.location.nativeElement; | ||
}; | ||
HelipopperDirective.prototype.destroyComponent = function () { | ||
this.innerComponentRef.destroy(); | ||
this.appRef.detachView(this.innerComponentRef.hostView); | ||
this.innerComponentRef = null; | ||
}; | ||
HelipopperDirective.prototype.resolveContent = function () { | ||
var content = this._content; | ||
var finalContent; | ||
if (content instanceof core.TemplateRef) { | ||
finalContent = this.resolveTemplate(content); | ||
else { | ||
this.instance.enable(); | ||
} | ||
} | ||
else if (typeof content === 'string') { | ||
finalContent = this.mergedConfig.beforeRender(content); | ||
} | ||
else { | ||
finalContent = this.resolveComponent(content); | ||
(_a = this.instance) === null || _a === void 0 ? void 0 : _a.disable(); | ||
} | ||
return finalContent; | ||
}; | ||
HelipopperDirective.ctorParameters = function () { return [ | ||
{ type: core.ElementRef }, | ||
{ type: core.ApplicationRef }, | ||
TippyDirective.ctorParameters = function () { return [ | ||
{ type: String, decorators: [{ type: core.Inject, args: [core.PLATFORM_ID,] }] }, | ||
{ type: undefined, decorators: [{ type: core.Inject, args: [TIPPY_CONFIG,] }] }, | ||
{ type: core.Injector }, | ||
{ type: overview.ViewService }, | ||
{ type: core.ViewContainerRef }, | ||
{ type: core.NgZone }, | ||
{ type: core.ComponentFactoryResolver }, | ||
{ type: core.Injector }, | ||
{ type: String, decorators: [{ type: core.Inject, args: [core.PLATFORM_ID,] }] }, | ||
{ type: undefined, decorators: [{ type: core.Inject, args: [HELIPOPPER_CONFIG,] }] }, | ||
{ type: undefined, decorators: [{ type: core.Inject, args: [INITIAL_HELIPOPPER_OPTIONS,] }] } | ||
{ type: core.ElementRef } | ||
]; }; | ||
__decorate([ | ||
core.Input() | ||
], HelipopperDirective.prototype, "helipopperOptions", void 0); | ||
], TippyDirective.prototype, "appendTo", void 0); | ||
__decorate([ | ||
core.Input('helipopperTextOverflow') | ||
], HelipopperDirective.prototype, "showOnlyOnTextOverflow", void 0); | ||
core.Input() | ||
], TippyDirective.prototype, "delay", void 0); | ||
__decorate([ | ||
core.Input() | ||
], HelipopperDirective.prototype, "triggerTarget", void 0); | ||
], TippyDirective.prototype, "duration", void 0); | ||
__decorate([ | ||
core.Input() | ||
], HelipopperDirective.prototype, "helipopperHost", void 0); | ||
], TippyDirective.prototype, "hideOnClick", void 0); | ||
__decorate([ | ||
core.Input() | ||
], HelipopperDirective.prototype, "helipopperAppendTo", void 0); | ||
], TippyDirective.prototype, "interactive", void 0); | ||
__decorate([ | ||
core.Input() | ||
], HelipopperDirective.prototype, "helipopperTrigger", void 0); | ||
], TippyDirective.prototype, "interactiveBorder", void 0); | ||
__decorate([ | ||
core.Input() | ||
], HelipopperDirective.prototype, "helipopperMaxWidth", void 0); | ||
], TippyDirective.prototype, "maxWidth", void 0); | ||
__decorate([ | ||
core.Input() | ||
], HelipopperDirective.prototype, "helipopperUseHostWidth", void 0); | ||
], TippyDirective.prototype, "offset", void 0); | ||
__decorate([ | ||
core.Input() | ||
], HelipopperDirective.prototype, "helipopperAllowClose", void 0); | ||
], TippyDirective.prototype, "placement", void 0); | ||
__decorate([ | ||
core.Input() | ||
], HelipopperDirective.prototype, "helipopperClass", void 0); | ||
], TippyDirective.prototype, "popperOptions", void 0); | ||
__decorate([ | ||
core.Input() | ||
], HelipopperDirective.prototype, "helipopperOffset", void 0); | ||
], TippyDirective.prototype, "showOnCreate", void 0); | ||
__decorate([ | ||
core.Input('helipopperInjector') | ||
], HelipopperDirective.prototype, "injector", void 0); | ||
core.Input() | ||
], TippyDirective.prototype, "trigger", void 0); | ||
__decorate([ | ||
core.Input('helipopperPlacement') | ||
], HelipopperDirective.prototype, "placement", null); | ||
core.Input() | ||
], TippyDirective.prototype, "triggerTarget", void 0); | ||
__decorate([ | ||
core.Input('helipopperVariation') | ||
], HelipopperDirective.prototype, "variation", null); | ||
core.Input() | ||
], TippyDirective.prototype, "zIndex", void 0); | ||
__decorate([ | ||
core.Input('helipopperDisabled') | ||
], HelipopperDirective.prototype, "disabled", null); | ||
core.Input() | ||
], TippyDirective.prototype, "lazy", void 0); | ||
__decorate([ | ||
core.Input('helipopperSticky') | ||
], HelipopperDirective.prototype, "sticky", null); | ||
core.Input() | ||
], TippyDirective.prototype, "variation", void 0); | ||
__decorate([ | ||
core.Input() | ||
], HelipopperDirective.prototype, "helipopper", null); | ||
], TippyDirective.prototype, "isEnable", void 0); | ||
__decorate([ | ||
core.Output() | ||
], HelipopperDirective.prototype, "helipopperClose", void 0); | ||
core.Input() | ||
], TippyDirective.prototype, "className", void 0); | ||
__decorate([ | ||
core.Input() | ||
], TippyDirective.prototype, "onlyTextOverflow", void 0); | ||
__decorate([ | ||
core.Input() | ||
], TippyDirective.prototype, "data", void 0); | ||
__decorate([ | ||
core.Input() | ||
], TippyDirective.prototype, "useHostWidth", void 0); | ||
__decorate([ | ||
core.Input("tippy") | ||
], TippyDirective.prototype, "content", void 0); | ||
__decorate([ | ||
core.Output() | ||
], HelipopperDirective.prototype, "helipopperVisible", void 0); | ||
HelipopperDirective = __decorate([ | ||
core.Directive({ selector: "[helipopper]", exportAs: 'helipopper' }), | ||
__param(5, core.Inject(core.PLATFORM_ID)), | ||
__param(6, core.Inject(HELIPOPPER_CONFIG)), | ||
__param(7, core.Inject(INITIAL_HELIPOPPER_OPTIONS)) | ||
], HelipopperDirective); | ||
return HelipopperDirective; | ||
], TippyDirective.prototype, "visible", void 0); | ||
TippyDirective = __decorate([ | ||
core.Directive({ | ||
selector: "[tippy]", | ||
exportAs: "tippy" | ||
}), | ||
__param(0, core.Inject(core.PLATFORM_ID)), | ||
__param(1, core.Inject(TIPPY_CONFIG)) | ||
], TippyDirective); | ||
return TippyDirective; | ||
}()); | ||
function isChanged(key, changes) { | ||
return key in changes; | ||
} | ||
var HelipopperModule = /** @class */ (function () { | ||
function HelipopperModule() { | ||
var TippyModule = /** @class */ (function () { | ||
function TippyModule() { | ||
} | ||
HelipopperModule_1 = HelipopperModule; | ||
HelipopperModule.forRoot = function (config) { | ||
TippyModule_1 = TippyModule; | ||
TippyModule.forRoot = function (config) { | ||
if (config === void 0) { config = {}; } | ||
return { | ||
ngModule: HelipopperModule_1, | ||
ngModule: TippyModule_1, | ||
providers: [ | ||
{ | ||
provide: HELIPOPPER_CONFIG, | ||
provide: TIPPY_CONFIG, | ||
useValue: config | ||
@@ -778,72 +623,98 @@ } | ||
}; | ||
var HelipopperModule_1; | ||
HelipopperModule = HelipopperModule_1 = __decorate([ | ||
var TippyModule_1; | ||
TippyModule = TippyModule_1 = __decorate([ | ||
core.NgModule({ | ||
declarations: [HelipopperDirective], | ||
exports: [HelipopperDirective] | ||
declarations: [TippyDirective], | ||
exports: [TippyDirective] | ||
}) | ||
], HelipopperModule); | ||
return HelipopperModule; | ||
], TippyModule); | ||
return TippyModule; | ||
}()); | ||
var HelipopperService = /** @class */ (function () { | ||
function HelipopperService(appRef, zone, resolver, hostInjector, platformId, config, initialOptions) { | ||
this.appRef = appRef; | ||
this.zone = zone; | ||
this.resolver = resolver; | ||
this.hostInjector = hostInjector; | ||
this.platformId = platformId; | ||
this.config = config; | ||
this.initialOptions = initialOptions; | ||
var tooltipVariation = { | ||
theme: null, | ||
arrow: false, | ||
animation: 'scale', | ||
trigger: 'mouseenter', | ||
offset: [0, 5] | ||
}; | ||
var popperVariation = { | ||
theme: 'light', | ||
arrow: true, | ||
offset: [0, 10], | ||
animation: null, | ||
trigger: 'click', | ||
interactive: true | ||
}; | ||
function withContextMenuVariation(baseVariation) { | ||
return __assign(__assign({}, baseVariation), { placement: 'right-start', trigger: 'manual', arrow: false, offset: [0, 0] }); | ||
} | ||
var TippyService = /** @class */ (function () { | ||
function TippyService(globalConfig, view, injector) { | ||
this.globalConfig = globalConfig; | ||
this.view = view; | ||
this.injector = injector; | ||
} | ||
HelipopperService.prototype.open = function (host, helipopper, options) { | ||
var directive = new HelipopperDirective(host, this.appRef, this.zone, this.resolver, this.hostInjector, this.platformId, this.config, this.initialOptions); | ||
directive.helipopper = helipopper; | ||
directive.helipopperOptions = (options === null || options === void 0 ? void 0 : options.options) || this.initialOptions.options; | ||
directive.showOnlyOnTextOverflow = isDefined(options === null || options === void 0 ? void 0 : options.textOverflow) | ||
? options === null || options === void 0 ? void 0 : options.textOverflow : this.initialOptions.textOverflow; | ||
directive.triggerTarget = options === null || options === void 0 ? void 0 : options.triggerTarget; | ||
directive.helipopperAppendTo = (options === null || options === void 0 ? void 0 : options.appendTo) || this.initialOptions.appendTo; | ||
directive.helipopperTrigger = options === null || options === void 0 ? void 0 : options.trigger; | ||
directive.helipopperClass = options === null || options === void 0 ? void 0 : options.class; | ||
directive.helipopperOffset = options === null || options === void 0 ? void 0 : options.offset; | ||
directive.injector = options === null || options === void 0 ? void 0 : options.injector; | ||
directive.placement = (options === null || options === void 0 ? void 0 : options.placement) || this.initialOptions.placement; | ||
directive.variation = (options === null || options === void 0 ? void 0 : options.variation) || this.initialOptions.variation; | ||
directive.disabled = isDefined(options === null || options === void 0 ? void 0 : options.disabled) ? options === null || options === void 0 ? void 0 : options.disabled : this.initialOptions.disabled; | ||
directive.sticky = options === null || options === void 0 ? void 0 : options.sticky; | ||
directive.helipopperAllowClose = isDefined(options === null || options === void 0 ? void 0 : options.allowClose) | ||
? options === null || options === void 0 ? void 0 : options.allowClose : this.initialOptions.allowClose; | ||
directive.whenStable.subscribe(function () { return directive.show(); }); | ||
return directive; | ||
TippyService.prototype.create = function (host, content, options) { | ||
var _this = this; | ||
if (options === void 0) { options = {}; } | ||
var view; | ||
var config = __assign(__assign(__assign({ $viewOptions: undefined, onShow: function (instance) { | ||
var _a; | ||
if (!config.$viewOptions) { | ||
config.$viewOptions = {}; | ||
if (overview.isTemplateRef(content)) { | ||
config.$viewOptions.context = { | ||
$implicit: instance.hide.bind(instance) | ||
}; | ||
} | ||
else if (overview.isComponent(content)) { | ||
config.$viewOptions.injector = core.Injector.create({ | ||
providers: [{ provide: TIPPY_REF, useValue: instance }], | ||
parent: options.injector || _this.injector | ||
}); | ||
} | ||
} | ||
view = _this.view.createView(content, __assign(__assign({}, options), config.$viewOptions)); | ||
instance.setContent(view.getElement()); | ||
(_a = options === null || options === void 0 ? void 0 : options.onShow) === null || _a === void 0 ? void 0 : _a.call(options, instance); | ||
}, onHidden: function (instance) { | ||
var _a; | ||
view.destroy(); | ||
(_a = options === null || options === void 0 ? void 0 : options.onHidden) === null || _a === void 0 ? void 0 : _a.call(options, instance); | ||
view = null; | ||
} }, this.globalConfig), this.globalConfig.variations[options.variation || this.globalConfig.defaultVariation]), options); | ||
var instance = tippy(host, config); | ||
var original = instance.destroy; | ||
instance.destroy = function () { | ||
original.call(tippy); | ||
view === null || view === void 0 ? void 0 : view.destroy(); | ||
view = null; | ||
}; | ||
return instance; | ||
}; | ||
HelipopperService.ctorParameters = function () { return [ | ||
{ type: core.ApplicationRef }, | ||
{ type: core.NgZone }, | ||
{ type: core.ComponentFactoryResolver }, | ||
{ type: core.Injector }, | ||
{ type: String, decorators: [{ type: core.Inject, args: [core.PLATFORM_ID,] }] }, | ||
{ type: undefined, decorators: [{ type: core.Inject, args: [HELIPOPPER_CONFIG,] }] }, | ||
{ type: undefined, decorators: [{ type: core.Inject, args: [INITIAL_HELIPOPPER_OPTIONS,] }] } | ||
TippyService.ctorParameters = function () { return [ | ||
{ type: undefined, decorators: [{ type: core.Inject, args: [TIPPY_CONFIG,] }] }, | ||
{ type: overview.ViewService }, | ||
{ type: core.Injector } | ||
]; }; | ||
HelipopperService.ɵprov = core.ɵɵdefineInjectable({ factory: function HelipopperService_Factory() { return new HelipopperService(core.ɵɵinject(core.ApplicationRef), core.ɵɵinject(core.NgZone), core.ɵɵinject(core.ComponentFactoryResolver), core.ɵɵinject(core.INJECTOR), core.ɵɵinject(core.PLATFORM_ID), core.ɵɵinject(HELIPOPPER_CONFIG), core.ɵɵinject(INITIAL_HELIPOPPER_OPTIONS)); }, token: HelipopperService, providedIn: "root" }); | ||
HelipopperService = __decorate([ | ||
core.Injectable({ | ||
providedIn: 'root' | ||
}), | ||
__param(4, core.Inject(core.PLATFORM_ID)), | ||
__param(5, core.Inject(HELIPOPPER_CONFIG)), | ||
__param(6, core.Inject(INITIAL_HELIPOPPER_OPTIONS)) | ||
], HelipopperService); | ||
return HelipopperService; | ||
TippyService.ɵprov = core.ɵɵdefineInjectable({ factory: function TippyService_Factory() { return new TippyService(core.ɵɵinject(TIPPY_CONFIG), core.ɵɵinject(overview.ViewService), core.ɵɵinject(core.INJECTOR)); }, token: TippyService, providedIn: "root" }); | ||
TippyService = __decorate([ | ||
core.Injectable({ providedIn: 'root' }), | ||
__param(0, core.Inject(TIPPY_CONFIG)) | ||
], TippyService); | ||
return TippyService; | ||
}()); | ||
function isDefined(value) { | ||
return value !== undefined; | ||
} | ||
exports.HelipopperDirective = HelipopperDirective; | ||
exports.HelipopperModule = HelipopperModule; | ||
exports.HelipopperService = HelipopperService; | ||
exports.ɵb = HELIPOPPER_CONFIG; | ||
exports.ɵc = INITIAL_HELIPOPPER_OPTIONS; | ||
exports.TIPPY_REF = TIPPY_REF; | ||
exports.TippyModule = TippyModule; | ||
exports.TippyService = TippyService; | ||
exports.inView = inView; | ||
exports.overflowChanges = overflowChanges; | ||
exports.popperVariation = popperVariation; | ||
exports.tooltipVariation = tooltipVariation; | ||
exports.withContextMenuVariation = withContextMenuVariation; | ||
exports.ɵa = TIPPY_CONFIG; | ||
exports.ɵc = TippyDirective; | ||
@@ -850,0 +721,0 @@ Object.defineProperty(exports, '__esModule', { value: true }); |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/common"),require("tippy.js"),require("rxjs"),require("rxjs/operators")):"function"==typeof define&&define.amd?define("@ngneat/helipopper",["exports","@angular/core","@angular/common","tippy.js","rxjs","rxjs/operators"],t):t(((e=e||self).ngneat=e.ngneat||{},e.ngneat.helipopper={}),e.ng.core,e.ng.common,e.tippy,e.rxjs,e.rxjs.operators)}(this,(function(e,t,o,i,n,r){"use strict";i=i&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i;var p=function(){return(p=Object.assign||function(e){for(var t,o=1,i=arguments.length;o<i;o++)for(var n in t=arguments[o])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}).apply(this,arguments)};function s(e,t,o,i){var n,r=arguments.length,p=r<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)p=Reflect.decorate(e,t,o,i);else for(var s=e.length-1;s>=0;s--)(n=e[s])&&(p=(r<3?n(p):r>3?n(t,o,p):n(t,o))||p);return r>3&&p&&Object.defineProperty(t,o,p),p}function l(e,t){return function(o,i){t(o,i,e)}}function a(e,t){var o="function"==typeof Symbol&&e[Symbol.iterator];if(!o)return e;var i,n,r=o.call(e),p=[];try{for(;(void 0===t||t-- >0)&&!(i=r.next()).done;)p.push(i.value)}catch(e){n={error:e}}finally{try{i&&!i.done&&(o=r.return)&&o.call(r)}finally{if(n)throw n.error}}return p}var h=!1,c=!1;"undefined"!=typeof window&&(h="IntersectionObserver"in window,c="ResizeObserver"in window);function u(e,t){return c?function(e,t){void 0===t&&(t={box:"border-box"});return new n.Observable((function(o){var i=new ResizeObserver((function(e){var t=a(e,1)[0];t.borderBoxSize?o.next({width:t.borderBoxSize.inlineSize,height:t.borderBoxSize.blockSize}):o.next({width:t.target.offsetWidth,height:t.target.offsetHeight})}));return i.observe(e,t),function(){return i.disconnect()}}))}(e,t).pipe(r.auditTime(150)):function(e){return n.fromEvent(window,"resize").pipe(r.auditTime(150),r.map((function(){return{width:e.offsetWidth,height:e.offsetHeight}})),r.distinctUntilChanged((function(e,t){return e.width===t.width&&e.height===t.height})))}(e)}function d(e){return e instanceof t.ElementRef?e.nativeElement:e}function f(e,t){Array.isArray(t)?t.forEach((function(t){return e.classList.add(t)})):e.classList.add(t)}var v=function(){function e(e){var t;this.wrapper=null,this.viewRef=e.createEmbeddedView({}),this.viewRef.detectChanges(),1===this.viewRef.rootNodes.length?this.elementRef=this.viewRef.rootNodes[0]:(this.wrapper=document.createElement("div"),(t=this.wrapper).append.apply(t,function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(a(arguments[t]));return e}(this.viewRef.rootNodes)),this.elementRef=this.wrapper)}return e.prototype.destroy=function(){null!==this.wrapper&&(this.wrapper.parentNode.removeChild(this.wrapper),this.wrapper=null),this.viewRef.destroy()},e}();var y=new t.InjectionToken("HELIPOPPER_CONFIG"),g=new t.InjectionToken("InitialHelipopperOptions",{providedIn:"root",factory:function(){return{options:{},textOverflow:!1,appendTo:t.inject(o.DOCUMENT).body,placement:"top",variation:"tooltip",disabled:!1,allowClose:!0}}}),m=function(){function e(e,t,o,i,r,p,s,l){this.host=e,this.appRef=t,this.zone=o,this.resolver=i,this.hostInjector=r,this.platformId=p,this.initialOptions=l,this.helipopperOptions=this.initialOptions.options,this.showOnlyOnTextOverflow=this.initialOptions.textOverflow,this.helipopperAppendTo=this.initialOptions.appendTo,this.helipopperUseHostWidth=!1,this.helipopperAllowClose=this.initialOptions.allowClose,this.helipopperClose=new n.Subject,this.helipopperVisible=new n.Subject,this._destroy=new n.Subject,this._placement=this.initialOptions.placement,this._disabled=!1,this._variation=this.initialOptions.variation,this.whenStable=new n.Subject,this.isVisible=!1,this.mergedConfig=this.createConfig(s)}return Object.defineProperty(e.prototype,"placement",{set:function(e){this._placement=e,this.setProps({placement:e})},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"variation",{set:function(e){this._variation=e,this.setProps(this.resolveTheme())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"disabled",{set:function(e){this._disabled=e,this.markDisabled(this._disabled)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"sticky",{set:function(e){this.instance&&(e?(this.setProps({trigger:"manual",hideOnClick:!1}),this.show()):(this.hide(),this.setProps({trigger:this.helipopperTrigger})))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"helipopper",{set:function(e){var t=this;o.isPlatformServer(this.platformId)||(this.destroyView(),this._content=e,this.instance?this.checkOverflow():requestAnimationFrame((function(){var e,o;(e=t.host.nativeElement,void 0===o&&(o={root:null,threshold:.3}),new n.Observable((function(t){if(!h)return t.next(),void t.complete();var i=new IntersectionObserver((function(e){var o;(o=e)[o.length-1].isIntersecting&&(t.next(),t.complete())}),o);return i.observe(e),function(){return i.disconnect()}}))).pipe(r.takeUntil(t._destroy)).subscribe((function(){return t.create()}))})))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"_tooltipTarget",{get:function(){return d(this.triggerTarget)||this.host.nativeElement},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"_tooltipHost",{get:function(){return d(this.helipopperHost)||this.host.nativeElement},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isTooltip",{get:function(){return"tooltip"===this._variation},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isPopper",{get:function(){return"popper"===this._variation},enumerable:!0,configurable:!0}),e.prototype.setProps=function(e){this.instance&&this.instance.setProps(e)},e.prototype.hide=function(){this.instance.hide()},e.prototype.show=function(){this.instance.show()},e.prototype.ngOnDestroy=function(){this.destroyView(),this.instance&&this.instance.destroy(),this.instance=null,this._destroy.next()},e.prototype.destroy=function(){this.ngOnDestroy()},Object.defineProperty(e.prototype,"hostWidth",{get:function(){return this._tooltipHost.getBoundingClientRect().width+"px"},enumerable:!0,configurable:!0}),e.prototype.destroyView=function(){this.tplPortal&&this.destroyTemplate(),this.innerComponentRef&&this.destroyComponent()},e.prototype.create=function(){var e=this;this.zone.runOutsideAngular((function(){return e.createInstance()}))},e.prototype.createInstance=function(){var e=this;this.showOnlyOnTextOverflow&&u(this._tooltipHost).pipe(r.takeUntil(this._destroy)).subscribe((function(){e.markDisabled(!1===e.isElementOverflow())})),this.helipopperTrigger=this.resolveTrigger();var t=this.helipopperUseHostWidth?this.hostWidth:this.helipopperMaxWidth;this.instance=i(this._tooltipHost,p(p({content:void 0,appendTo:this.getParent(),arrow:!this.isTooltip,allowHTML:!0,zIndex:1e6,trigger:this.helipopperTrigger,placement:this._placement,triggerTarget:this._tooltipTarget,maxWidth:t,hideOnClick:this.helipopperAllowClose,onMount:function(){e.isVisible=!0,e.helipopperVisible.next(!0)},onCreate:function(t){var o,i,n;e.helipopperClass&&f(t.popper,e.helipopperClass),e.helipopperUseHostWidth&&(o=t.popper,i="width",n=e.hostWidth,o.style[i]=n)},onShow:function(t){e.zone.run((function(){return e.instance.setContent(e.resolveContent())})),e.helipopperAllowClose&&e.isPopper&&e.addCloseButton(t)},onHidden:function(t){e.helipopperAllowClose&&e.isPopper&&e.removeCloseButton(t),e.destroyView(),e.isVisible=!1,e.helipopperClose.next(),e.helipopperVisible.next(!1)}},this.resolveTheme()),this.helipopperOptions)),this.whenStable.next(!0),this.markDisabled(this._disabled)},e.prototype.resolveTrigger=function(){return this.helipopperTrigger||(this.isTooltip?"mouseenter":"click")},e.prototype.resolveTemplate=function(e){return this.tplPortal&&this.destroyTemplate(),this.tplPortal=new v(e),this.appRef.attachView(this.tplPortal.viewRef),this.tplPortal.elementRef},e.prototype.isElementOverflow=function(){var e=this._tooltipTarget,t=e.parentElement,o=e.offsetWidth>t.offsetWidth,i=e.offsetWidth<e.scrollWidth;return o||i},e.prototype.getParent=function(){var e,t,o;return"string"==typeof this.helipopperAppendTo?(t=this.host.nativeElement,o=this.helipopperAppendTo,window.Element&&!Element.prototype.closest&&(Element.prototype.closest=function(e){var t,o=(this.document||this.ownerDocument).querySelectorAll(e),i=this;do{for(t=o.length;--t>=0&&o.item(t)!==i;);}while(t<0&&(i=i.parentElement));return i}),e=t.closest(o)):e=this.helipopperAppendTo,e||document.body},e.prototype.markDisabled=function(e){void 0===e&&(e=!0),this.instance&&(e?this.instance.disable():this.instance.enable())},e.prototype.resolveTheme=function(){return{offset:this.helipopperOffset||[0,this.isTooltip?5:10],theme:this.isTooltip?null:"light",arrow:!1===this.isTooltip,animation:this.isTooltip?"scale":null,interactive:!this.isTooltip}},e.prototype.addCloseButton=function(e){var t,o=this,i=e.popper,r=this.mergedConfig.closeIcon,p=(t="div",document.createElement(t));f(p,"tippy-close"),p.innerHTML=r;var s=n.fromEvent(p,"click").subscribe((function(){return o.hide()}));i.appendChild(p),e.closeButtonElement=p,e.closeButtonSubscription=s},e.prototype.removeCloseButton=function(e){e.popper.removeChild(e.closeButtonElement),e.closeButtonSubscription.unsubscribe(),e.closeButtonElement=null,e.closeButtonSubscription=null},e.prototype.checkOverflow=function(){var e=this;this.showOnlyOnTextOverflow&&requestAnimationFrame((function(){return e.markDisabled(!1===e.isElementOverflow())}))},e.prototype.destroyTemplate=function(){this.appRef.detachView(this.tplPortal.viewRef),this.tplPortal.destroy(),this.tplPortal=null},e.prototype.createConfig=function(e){return p(p({},{closeIcon:'\n <svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 24 24" fit="" preserveAspectRatio="xMidYMid meet" focusable="false">\n<path d="M12.793 12l4.039-4.025c0.219-0.219 0.224-0.578 0.012-0.802-0.213-0.225-0.563-0.231-0.782-0.011l-4.062 4.049-4.062-4.049c-0.219-0.22-0.569-0.213-0.782 0.011s-0.208 0.583 0.012 0.802l4.039 4.025-4.039 4.025c-0.22 0.219-0.224 0.578-0.012 0.802 0.108 0.115 0.252 0.172 0.397 0.172 0.138 0 0.278-0.053 0.385-0.161l4.062-4.049 4.062 4.049c0.107 0.108 0.245 0.161 0.385 0.161 0.144 0 0.287-0.058 0.397-0.172 0.212-0.225 0.207-0.583-0.012-0.802l-4.039-4.025z"></path>\n</svg>\n ',beforeRender:function(e){return e}}),e)},e.prototype.resolveComponent=function(e){var t=this.resolver.resolveComponentFactory(e),o=this.injector||this.hostInjector;return this.innerComponentRef=t.create(o),this.appRef.attachView(this.innerComponentRef.hostView),this.innerComponentRef.hostView.detectChanges(),this.innerComponentRef.location.nativeElement},e.prototype.destroyComponent=function(){this.innerComponentRef.destroy(),this.appRef.detachView(this.innerComponentRef.hostView),this.innerComponentRef=null},e.prototype.resolveContent=function(){var e=this._content;return e instanceof t.TemplateRef?this.resolveTemplate(e):"string"==typeof e?this.mergedConfig.beforeRender(e):this.resolveComponent(e)},e.ctorParameters=function(){return[{type:t.ElementRef},{type:t.ApplicationRef},{type:t.NgZone},{type:t.ComponentFactoryResolver},{type:t.Injector},{type:String,decorators:[{type:t.Inject,args:[t.PLATFORM_ID]}]},{type:void 0,decorators:[{type:t.Inject,args:[y]}]},{type:void 0,decorators:[{type:t.Inject,args:[g]}]}]},s([t.Input()],e.prototype,"helipopperOptions",void 0),s([t.Input("helipopperTextOverflow")],e.prototype,"showOnlyOnTextOverflow",void 0),s([t.Input()],e.prototype,"triggerTarget",void 0),s([t.Input()],e.prototype,"helipopperHost",void 0),s([t.Input()],e.prototype,"helipopperAppendTo",void 0),s([t.Input()],e.prototype,"helipopperTrigger",void 0),s([t.Input()],e.prototype,"helipopperMaxWidth",void 0),s([t.Input()],e.prototype,"helipopperUseHostWidth",void 0),s([t.Input()],e.prototype,"helipopperAllowClose",void 0),s([t.Input()],e.prototype,"helipopperClass",void 0),s([t.Input()],e.prototype,"helipopperOffset",void 0),s([t.Input("helipopperInjector")],e.prototype,"injector",void 0),s([t.Input("helipopperPlacement")],e.prototype,"placement",null),s([t.Input("helipopperVariation")],e.prototype,"variation",null),s([t.Input("helipopperDisabled")],e.prototype,"disabled",null),s([t.Input("helipopperSticky")],e.prototype,"sticky",null),s([t.Input()],e.prototype,"helipopper",null),s([t.Output()],e.prototype,"helipopperClose",void 0),s([t.Output()],e.prototype,"helipopperVisible",void 0),e=s([t.Directive({selector:"[helipopper]",exportAs:"helipopper"}),l(5,t.Inject(t.PLATFORM_ID)),l(6,t.Inject(y)),l(7,t.Inject(g))],e)}(),w=function(){function e(){}var o;return o=e,e.forRoot=function(e){return void 0===e&&(e={}),{ngModule:o,providers:[{provide:y,useValue:e}]}},e=o=s([t.NgModule({declarations:[m],exports:[m]})],e)}(),b=function(){function e(e,t,o,i,n,r,p){this.appRef=e,this.zone=t,this.resolver=o,this.hostInjector=i,this.platformId=n,this.config=r,this.initialOptions=p}return e.prototype.open=function(e,t,o){var i=new m(e,this.appRef,this.zone,this.resolver,this.hostInjector,this.platformId,this.config,this.initialOptions);return i.helipopper=t,i.helipopperOptions=(null==o?void 0:o.options)||this.initialOptions.options,i.showOnlyOnTextOverflow=O(null==o?void 0:o.textOverflow)?null==o?void 0:o.textOverflow:this.initialOptions.textOverflow,i.triggerTarget=null==o?void 0:o.triggerTarget,i.helipopperAppendTo=(null==o?void 0:o.appendTo)||this.initialOptions.appendTo,i.helipopperTrigger=null==o?void 0:o.trigger,i.helipopperClass=null==o?void 0:o.class,i.helipopperOffset=null==o?void 0:o.offset,i.injector=null==o?void 0:o.injector,i.placement=(null==o?void 0:o.placement)||this.initialOptions.placement,i.variation=(null==o?void 0:o.variation)||this.initialOptions.variation,i.disabled=O(null==o?void 0:o.disabled)?null==o?void 0:o.disabled:this.initialOptions.disabled,i.sticky=null==o?void 0:o.sticky,i.helipopperAllowClose=O(null==o?void 0:o.allowClose)?null==o?void 0:o.allowClose:this.initialOptions.allowClose,i.whenStable.subscribe((function(){return i.show()})),i},e.ctorParameters=function(){return[{type:t.ApplicationRef},{type:t.NgZone},{type:t.ComponentFactoryResolver},{type:t.Injector},{type:String,decorators:[{type:t.Inject,args:[t.PLATFORM_ID]}]},{type:void 0,decorators:[{type:t.Inject,args:[y]}]},{type:void 0,decorators:[{type:t.Inject,args:[g]}]}]},e.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e(t.ɵɵinject(t.ApplicationRef),t.ɵɵinject(t.NgZone),t.ɵɵinject(t.ComponentFactoryResolver),t.ɵɵinject(t.INJECTOR),t.ɵɵinject(t.PLATFORM_ID),t.ɵɵinject(y),t.ɵɵinject(g))},token:e,providedIn:"root"}),e=s([t.Injectable({providedIn:"root"}),l(4,t.Inject(t.PLATFORM_ID)),l(5,t.Inject(y)),l(6,t.Inject(g))],e)}();function O(e){return void 0!==e}e.HelipopperDirective=m,e.HelipopperModule=w,e.HelipopperService=b,e.ɵb=y,e.ɵc=g,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("tippy.js"),require("rxjs"),require("rxjs/operators"),require("@ngneat/overview"),require("@angular/common")):"function"==typeof define&&define.amd?define("@ngneat/helipopper",["exports","@angular/core","tippy.js","rxjs","rxjs/operators","@ngneat/overview","@angular/common"],e):e(((t=t||self).ngneat=t.ngneat||{},t.ngneat.helipopper={}),t.ng.core,t.tippy,t.rxjs,t.rxjs.operators,t.ngneatOverview,t.ng.common)}(this,(function(t,e,n,i,o,r,s){"use strict";n=n&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n;var a=function(){return(a=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function p(t,e,n,i){var o,r=arguments.length,s=r<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,i);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(r<3?o(s):r>3?o(e,n,s):o(e,n))||s);return r>3&&s&&Object.defineProperty(e,n,s),s}function c(t,e){return function(n,i){e(n,i,t)}}var l=new e.InjectionToken("Tippy config",{providedIn:"root",factory:function(){return{}}}),u=new e.InjectionToken("TIPPY_REF");function d(t){return t instanceof e.ElementRef?t.nativeElement:t}var v=!1,h=!1;function f(t,e){void 0===e&&(e={root:null,threshold:.3});var n=d(t);return new i.Observable((function(t){if(!v)return t.next(),void t.complete();var i=new IntersectionObserver((function(e){e[e.length-1].isIntersecting&&(t.next(),t.complete())}),e);return i.observe(n),function(){return i.disconnect()}}))}function y(t){var e,n=d(t);return(e=n,function(t){return new i.Observable((function(e){if(!h)return e.next(),void e.complete();var n=new ResizeObserver((function(){return e.next(!0)}));return n.observe(t),function(){return n.disconnect()}}))}(e).pipe(o.auditTime(150))).pipe(o.map((function(){return function(t){var e=t.parentElement,n=t.offsetWidth>e.offsetWidth,i=t.offsetWidth<t.scrollWidth;return n||i}(n)})))}"undefined"!=typeof window&&(v="IntersectionObserver"in window,h="ResizeObserver"in window);var g=function(){function t(t,n,o,r,s,a,p){this.platformId=t,this.globalConfig=n,this.injector=o,this.viewService=r,this.vcr=s,this.zone=a,this.host=p,this.onlyTextOverflow=!1,this.useHostWidth=!1,this.visible=new e.EventEmitter,this.isVisible=!1,this.destroyed=new i.Subject,this.enabled=!0,this.variationDefined=!1}return t.prototype.ngOnChanges=function(t){if(!s.isPlatformServer(this.platformId)){t.content&&(this.view=t.content.currentValue);var e,n=Object.keys(t).reduce((function(e,n){return e[n]=t[n].currentValue,e}),{});w("variation",t)?e=t.variation.currentValue:this.variationDefined||(e=this.globalConfig.defaultVariation,this.variationDefined=!0),e&&(n=a(a({},this.globalConfig.variations[e]),n)),w("isEnable",t)&&(this.enabled=t.isEnable.currentValue,this.setStatus()),delete n.content,this.setProps(n)}},t.prototype.ngOnInit=function(){this.useHostWidth&&(this.props.maxWidth=this.hostWidth)},t.prototype.ngAfterViewInit=function(){var t=this;this.lazy?this.onlyTextOverflow?f(this.host).pipe(o.switchMap((function(){return y(t.host)})),o.takeUntil(this.destroyed)).subscribe((function(e){t.checkOverflow(e)})):f(this.host).pipe(o.takeUntil(this.destroyed)).subscribe((function(){t.createInstance()})):this.onlyTextOverflow?y(this.host).pipe(o.takeUntil(this.destroyed)).subscribe((function(e){t.checkOverflow(e)})):this.createInstance()},t.prototype.ngOnDestroy=function(){var t;this.destroyed.next(),null===(t=this.instance)||void 0===t||t.destroy(),this.destroyView()},t.prototype.destroyView=function(){var t;null===(t=this.viewRef)||void 0===t||t.destroy(),this.viewRef=null},t.prototype.show=function(){var t;null===(t=this.instance)||void 0===t||t.show()},t.prototype.hide=function(){var t;null===(t=this.instance)||void 0===t||t.hide()},t.prototype.enable=function(){var t;null===(t=this.instance)||void 0===t||t.enable()},t.prototype.disable=function(){var t;null===(t=this.instance)||void 0===t||t.disable()},t.prototype.setProps=function(t){var e;this.props=t,null===(e=this.instance)||void 0===e||e.setProps(t)},t.prototype.setStatus=function(){var t,e;this.enabled?null===(t=this.instance)||void 0===t||t.enable():null===(e=this.instance)||void 0===e||e.disable()},Object.defineProperty(t.prototype,"hostWidth",{get:function(){return this.host.nativeElement.getBoundingClientRect().width+"px"},enumerable:!0,configurable:!0}),t.prototype.createInstance=function(){var t=this;this.instance=n(this.host.nativeElement,a(a(a({allowHTML:!0},this.globalConfig),this.props),{onMount:function(e){var n,i;t.isVisible=!0,t.visible.next(!0),null===(i=(n=t.globalConfig).onMount)||void 0===i||i.call(n,e)},onCreate:function(e){var n,i;t.className&&e.popper.classList.add(t.className),t.useHostWidth&&(e.popper.style.width=t.hostWidth),null===(i=(n=t.globalConfig).onCreate)||void 0===i||i.call(n,e)},onShow:function(e){var n,i;t.zone.run((function(){return t.instance.setContent(t.resolveContent())})),null===(i=(n=t.globalConfig).onShow)||void 0===i||i.call(n,e)},onHidden:function(e){var n,i;t.destroyView(),t.isVisible=!1,t.visible.next(!1),null===(i=(n=t.globalConfig).onHidden)||void 0===i||i.call(n,e)}})),this.setStatus(),this.setProps(this.props),"contextMenu"===this.variation&&this.handleContextMenu()},t.prototype.resolveContent=function(){this.viewOptions$||r.isString(this.content)||(r.isComponent(this.content)?this.viewOptions$={injector:e.Injector.create({providers:[{provide:u,useValue:this.instance}],parent:this.injector})}:r.isTemplateRef(this.content)&&(this.viewOptions$={context:{$implicit:this.hide.bind(this),data:this.data}})),this.viewRef=this.viewService.createView(this.content,a({vcr:this.vcr},this.viewOptions$));var t=this.viewRef.getElement();return r.isString(t)&&this.globalConfig.beforeRender&&(t=this.globalConfig.beforeRender(t)),t},t.prototype.handleContextMenu=function(){var t=this;i.fromEvent(this.host.nativeElement,"contextmenu").pipe(o.takeUntil(this.destroyed)).subscribe((function(e){e.preventDefault(),t.instance.setProps({getReferenceClientRect:function(){return{width:0,height:0,top:e.clientY,bottom:e.clientY,left:e.clientX,right:e.clientX}}}),t.instance.show()}))},t.prototype.checkOverflow=function(t){var e;t?this.instance?this.instance.enable():this.createInstance():null===(e=this.instance)||void 0===e||e.disable()},t.ctorParameters=function(){return[{type:String,decorators:[{type:e.Inject,args:[e.PLATFORM_ID]}]},{type:void 0,decorators:[{type:e.Inject,args:[l]}]},{type:e.Injector},{type:r.ViewService},{type:e.ViewContainerRef},{type:e.NgZone},{type:e.ElementRef}]},p([e.Input()],t.prototype,"appendTo",void 0),p([e.Input()],t.prototype,"delay",void 0),p([e.Input()],t.prototype,"duration",void 0),p([e.Input()],t.prototype,"hideOnClick",void 0),p([e.Input()],t.prototype,"interactive",void 0),p([e.Input()],t.prototype,"interactiveBorder",void 0),p([e.Input()],t.prototype,"maxWidth",void 0),p([e.Input()],t.prototype,"offset",void 0),p([e.Input()],t.prototype,"placement",void 0),p([e.Input()],t.prototype,"popperOptions",void 0),p([e.Input()],t.prototype,"showOnCreate",void 0),p([e.Input()],t.prototype,"trigger",void 0),p([e.Input()],t.prototype,"triggerTarget",void 0),p([e.Input()],t.prototype,"zIndex",void 0),p([e.Input()],t.prototype,"lazy",void 0),p([e.Input()],t.prototype,"variation",void 0),p([e.Input()],t.prototype,"isEnable",void 0),p([e.Input()],t.prototype,"className",void 0),p([e.Input()],t.prototype,"onlyTextOverflow",void 0),p([e.Input()],t.prototype,"data",void 0),p([e.Input()],t.prototype,"useHostWidth",void 0),p([e.Input("tippy")],t.prototype,"content",void 0),p([e.Output()],t.prototype,"visible",void 0),t=p([e.Directive({selector:"[tippy]",exportAs:"tippy"}),c(0,e.Inject(e.PLATFORM_ID)),c(1,e.Inject(l))],t)}();function w(t,e){return t in e}var b=function(){function t(){}var n;return n=t,t.forRoot=function(t){return void 0===t&&(t={}),{ngModule:n,providers:[{provide:l,useValue:t}]}},t=n=p([e.NgModule({declarations:[g],exports:[g]})],t)}();var I=function(){function t(t,e,n){this.globalConfig=t,this.view=e,this.injector=n}return t.prototype.create=function(t,i,o){var s,p=this;void 0===o&&(o={});var c=a(a(a({$viewOptions:void 0,onShow:function(t){var n;c.$viewOptions||(c.$viewOptions={},r.isTemplateRef(i)?c.$viewOptions.context={$implicit:t.hide.bind(t)}:r.isComponent(i)&&(c.$viewOptions.injector=e.Injector.create({providers:[{provide:u,useValue:t}],parent:o.injector||p.injector}))),s=p.view.createView(i,a(a({},o),c.$viewOptions)),t.setContent(s.getElement()),null===(n=null==o?void 0:o.onShow)||void 0===n||n.call(o,t)},onHidden:function(t){var e;s.destroy(),null===(e=null==o?void 0:o.onHidden)||void 0===e||e.call(o,t),s=null}},this.globalConfig),this.globalConfig.variations[o.variation||this.globalConfig.defaultVariation]),o),l=n(t,c),d=l.destroy;return l.destroy=function(){d.call(n),null==s||s.destroy(),s=null},l},t.ctorParameters=function(){return[{type:void 0,decorators:[{type:e.Inject,args:[l]}]},{type:r.ViewService},{type:e.Injector}]},t.ɵprov=e.ɵɵdefineInjectable({factory:function(){return new t(e.ɵɵinject(l),e.ɵɵinject(r.ViewService),e.ɵɵinject(e.INJECTOR))},token:t,providedIn:"root"}),t=p([e.Injectable({providedIn:"root"}),c(0,e.Inject(l))],t)}();t.TIPPY_REF=u,t.TippyModule=b,t.TippyService=I,t.inView=f,t.overflowChanges=y,t.popperVariation={theme:"light",arrow:!0,offset:[0,10],animation:null,trigger:"click",interactive:!0},t.tooltipVariation={theme:null,arrow:!1,animation:"scale",trigger:"mouseenter",offset:[0,5]},t.withContextMenuVariation=function(t){return a(a({},t),{placement:"right-start",trigger:"manual",arrow:!1,offset:[0,0]})},t.ɵa=l,t.ɵc=g,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=ngneat-helipopper.umd.min.js.map |
@@ -1,5 +0,6 @@ | ||
import { fromEvent, Observable } from 'rxjs'; | ||
import { auditTime, distinctUntilChanged, map } from 'rxjs/operators'; | ||
import { ElementRef } from '@angular/core'; | ||
let supportsIntersectionObserver = false, supportsResizeObserver = false; | ||
import { Observable } from 'rxjs'; | ||
import { auditTime, map } from 'rxjs/operators'; | ||
import { coerceElement } from './tippy.types'; | ||
let supportsIntersectionObserver = false; | ||
let supportsResizeObserver = false; | ||
if (typeof window !== 'undefined') { | ||
@@ -9,6 +10,7 @@ supportsIntersectionObserver = 'IntersectionObserver' in window; | ||
} | ||
export function inView(element, options = { | ||
export function inView(host, options = { | ||
root: null, | ||
threshold: 0.3 | ||
}) { | ||
const element = coerceElement(host); | ||
return new Observable(subscriber => { | ||
@@ -18,4 +20,2 @@ if (!supportsIntersectionObserver) { | ||
subscriber.complete(); | ||
// If the browser doesn't support the `IntersectionObserver` then | ||
// we "return" since it will throw `IntersectionObserver is not defined`. | ||
return; | ||
@@ -25,3 +25,3 @@ } | ||
// Several changes may occur in the same tick, we want to check the latest entry state. | ||
const entry = last(entries); | ||
const entry = entries[entries.length - 1]; | ||
if (entry.isIntersecting) { | ||
@@ -36,100 +36,29 @@ subscriber.next(); | ||
} | ||
const AUDIT_TIME = 150; | ||
export function dimensionsChanges(target, options) { | ||
return supportsResizeObserver | ||
? resizeObserverStrategy(target, options).pipe(auditTime(AUDIT_TIME)) | ||
: resizeWindowStrategy(target); | ||
function isElementOverflow(host) { | ||
const parentEl = host.parentElement; | ||
const parentTest = host.offsetWidth > parentEl.offsetWidth; | ||
const elementTest = host.offsetWidth < host.scrollWidth; | ||
return parentTest || elementTest; | ||
} | ||
function resizeWindowStrategy(target) { | ||
return fromEvent(window, 'resize').pipe(auditTime(AUDIT_TIME), map(() => ({ | ||
width: target.offsetWidth, | ||
height: target.offsetHeight | ||
})), distinctUntilChanged((prev, current) => { | ||
return prev.width === current.width && prev.height === current.height; | ||
export function overflowChanges(host) { | ||
const element = coerceElement(host); | ||
return dimensionsChanges(element).pipe(map(() => { | ||
return isElementOverflow(element); | ||
})); | ||
} | ||
function resizeObserverStrategy(target, options = { box: 'border-box' }) { | ||
export function dimensionsChanges(target) { | ||
return resizeObserverStrategy(target).pipe(auditTime(150)); | ||
} | ||
function resizeObserverStrategy(target) { | ||
return new Observable(subscriber => { | ||
const observer = new ResizeObserver(([entry]) => { | ||
// Currently, only Firefox supports `borderBoxSize` property which | ||
// gives the border-box value include padding and border | ||
if (entry.borderBoxSize) { | ||
subscriber.next({ | ||
width: entry.borderBoxSize.inlineSize, | ||
height: entry.borderBoxSize.blockSize | ||
}); | ||
} | ||
else { | ||
subscriber.next({ | ||
width: entry.target.offsetWidth, | ||
height: entry.target.offsetHeight | ||
}); | ||
} | ||
}); | ||
observer.observe(target, options); | ||
if (!supportsResizeObserver) { | ||
subscriber.next(); | ||
subscriber.complete(); | ||
return; | ||
} | ||
const observer = new ResizeObserver(() => subscriber.next(true)); | ||
observer.observe(target); | ||
return () => observer.disconnect(); | ||
}); | ||
} | ||
export function coerceElement(elementOrRef) { | ||
return elementOrRef instanceof ElementRef ? elementOrRef.nativeElement : elementOrRef; | ||
} | ||
export function isString(value) { | ||
return typeof value === 'string'; | ||
} | ||
export function addClass(element, className) { | ||
if (Array.isArray(className)) { | ||
className.forEach(name => element.classList.add(name)); | ||
} | ||
else { | ||
element.classList.add(className); | ||
} | ||
} | ||
export function addStyle(element, prop, value) { | ||
element.style[prop] = value; | ||
} | ||
export function createElement(tagName) { | ||
return document.createElement(tagName); | ||
} | ||
export function closest(element, selector) { | ||
if (window['Element'] && !Element.prototype.closest) { | ||
Element.prototype.closest = function (s) { | ||
let matches = (this.document || this.ownerDocument).querySelectorAll(s), i, el = this; | ||
do { | ||
i = matches.length; | ||
while (--i >= 0 && matches.item(i) !== el) { } | ||
} while (i < 0 && (el = el.parentElement)); | ||
return el; | ||
}; | ||
} | ||
return element.closest(selector); | ||
} | ||
export class TemplatePortal { | ||
constructor(tpl) { | ||
this.wrapper = null; | ||
this.viewRef = tpl.createEmbeddedView({}); | ||
this.viewRef.detectChanges(); | ||
if (this.viewRef.rootNodes.length === 1) { | ||
this.elementRef = this.viewRef.rootNodes[0]; | ||
} | ||
else { | ||
this.wrapper = document.createElement('div'); | ||
// The `node` might be an instance of the `Comment` class, | ||
// which is an `ng-container` element. We shouldn't filter it | ||
// out since there can be `ngIf` or any other directive bound | ||
// to the `ng-container`. | ||
this.wrapper.append(...this.viewRef.rootNodes); | ||
this.elementRef = this.wrapper; | ||
} | ||
} | ||
destroy() { | ||
if (this.wrapper !== null) { | ||
this.wrapper.parentNode.removeChild(this.wrapper); | ||
this.wrapper = null; | ||
} | ||
this.viewRef.destroy(); | ||
} | ||
} | ||
function last(arr) { | ||
return arr[arr.length - 1]; | ||
} | ||
//# sour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6IE9ic2VydmFibGU8Ym9vbGVhbj4ge1xuICByZXR1cm4gbmV3IE9ic2VydmFibGUoc3Vic2NyaWJlciA9PiB7XG4gICAgaWYgKCFzdXBwb3J0c1Jlc2l6ZU9ic2VydmVyKSB7XG4gICAgICBzdWJzY3JpYmVyLm5leHQoKTtcbiAgICAgIHN1YnNjcmliZXIuY29tcGxldGUoKTtcbiAgICAgIHJldHVybjtcbiAgICB9XG5cbiAgICBjb25zdCBvYnNlcnZlciA9IG5ldyBSZXNpemVPYnNlcnZlcigoKSA9PiBzdWJzY3JpYmVyLm5leHQodHJ1ZSkpO1xuXG4gICAgb2JzZXJ2ZXIub2JzZXJ2ZSh0YXJnZXQpO1xuXG4gICAgcmV0dXJuICgpID0+IG9ic2VydmVyLmRpc2Nvbm5lY3QoKTtcbiAgfSk7XG59XG4iXX0= |
@@ -5,4 +5,4 @@ /** | ||
export * from './public-api'; | ||
export { INITIAL_HELIPOPPER_OPTIONS as ɵc } from './lib/helipopper-options'; | ||
export { HELIPOPPER_CONFIG as ɵb } from './lib/helipopper.types'; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmduZWF0LWhlbGlwb3BwZXIuanMiLCJzb3VyY2VSb290Ijoibmc6Ly9AbmduZWF0L2hlbGlwb3BwZXIvIiwic291cmNlcyI6WyJuZ25lYXQtaGVsaXBvcHBlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7R0FFRztBQUVILGNBQWMsY0FBYyxDQUFDO0FBRTdCLE9BQU8sRUFBQywwQkFBMEIsSUFBSSxFQUFFLEVBQWdDLE1BQU0sMEJBQTBCLENBQUM7QUFDekcsT0FBTyxFQUFDLGlCQUFpQixJQUFJLEVBQUUsRUFBd0IsTUFBTSx3QkFBd0IsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogR2VuZXJhdGVkIGJ1bmRsZSBpbmRleC4gRG8gbm90IGVkaXQuXG4gKi9cblxuZXhwb3J0ICogZnJvbSAnLi9wdWJsaWMtYXBpJztcblxuZXhwb3J0IHtJTklUSUFMX0hFTElQT1BQRVJfT1BUSU9OUyBhcyDJtWMsUGFydGlhbEhlbGlwb3BwZXJPcHRpb25zIGFzIMm1ZH0gZnJvbSAnLi9saWIvaGVsaXBvcHBlci1vcHRpb25zJztcbmV4cG9ydCB7SEVMSVBPUFBFUl9DT05GSUcgYXMgybViLEhlbGlwb3BwZXJDb25maWcgYXMgybVhfSBmcm9tICcuL2xpYi9oZWxpcG9wcGVyLnR5cGVzJzsiXX0= | ||
export { TippyDirective as ɵc } from './lib/tippy.directive'; | ||
export { TIPPY_CONFIG as ɵa } from './lib/tippy.types'; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmduZWF0LWhlbGlwb3BwZXIuanMiLCJzb3VyY2VSb290Ijoibmc6Ly9AbmduZWF0L2hlbGlwb3BwZXIvIiwic291cmNlcyI6WyJuZ25lYXQtaGVsaXBvcHBlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7R0FFRztBQUVILGNBQWMsY0FBYyxDQUFDO0FBRTdCLE9BQU8sRUFBQyxjQUFjLElBQUksRUFBRSxFQUFDLE1BQU0sdUJBQXVCLENBQUM7QUFDM0QsT0FBTyxFQUFDLFlBQVksSUFBSSxFQUFFLEVBQW1CLE1BQU0sbUJBQW1CLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIEdlbmVyYXRlZCBidW5kbGUgaW5kZXguIERvIG5vdCBlZGl0LlxuICovXG5cbmV4cG9ydCAqIGZyb20gJy4vcHVibGljLWFwaSc7XG5cbmV4cG9ydCB7VGlwcHlEaXJlY3RpdmUgYXMgybVjfSBmcm9tICcuL2xpYi90aXBweS5kaXJlY3RpdmUnO1xuZXhwb3J0IHtUSVBQWV9DT05GSUcgYXMgybVhLFRpcHB5Q29uZmlnIGFzIMm1Yn0gZnJvbSAnLi9saWIvdGlwcHkudHlwZXMnOyJdfQ== |
@@ -1,4 +0,6 @@ | ||
export * from './lib/helipopper.module'; | ||
export * from './lib/helipopper.directive'; | ||
export * from './lib/helipopper.service'; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljLWFwaS5qcyIsInNvdXJjZVJvb3QiOiJuZzovL0BuZ25lYXQvaGVsaXBvcHBlci8iLCJzb3VyY2VzIjpbInB1YmxpYy1hcGkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsY0FBYyx5QkFBeUIsQ0FBQztBQUN4QyxjQUFjLDRCQUE0QixDQUFDO0FBQzNDLGNBQWMsMEJBQTBCLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgKiBmcm9tICcuL2xpYi9oZWxpcG9wcGVyLm1vZHVsZSc7XG5leHBvcnQgKiBmcm9tICcuL2xpYi9oZWxpcG9wcGVyLmRpcmVjdGl2ZSc7XG5leHBvcnQgKiBmcm9tICcuL2xpYi9oZWxpcG9wcGVyLnNlcnZpY2UnO1xuIl19 | ||
export { TippyModule } from "./lib/tippy.module"; | ||
export { tooltipVariation, popperVariation, withContextMenuVariation } from "./lib/defaults"; | ||
export { TippyService } from "./lib/tippy.service"; | ||
export { inView, overflowChanges } from "./lib/utils"; | ||
export { TIPPY_REF } from "./lib/tippy.types"; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljLWFwaS5qcyIsInNvdXJjZVJvb3QiOiJuZzovL0BuZ25lYXQvaGVsaXBvcHBlci8iLCJzb3VyY2VzIjpbInB1YmxpYy1hcGkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFdBQVcsRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBQ2pELE9BQU8sRUFBRSxnQkFBZ0IsRUFBRSxlQUFlLEVBQUUsd0JBQXdCLEVBQUUsTUFBTSxnQkFBZ0IsQ0FBQztBQUM3RixPQUFPLEVBQUUsWUFBWSxFQUFFLE1BQU0scUJBQXFCLENBQUM7QUFDbkQsT0FBTyxFQUFFLE1BQU0sRUFBRSxlQUFlLEVBQUUsTUFBTSxhQUFhLENBQUM7QUFDdEQsT0FBTyxFQUFpQixTQUFTLEVBQUUsTUFBTSxtQkFBbUIsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCB7IFRpcHB5TW9kdWxlIH0gZnJvbSBcIi4vbGliL3RpcHB5Lm1vZHVsZVwiO1xuZXhwb3J0IHsgdG9vbHRpcFZhcmlhdGlvbiwgcG9wcGVyVmFyaWF0aW9uLCB3aXRoQ29udGV4dE1lbnVWYXJpYXRpb24gfSBmcm9tIFwiLi9saWIvZGVmYXVsdHNcIjtcbmV4cG9ydCB7IFRpcHB5U2VydmljZSB9IGZyb20gXCIuL2xpYi90aXBweS5zZXJ2aWNlXCI7XG5leHBvcnQgeyBpblZpZXcsIG92ZXJmbG93Q2hhbmdlcyB9IGZyb20gXCIuL2xpYi91dGlsc1wiO1xuZXhwb3J0IHsgVGlwcHlJbnN0YW5jZSwgVElQUFlfUkVGIH0gZnJvbSBcIi4vbGliL3RpcHB5LnR5cGVzXCI7XG4iXX0= |
@@ -1,6 +0,6 @@ | ||
import { __read, __spread } from "tslib"; | ||
import { fromEvent, Observable } from 'rxjs'; | ||
import { auditTime, distinctUntilChanged, map } from 'rxjs/operators'; | ||
import { ElementRef } from '@angular/core'; | ||
var supportsIntersectionObserver = false, supportsResizeObserver = false; | ||
import { Observable } from 'rxjs'; | ||
import { auditTime, map } from 'rxjs/operators'; | ||
import { coerceElement } from './tippy.types'; | ||
var supportsIntersectionObserver = false; | ||
var supportsResizeObserver = false; | ||
if (typeof window !== 'undefined') { | ||
@@ -10,3 +10,3 @@ supportsIntersectionObserver = 'IntersectionObserver' in window; | ||
} | ||
export function inView(element, options) { | ||
export function inView(host, options) { | ||
if (options === void 0) { options = { | ||
@@ -16,2 +16,3 @@ root: null, | ||
}; } | ||
var element = coerceElement(host); | ||
return new Observable(function (subscriber) { | ||
@@ -21,4 +22,2 @@ if (!supportsIntersectionObserver) { | ||
subscriber.complete(); | ||
// If the browser doesn't support the `IntersectionObserver` then | ||
// we "return" since it will throw `IntersectionObserver is not defined`. | ||
return; | ||
@@ -28,3 +27,3 @@ } | ||
// Several changes may occur in the same tick, we want to check the latest entry state. | ||
var entry = last(entries); | ||
var entry = entries[entries.length - 1]; | ||
if (entry.isIntersecting) { | ||
@@ -39,105 +38,29 @@ subscriber.next(); | ||
} | ||
var AUDIT_TIME = 150; | ||
export function dimensionsChanges(target, options) { | ||
return supportsResizeObserver | ||
? resizeObserverStrategy(target, options).pipe(auditTime(AUDIT_TIME)) | ||
: resizeWindowStrategy(target); | ||
function isElementOverflow(host) { | ||
var parentEl = host.parentElement; | ||
var parentTest = host.offsetWidth > parentEl.offsetWidth; | ||
var elementTest = host.offsetWidth < host.scrollWidth; | ||
return parentTest || elementTest; | ||
} | ||
function resizeWindowStrategy(target) { | ||
return fromEvent(window, 'resize').pipe(auditTime(AUDIT_TIME), map(function () { return ({ | ||
width: target.offsetWidth, | ||
height: target.offsetHeight | ||
}); }), distinctUntilChanged(function (prev, current) { | ||
return prev.width === current.width && prev.height === current.height; | ||
export function overflowChanges(host) { | ||
var element = coerceElement(host); | ||
return dimensionsChanges(element).pipe(map(function () { | ||
return isElementOverflow(element); | ||
})); | ||
} | ||
function resizeObserverStrategy(target, options) { | ||
if (options === void 0) { options = { box: 'border-box' }; } | ||
export function dimensionsChanges(target) { | ||
return resizeObserverStrategy(target).pipe(auditTime(150)); | ||
} | ||
function resizeObserverStrategy(target) { | ||
return new Observable(function (subscriber) { | ||
var observer = new ResizeObserver(function (_a) { | ||
var _b = __read(_a, 1), entry = _b[0]; | ||
// Currently, only Firefox supports `borderBoxSize` property which | ||
// gives the border-box value include padding and border | ||
if (entry.borderBoxSize) { | ||
subscriber.next({ | ||
width: entry.borderBoxSize.inlineSize, | ||
height: entry.borderBoxSize.blockSize | ||
}); | ||
} | ||
else { | ||
subscriber.next({ | ||
width: entry.target.offsetWidth, | ||
height: entry.target.offsetHeight | ||
}); | ||
} | ||
}); | ||
observer.observe(target, options); | ||
if (!supportsResizeObserver) { | ||
subscriber.next(); | ||
subscriber.complete(); | ||
return; | ||
} | ||
var observer = new ResizeObserver(function () { return subscriber.next(true); }); | ||
observer.observe(target); | ||
return function () { return observer.disconnect(); }; | ||
}); | ||
} | ||
export function coerceElement(elementOrRef) { | ||
return elementOrRef instanceof ElementRef ? elementOrRef.nativeElement : elementOrRef; | ||
} | ||
export function isString(value) { | ||
return typeof value === 'string'; | ||
} | ||
export function addClass(element, className) { | ||
if (Array.isArray(className)) { | ||
className.forEach(function (name) { return element.classList.add(name); }); | ||
} | ||
else { | ||
element.classList.add(className); | ||
} | ||
} | ||
export function addStyle(element, prop, value) { | ||
element.style[prop] = value; | ||
} | ||
export function createElement(tagName) { | ||
return document.createElement(tagName); | ||
} | ||
export function closest(element, selector) { | ||
if (window['Element'] && !Element.prototype.closest) { | ||
Element.prototype.closest = function (s) { | ||
var matches = (this.document || this.ownerDocument).querySelectorAll(s), i, el = this; | ||
do { | ||
i = matches.length; | ||
while (--i >= 0 && matches.item(i) !== el) { } | ||
} while (i < 0 && (el = el.parentElement)); | ||
return el; | ||
}; | ||
} | ||
return element.closest(selector); | ||
} | ||
var TemplatePortal = /** @class */ (function () { | ||
function TemplatePortal(tpl) { | ||
var _a; | ||
this.wrapper = null; | ||
this.viewRef = tpl.createEmbeddedView({}); | ||
this.viewRef.detectChanges(); | ||
if (this.viewRef.rootNodes.length === 1) { | ||
this.elementRef = this.viewRef.rootNodes[0]; | ||
} | ||
else { | ||
this.wrapper = document.createElement('div'); | ||
// The `node` might be an instance of the `Comment` class, | ||
// which is an `ng-container` element. We shouldn't filter it | ||
// out since there can be `ngIf` or any other directive bound | ||
// to the `ng-container`. | ||
(_a = this.wrapper).append.apply(_a, __spread(this.viewRef.rootNodes)); | ||
this.elementRef = this.wrapper; | ||
} | ||
} | ||
TemplatePortal.prototype.destroy = function () { | ||
if (this.wrapper !== null) { | ||
this.wrapper.parentNode.removeChild(this.wrapper); | ||
this.wrapper = null; | ||
} | ||
this.viewRef.destroy(); | ||
}; | ||
return TemplatePortal; | ||
}()); | ||
export { TemplatePortal }; | ||
function last(arr) { | ||
return arr[arr.length - 1]; | ||
} | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuanMiLCJzb3VyY2VSb290Ijoibmc6Ly9AbmduZWF0L2hlbGlwb3BwZXIvIiwic291cmNlcyI6WyJsaWIvdXRpbHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLE9BQU8sRUFBRSxTQUFTLEVBQUUsVUFBVSxFQUFFLE1BQU0sTUFBTSxDQUFDO0FBQzdDLE9BQU8sRUFBRSxTQUFTLEVBQUUsb0JBQW9CLEVBQUUsR0FBRyxFQUFFLE1BQU0sZ0JBQWdCLENBQUM7QUFDdEUsT0FBTyxFQUFFLFVBQVUsRUFBZ0MsTUFBTSxlQUFlLENBQUM7QUFFekUsSUFBSSw0QkFBNEIsR0FBRyxLQUFLLEVBQ3RDLHNCQUFzQixHQUFHLEtBQUssQ0FBQztBQUNqQyxJQUFJLE9BQU8sTUFBTSxLQUFLLFdBQVcsRUFBRTtJQUNqQyw0QkFBNEIsR0FBRyxzQkFBc0IsSUFBSSxNQUFNLENBQUM7SUFDaEUsc0JBQXNCLEdBQUcsZ0JBQWdCLElBQUksTUFBTSxDQUFDO0NBQ3JEO0FBRUQsTUFBTSxVQUFVLE1BQU0sQ0FDcEIsT0FBb0IsRUFDcEIsT0FHQztJQUhELHdCQUFBLEVBQUE7UUFDRSxJQUFJLEVBQUUsSUFBSTtRQUNWLFNBQVMsRUFBRSxHQUFHO0tBQ2Y7SUFFRCxPQUFPLElBQUksVUFBVSxDQUFDLFVBQUEsVUFB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RpbWVuc2lvbnNDaGFuZ2VzKGVsZW1lbnQpLnBpcGUoXG4gICAgbWFwKCgpID0+IHtcbiAgICAgIHJldHVybiBpc0VsZW1lbnRPdmVyZmxvdyhlbGVtZW50KTtcbiAgICB9KVxuICApO1xufVxuXG5leHBvcnQgZnVuY3Rpb24gZGltZW5zaW9uc0NoYW5nZXModGFyZ2V0OiBIVE1MRWxlbWVudCkge1xuICByZXR1cm4gcmVzaXplT2JzZXJ2ZXJTdHJhdGVneSh0YXJnZXQpLnBpcGUoYXVkaXRUaW1lKDE1MCkpO1xufVxuXG5mdW5jdGlvbiByZXNpemVPYnNlcnZlclN0cmF0ZWd5KHRhcmdldDogSFRNTEVsZW1lbnQpOiBPYnNlcnZhYmxlPGJvb2xlYW4+IHtcbiAgcmV0dXJuIG5ldyBPYnNlcnZhYmxlKHN1YnNjcmliZXIgPT4ge1xuICAgIGlmICghc3VwcG9ydHNSZXNpemVPYnNlcnZlcikge1xuICAgICAgc3Vic2NyaWJlci5uZXh0KCk7XG4gICAgICBzdWJzY3JpYmVyLmNvbXBsZXRlKCk7XG4gICAgICByZXR1cm47XG4gICAgfVxuXG4gICAgY29uc3Qgb2JzZXJ2ZXIgPSBuZXcgUmVzaXplT2JzZXJ2ZXIoKCkgPT4gc3Vic2NyaWJlci5uZXh0KHRydWUpKTtcblxuICAgIG9ic2VydmVyLm9ic2VydmUodGFyZ2V0KTtcblxuICAgIHJldHVybiAoKSA9PiBvYnNlcnZlci5kaXNjb25uZWN0KCk7XG4gIH0pO1xufVxuIl19 |
@@ -5,4 +5,4 @@ /** | ||
export * from './public-api'; | ||
export { INITIAL_HELIPOPPER_OPTIONS as ɵc } from './lib/helipopper-options'; | ||
export { HELIPOPPER_CONFIG as ɵb } from './lib/helipopper.types'; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmduZWF0LWhlbGlwb3BwZXIuanMiLCJzb3VyY2VSb290Ijoibmc6Ly9AbmduZWF0L2hlbGlwb3BwZXIvIiwic291cmNlcyI6WyJuZ25lYXQtaGVsaXBvcHBlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7R0FFRztBQUVILGNBQWMsY0FBYyxDQUFDO0FBRTdCLE9BQU8sRUFBQywwQkFBMEIsSUFBSSxFQUFFLEVBQWdDLE1BQU0sMEJBQTBCLENBQUM7QUFDekcsT0FBTyxFQUFDLGlCQUFpQixJQUFJLEVBQUUsRUFBd0IsTUFBTSx3QkFBd0IsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogR2VuZXJhdGVkIGJ1bmRsZSBpbmRleC4gRG8gbm90IGVkaXQuXG4gKi9cblxuZXhwb3J0ICogZnJvbSAnLi9wdWJsaWMtYXBpJztcblxuZXhwb3J0IHtJTklUSUFMX0hFTElQT1BQRVJfT1BUSU9OUyBhcyDJtWMsUGFydGlhbEhlbGlwb3BwZXJPcHRpb25zIGFzIMm1ZH0gZnJvbSAnLi9saWIvaGVsaXBvcHBlci1vcHRpb25zJztcbmV4cG9ydCB7SEVMSVBPUFBFUl9DT05GSUcgYXMgybViLEhlbGlwb3BwZXJDb25maWcgYXMgybVhfSBmcm9tICcuL2xpYi9oZWxpcG9wcGVyLnR5cGVzJzsiXX0= | ||
export { TippyDirective as ɵc } from './lib/tippy.directive'; | ||
export { TIPPY_CONFIG as ɵa } from './lib/tippy.types'; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmduZWF0LWhlbGlwb3BwZXIuanMiLCJzb3VyY2VSb290Ijoibmc6Ly9AbmduZWF0L2hlbGlwb3BwZXIvIiwic291cmNlcyI6WyJuZ25lYXQtaGVsaXBvcHBlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7R0FFRztBQUVILGNBQWMsY0FBYyxDQUFDO0FBRTdCLE9BQU8sRUFBQyxjQUFjLElBQUksRUFBRSxFQUFDLE1BQU0sdUJBQXVCLENBQUM7QUFDM0QsT0FBTyxFQUFDLFlBQVksSUFBSSxFQUFFLEVBQW1CLE1BQU0sbUJBQW1CLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIEdlbmVyYXRlZCBidW5kbGUgaW5kZXguIERvIG5vdCBlZGl0LlxuICovXG5cbmV4cG9ydCAqIGZyb20gJy4vcHVibGljLWFwaSc7XG5cbmV4cG9ydCB7VGlwcHlEaXJlY3RpdmUgYXMgybVjfSBmcm9tICcuL2xpYi90aXBweS5kaXJlY3RpdmUnO1xuZXhwb3J0IHtUSVBQWV9DT05GSUcgYXMgybVhLFRpcHB5Q29uZmlnIGFzIMm1Yn0gZnJvbSAnLi9saWIvdGlwcHkudHlwZXMnOyJdfQ== |
@@ -1,4 +0,6 @@ | ||
export * from './lib/helipopper.module'; | ||
export * from './lib/helipopper.directive'; | ||
export * from './lib/helipopper.service'; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljLWFwaS5qcyIsInNvdXJjZVJvb3QiOiJuZzovL0BuZ25lYXQvaGVsaXBvcHBlci8iLCJzb3VyY2VzIjpbInB1YmxpYy1hcGkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsY0FBYyx5QkFBeUIsQ0FBQztBQUN4QyxjQUFjLDRCQUE0QixDQUFDO0FBQzNDLGNBQWMsMEJBQTBCLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgKiBmcm9tICcuL2xpYi9oZWxpcG9wcGVyLm1vZHVsZSc7XG5leHBvcnQgKiBmcm9tICcuL2xpYi9oZWxpcG9wcGVyLmRpcmVjdGl2ZSc7XG5leHBvcnQgKiBmcm9tICcuL2xpYi9oZWxpcG9wcGVyLnNlcnZpY2UnO1xuIl19 | ||
export { TippyModule } from "./lib/tippy.module"; | ||
export { tooltipVariation, popperVariation, withContextMenuVariation } from "./lib/defaults"; | ||
export { TippyService } from "./lib/tippy.service"; | ||
export { inView, overflowChanges } from "./lib/utils"; | ||
export { TIPPY_REF } from "./lib/tippy.types"; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljLWFwaS5qcyIsInNvdXJjZVJvb3QiOiJuZzovL0BuZ25lYXQvaGVsaXBvcHBlci8iLCJzb3VyY2VzIjpbInB1YmxpYy1hcGkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFdBQVcsRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBQ2pELE9BQU8sRUFBRSxnQkFBZ0IsRUFBRSxlQUFlLEVBQUUsd0JBQXdCLEVBQUUsTUFBTSxnQkFBZ0IsQ0FBQztBQUM3RixPQUFPLEVBQUUsWUFBWSxFQUFFLE1BQU0scUJBQXFCLENBQUM7QUFDbkQsT0FBTyxFQUFFLE1BQU0sRUFBRSxlQUFlLEVBQUUsTUFBTSxhQUFhLENBQUM7QUFDdEQsT0FBTyxFQUFpQixTQUFTLEVBQUUsTUFBTSxtQkFBbUIsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCB7IFRpcHB5TW9kdWxlIH0gZnJvbSBcIi4vbGliL3RpcHB5Lm1vZHVsZVwiO1xuZXhwb3J0IHsgdG9vbHRpcFZhcmlhdGlvbiwgcG9wcGVyVmFyaWF0aW9uLCB3aXRoQ29udGV4dE1lbnVWYXJpYXRpb24gfSBmcm9tIFwiLi9saWIvZGVmYXVsdHNcIjtcbmV4cG9ydCB7IFRpcHB5U2VydmljZSB9IGZyb20gXCIuL2xpYi90aXBweS5zZXJ2aWNlXCI7XG5leHBvcnQgeyBpblZpZXcsIG92ZXJmbG93Q2hhbmdlcyB9IGZyb20gXCIuL2xpYi91dGlsc1wiO1xuZXhwb3J0IHsgVGlwcHlJbnN0YW5jZSwgVElQUFlfUkVGIH0gZnJvbSBcIi4vbGliL3RpcHB5LnR5cGVzXCI7XG4iXX0= |
import { __decorate, __param } from 'tslib'; | ||
import { ElementRef, InjectionToken, inject, TemplateRef, ApplicationRef, NgZone, ComponentFactoryResolver, Injector, Inject, PLATFORM_ID, Input, Output, Directive, NgModule, ɵɵdefineInjectable, ɵɵinject, INJECTOR, Injectable } from '@angular/core'; | ||
import { DOCUMENT, isPlatformServer } from '@angular/common'; | ||
import { InjectionToken, ElementRef, EventEmitter, Injector, Inject, PLATFORM_ID, ViewContainerRef, NgZone, Input, Output, Directive, NgModule, ɵɵdefineInjectable, ɵɵinject, INJECTOR, Injectable } from '@angular/core'; | ||
import tippy from 'tippy.js'; | ||
import { Observable, fromEvent, Subject } from 'rxjs'; | ||
import { auditTime, map, distinctUntilChanged, takeUntil } from 'rxjs/operators'; | ||
import { Observable, Subject, fromEvent } from 'rxjs'; | ||
import { auditTime, map, switchMap, takeUntil } from 'rxjs/operators'; | ||
import { isString, isComponent, isTemplateRef, ViewService } from '@ngneat/overview'; | ||
import { isPlatformServer } from '@angular/common'; | ||
let supportsIntersectionObserver = false, supportsResizeObserver = false; | ||
const TIPPY_CONFIG = new InjectionToken("Tippy config", { | ||
providedIn: "root", | ||
factory() { | ||
return {}; | ||
} | ||
}); | ||
const TIPPY_REF = new InjectionToken("TIPPY_REF"); | ||
function coerceElement(element) { | ||
return element instanceof ElementRef ? element.nativeElement : element; | ||
} | ||
let supportsIntersectionObserver = false; | ||
let supportsResizeObserver = false; | ||
if (typeof window !== 'undefined') { | ||
@@ -13,6 +26,7 @@ supportsIntersectionObserver = 'IntersectionObserver' in window; | ||
} | ||
function inView(element, options = { | ||
function inView(host, options = { | ||
root: null, | ||
threshold: 0.3 | ||
}) { | ||
const element = coerceElement(host); | ||
return new Observable(subscriber => { | ||
@@ -22,4 +36,2 @@ if (!supportsIntersectionObserver) { | ||
subscriber.complete(); | ||
// If the browser doesn't support the `IntersectionObserver` then | ||
// we "return" since it will throw `IntersectionObserver is not defined`. | ||
return; | ||
@@ -29,3 +41,3 @@ } | ||
// Several changes may occur in the same tick, we want to check the latest entry state. | ||
const entry = last(entries); | ||
const entry = entries[entries.length - 1]; | ||
if (entry.isIntersecting) { | ||
@@ -40,460 +52,333 @@ subscriber.next(); | ||
} | ||
const AUDIT_TIME = 150; | ||
function dimensionsChanges(target, options) { | ||
return supportsResizeObserver | ||
? resizeObserverStrategy(target, options).pipe(auditTime(AUDIT_TIME)) | ||
: resizeWindowStrategy(target); | ||
function isElementOverflow(host) { | ||
const parentEl = host.parentElement; | ||
const parentTest = host.offsetWidth > parentEl.offsetWidth; | ||
const elementTest = host.offsetWidth < host.scrollWidth; | ||
return parentTest || elementTest; | ||
} | ||
function resizeWindowStrategy(target) { | ||
return fromEvent(window, 'resize').pipe(auditTime(AUDIT_TIME), map(() => ({ | ||
width: target.offsetWidth, | ||
height: target.offsetHeight | ||
})), distinctUntilChanged((prev, current) => { | ||
return prev.width === current.width && prev.height === current.height; | ||
function overflowChanges(host) { | ||
const element = coerceElement(host); | ||
return dimensionsChanges(element).pipe(map(() => { | ||
return isElementOverflow(element); | ||
})); | ||
} | ||
function resizeObserverStrategy(target, options = { box: 'border-box' }) { | ||
function dimensionsChanges(target) { | ||
return resizeObserverStrategy(target).pipe(auditTime(150)); | ||
} | ||
function resizeObserverStrategy(target) { | ||
return new Observable(subscriber => { | ||
const observer = new ResizeObserver(([entry]) => { | ||
// Currently, only Firefox supports `borderBoxSize` property which | ||
// gives the border-box value include padding and border | ||
if (entry.borderBoxSize) { | ||
subscriber.next({ | ||
width: entry.borderBoxSize.inlineSize, | ||
height: entry.borderBoxSize.blockSize | ||
}); | ||
} | ||
else { | ||
subscriber.next({ | ||
width: entry.target.offsetWidth, | ||
height: entry.target.offsetHeight | ||
}); | ||
} | ||
}); | ||
observer.observe(target, options); | ||
if (!supportsResizeObserver) { | ||
subscriber.next(); | ||
subscriber.complete(); | ||
return; | ||
} | ||
const observer = new ResizeObserver(() => subscriber.next(true)); | ||
observer.observe(target); | ||
return () => observer.disconnect(); | ||
}); | ||
} | ||
function coerceElement(elementOrRef) { | ||
return elementOrRef instanceof ElementRef ? elementOrRef.nativeElement : elementOrRef; | ||
} | ||
function isString(value) { | ||
return typeof value === 'string'; | ||
} | ||
function addClass(element, className) { | ||
if (Array.isArray(className)) { | ||
className.forEach(name => element.classList.add(name)); | ||
} | ||
else { | ||
element.classList.add(className); | ||
} | ||
} | ||
function addStyle(element, prop, value) { | ||
element.style[prop] = value; | ||
} | ||
function createElement(tagName) { | ||
return document.createElement(tagName); | ||
} | ||
function closest(element, selector) { | ||
if (window['Element'] && !Element.prototype.closest) { | ||
Element.prototype.closest = function (s) { | ||
let matches = (this.document || this.ownerDocument).querySelectorAll(s), i, el = this; | ||
do { | ||
i = matches.length; | ||
while (--i >= 0 && matches.item(i) !== el) { } | ||
} while (i < 0 && (el = el.parentElement)); | ||
return el; | ||
}; | ||
} | ||
return element.closest(selector); | ||
} | ||
class TemplatePortal { | ||
constructor(tpl) { | ||
this.wrapper = null; | ||
this.viewRef = tpl.createEmbeddedView({}); | ||
this.viewRef.detectChanges(); | ||
if (this.viewRef.rootNodes.length === 1) { | ||
this.elementRef = this.viewRef.rootNodes[0]; | ||
} | ||
else { | ||
this.wrapper = document.createElement('div'); | ||
// The `node` might be an instance of the `Comment` class, | ||
// which is an `ng-container` element. We shouldn't filter it | ||
// out since there can be `ngIf` or any other directive bound | ||
// to the `ng-container`. | ||
this.wrapper.append(...this.viewRef.rootNodes); | ||
this.elementRef = this.wrapper; | ||
} | ||
} | ||
destroy() { | ||
if (this.wrapper !== null) { | ||
this.wrapper.parentNode.removeChild(this.wrapper); | ||
this.wrapper = null; | ||
} | ||
this.viewRef.destroy(); | ||
} | ||
} | ||
function last(arr) { | ||
return arr[arr.length - 1]; | ||
} | ||
const HELIPOPPER_CONFIG = new InjectionToken('HELIPOPPER_CONFIG'); | ||
const INITIAL_HELIPOPPER_OPTIONS = new InjectionToken('InitialHelipopperOptions', { | ||
providedIn: 'root', | ||
factory: () => { | ||
const document = inject(DOCUMENT); | ||
// The code actually shouldn't be executed on the server-side, | ||
// but these options are "statically" initialized, thus Universal | ||
// will throw an error "document is not defined". | ||
return { | ||
options: {}, | ||
textOverflow: false, | ||
appendTo: document.body, | ||
placement: 'top', | ||
variation: 'tooltip', | ||
disabled: false, | ||
allowClose: true | ||
}; | ||
} | ||
}); | ||
const icon = ` | ||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 24 24" fit="" preserveAspectRatio="xMidYMid meet" focusable="false"> | ||
<path d="M12.793 12l4.039-4.025c0.219-0.219 0.224-0.578 0.012-0.802-0.213-0.225-0.563-0.231-0.782-0.011l-4.062 4.049-4.062-4.049c-0.219-0.22-0.569-0.213-0.782 0.011s-0.208 0.583 0.012 0.802l4.039 4.025-4.039 4.025c-0.22 0.219-0.224 0.578-0.012 0.802 0.108 0.115 0.252 0.172 0.397 0.172 0.138 0 0.278-0.053 0.385-0.161l4.062-4.049 4.062 4.049c0.107 0.108 0.245 0.161 0.385 0.161 0.144 0 0.287-0.058 0.397-0.172 0.212-0.225 0.207-0.583-0.012-0.802l-4.039-4.025z"></path> | ||
</svg> | ||
`; | ||
let HelipopperDirective = class HelipopperDirective { | ||
constructor(host, appRef, zone, resolver, hostInjector, platformId, config, initialOptions) { | ||
let TippyDirective = class TippyDirective { | ||
constructor(platformId, globalConfig, injector, viewService, vcr, zone, host) { | ||
this.platformId = platformId; | ||
this.globalConfig = globalConfig; | ||
this.injector = injector; | ||
this.viewService = viewService; | ||
this.vcr = vcr; | ||
this.zone = zone; | ||
this.host = host; | ||
this.appRef = appRef; | ||
this.zone = zone; | ||
this.resolver = resolver; | ||
this.hostInjector = hostInjector; | ||
this.platformId = platformId; | ||
this.initialOptions = initialOptions; | ||
this.helipopperOptions = this.initialOptions.options; | ||
this.showOnlyOnTextOverflow = this.initialOptions.textOverflow; | ||
this.helipopperAppendTo = this.initialOptions.appendTo; | ||
this.helipopperUseHostWidth = false; | ||
this.helipopperAllowClose = this.initialOptions.allowClose; | ||
this.helipopperClose = new Subject(); | ||
this.helipopperVisible = new Subject(); | ||
this._destroy = new Subject(); | ||
this._placement = this.initialOptions.placement; | ||
this._disabled = false; | ||
this._variation = this.initialOptions.variation; | ||
this.whenStable = new Subject(); | ||
this.onlyTextOverflow = false; | ||
this.useHostWidth = false; | ||
this.visible = new EventEmitter(); | ||
this.isVisible = false; | ||
this.mergedConfig = this.createConfig(config); | ||
this.destroyed = new Subject(); | ||
this.enabled = true; | ||
this.variationDefined = false; | ||
} | ||
set placement(placement) { | ||
this._placement = placement; | ||
this.setProps({ placement }); | ||
} | ||
set variation(variation) { | ||
this._variation = variation; | ||
this.setProps(this.resolveTheme()); | ||
} | ||
set disabled(disabled) { | ||
this._disabled = disabled; | ||
this.markDisabled(this._disabled); | ||
} | ||
set sticky(isSticky) { | ||
if (!this.instance) { | ||
ngOnChanges(changes) { | ||
if (isPlatformServer(this.platformId)) | ||
return; | ||
if (changes.content) { | ||
this.view = changes.content.currentValue; | ||
} | ||
if (isSticky) { | ||
this.setProps({ trigger: 'manual', hideOnClick: false }); | ||
this.show(); | ||
let props = Object.keys(changes).reduce((acc, change) => { | ||
acc[change] = changes[change].currentValue; | ||
return acc; | ||
}, {}); | ||
let variation; | ||
if (isChanged("variation", changes)) { | ||
variation = changes.variation.currentValue; | ||
} | ||
else { | ||
this.hide(); | ||
this.setProps({ trigger: this.helipopperTrigger }); | ||
else if (!this.variationDefined) { | ||
variation = this.globalConfig.defaultVariation; | ||
this.variationDefined = true; | ||
} | ||
if (variation) { | ||
props = Object.assign(Object.assign({}, this.globalConfig.variations[variation]), props); | ||
} | ||
if (isChanged("isEnable", changes)) { | ||
this.enabled = changes.isEnable.currentValue; | ||
this.setStatus(); | ||
} | ||
// We don't want to save the content, we control it manually | ||
delete props.content; | ||
this.setProps(props); | ||
} | ||
set helipopper(content) { | ||
// We shouldn't do anything on the server side, | ||
// it will throw `requestAnimationFrame is not defined`, | ||
// we could replace it with `setTimeout` on the server side, | ||
// but `tippy.js` should be initialized only on the client side. | ||
// The `tippy.js` library is browser-compatible only! | ||
// It doesn't have any checks inside like `typeof window !== 'undefined`' | ||
// and should it be called only if the code is executed on the client side. | ||
if (isPlatformServer(this.platformId)) { | ||
return; | ||
ngOnInit() { | ||
if (this.useHostWidth) { | ||
this.props.maxWidth = this.hostWidth; | ||
} | ||
// Clear previously created view | ||
this.destroyView(); | ||
this._content = content; | ||
if (this.instance) { | ||
this.checkOverflow(); | ||
} | ||
ngAfterViewInit() { | ||
if (this.lazy) { | ||
if (this.onlyTextOverflow) { | ||
inView(this.host) | ||
.pipe(switchMap(() => overflowChanges(this.host)), takeUntil(this.destroyed)) | ||
.subscribe(isElementOverflow => { | ||
this.checkOverflow(isElementOverflow); | ||
}); | ||
} | ||
else { | ||
inView(this.host) | ||
.pipe(takeUntil(this.destroyed)) | ||
.subscribe(() => { | ||
this.createInstance(); | ||
}); | ||
} | ||
} | ||
else { | ||
requestAnimationFrame(() => { | ||
inView(this.host.nativeElement) | ||
.pipe(takeUntil(this._destroy)) | ||
.subscribe(() => this.create()); | ||
else if (this.onlyTextOverflow) { | ||
overflowChanges(this.host) | ||
.pipe(takeUntil(this.destroyed)) | ||
.subscribe(isElementOverflow => { | ||
this.checkOverflow(isElementOverflow); | ||
}); | ||
} | ||
else { | ||
this.createInstance(); | ||
} | ||
} | ||
get _tooltipTarget() { | ||
return coerceElement(this.triggerTarget) || this.host.nativeElement; | ||
ngOnDestroy() { | ||
var _a; | ||
this.destroyed.next(); | ||
(_a = this.instance) === null || _a === void 0 ? void 0 : _a.destroy(); | ||
this.destroyView(); | ||
} | ||
get _tooltipHost() { | ||
return coerceElement(this.helipopperHost) || this.host.nativeElement; | ||
destroyView() { | ||
var _a; | ||
(_a = this.viewRef) === null || _a === void 0 ? void 0 : _a.destroy(); | ||
this.viewRef = null; | ||
} | ||
get isTooltip() { | ||
return this._variation === 'tooltip'; | ||
show() { | ||
var _a; | ||
(_a = this.instance) === null || _a === void 0 ? void 0 : _a.show(); | ||
} | ||
get isPopper() { | ||
return this._variation === 'popper'; | ||
hide() { | ||
var _a; | ||
(_a = this.instance) === null || _a === void 0 ? void 0 : _a.hide(); | ||
} | ||
setProps(props) { | ||
this.instance && this.instance.setProps(props); | ||
enable() { | ||
var _a; | ||
(_a = this.instance) === null || _a === void 0 ? void 0 : _a.enable(); | ||
} | ||
hide() { | ||
this.instance.hide(); | ||
disable() { | ||
var _a; | ||
(_a = this.instance) === null || _a === void 0 ? void 0 : _a.disable(); | ||
} | ||
show() { | ||
this.instance.show(); | ||
setProps(props) { | ||
var _a; | ||
this.props = props; | ||
(_a = this.instance) === null || _a === void 0 ? void 0 : _a.setProps(props); | ||
} | ||
ngOnDestroy() { | ||
this.destroyView(); | ||
this.instance && this.instance.destroy(); | ||
this.instance = null; | ||
this._destroy.next(); | ||
setStatus() { | ||
var _a, _b; | ||
this.enabled ? (_a = this.instance) === null || _a === void 0 ? void 0 : _a.enable() : (_b = this.instance) === null || _b === void 0 ? void 0 : _b.disable(); | ||
} | ||
destroy() { | ||
this.ngOnDestroy(); | ||
} | ||
get hostWidth() { | ||
return `${this._tooltipHost.getBoundingClientRect().width}px`; | ||
return `${this.host.nativeElement.getBoundingClientRect().width}px`; | ||
} | ||
destroyView() { | ||
this.tplPortal && this.destroyTemplate(); | ||
this.innerComponentRef && this.destroyComponent(); | ||
} | ||
create() { | ||
this.zone.runOutsideAngular(() => this.createInstance()); | ||
} | ||
createInstance() { | ||
if (this.showOnlyOnTextOverflow) { | ||
dimensionsChanges(this._tooltipHost) | ||
.pipe(takeUntil(this._destroy)) | ||
.subscribe(() => { | ||
this.markDisabled(this.isElementOverflow() === false); | ||
}); | ||
} | ||
this.helipopperTrigger = this.resolveTrigger(); | ||
const maxWidth = this.helipopperUseHostWidth ? this.hostWidth : this.helipopperMaxWidth; | ||
this.instance = tippy(this._tooltipHost, Object.assign(Object.assign({ content: undefined, appendTo: this.getParent(), arrow: !this.isTooltip, allowHTML: true, zIndex: 1000000, trigger: this.helipopperTrigger, placement: this._placement, triggerTarget: this._tooltipTarget, maxWidth, hideOnClick: this.helipopperAllowClose, | ||
// TODO: Merge the following methods with the passed config | ||
onMount: () => { | ||
this.instance = tippy(this.host.nativeElement, Object.assign(Object.assign(Object.assign({ allowHTML: true }, this.globalConfig), this.props), { onMount: instance => { | ||
var _a, _b; | ||
this.isVisible = true; | ||
this.helipopperVisible.next(true); | ||
this.visible.next(true); | ||
(_b = (_a = this.globalConfig).onMount) === null || _b === void 0 ? void 0 : _b.call(_a, instance); | ||
}, onCreate: instance => { | ||
this.helipopperClass && addClass(instance.popper, this.helipopperClass); | ||
this.helipopperUseHostWidth && addStyle(instance.popper, 'width', this.hostWidth); | ||
var _a, _b; | ||
this.className && instance.popper.classList.add(this.className); | ||
if (this.useHostWidth) { | ||
instance.popper.style.width = this.hostWidth; | ||
} | ||
(_b = (_a = this.globalConfig).onCreate) === null || _b === void 0 ? void 0 : _b.call(_a, instance); | ||
}, onShow: instance => { | ||
var _a, _b; | ||
this.zone.run(() => this.instance.setContent(this.resolveContent())); | ||
this.helipopperAllowClose && this.isPopper && this.addCloseButton(instance); | ||
(_b = (_a = this.globalConfig).onShow) === null || _b === void 0 ? void 0 : _b.call(_a, instance); | ||
}, onHidden: instance => { | ||
this.helipopperAllowClose && this.isPopper && this.removeCloseButton(instance); | ||
var _a, _b; | ||
this.destroyView(); | ||
this.isVisible = false; | ||
this.helipopperClose.next(); | ||
this.helipopperVisible.next(false); | ||
} }, this.resolveTheme()), this.helipopperOptions)); | ||
this.whenStable.next(true); | ||
this.markDisabled(this._disabled); | ||
this.visible.next(false); | ||
(_b = (_a = this.globalConfig).onHidden) === null || _b === void 0 ? void 0 : _b.call(_a, instance); | ||
} })); | ||
this.setStatus(); | ||
this.setProps(this.props); | ||
this.variation === "contextMenu" && this.handleContextMenu(); | ||
} | ||
resolveTrigger() { | ||
return this.helipopperTrigger || (this.isTooltip ? 'mouseenter' : 'click'); | ||
} | ||
resolveTemplate(content) { | ||
if (this.tplPortal) { | ||
this.destroyTemplate(); | ||
resolveContent() { | ||
if (!this.viewOptions$ && !isString(this.content)) { | ||
if (isComponent(this.content)) { | ||
this.viewOptions$ = { | ||
injector: Injector.create({ | ||
providers: [{ provide: TIPPY_REF, useValue: this.instance }], | ||
parent: this.injector | ||
}) | ||
}; | ||
} | ||
else if (isTemplateRef(this.content)) { | ||
this.viewOptions$ = { | ||
context: { | ||
$implicit: this.hide.bind(this), | ||
data: this.data | ||
} | ||
}; | ||
} | ||
} | ||
this.tplPortal = new TemplatePortal(content); | ||
this.appRef.attachView(this.tplPortal.viewRef); | ||
return this.tplPortal.elementRef; | ||
} | ||
isElementOverflow() { | ||
const element = this._tooltipTarget; | ||
const parentEl = element.parentElement; | ||
const parentTest = element.offsetWidth > parentEl.offsetWidth; | ||
const elementTest = element.offsetWidth < element.scrollWidth; | ||
return parentTest || elementTest; | ||
} | ||
getParent() { | ||
let containerElement; | ||
if (isString(this.helipopperAppendTo)) { | ||
containerElement = closest(this.host.nativeElement, this.helipopperAppendTo); | ||
this.viewRef = this.viewService.createView(this.content, Object.assign({ vcr: this.vcr }, this.viewOptions$)); | ||
let content = this.viewRef.getElement(); | ||
if (isString(content) && this.globalConfig.beforeRender) { | ||
content = this.globalConfig.beforeRender(content); | ||
} | ||
else { | ||
containerElement = this.helipopperAppendTo; | ||
} | ||
return containerElement || document.body; | ||
return content; | ||
} | ||
markDisabled(disabled = true) { | ||
if (this.instance) { | ||
disabled ? this.instance.disable() : this.instance.enable(); | ||
} | ||
handleContextMenu() { | ||
fromEvent(this.host.nativeElement, "contextmenu") | ||
.pipe(takeUntil(this.destroyed)) | ||
.subscribe((event) => { | ||
event.preventDefault(); | ||
this.instance.setProps({ | ||
getReferenceClientRect: () => ({ | ||
width: 0, | ||
height: 0, | ||
top: event.clientY, | ||
bottom: event.clientY, | ||
left: event.clientX, | ||
right: event.clientX | ||
}) | ||
}); | ||
this.instance.show(); | ||
}); | ||
} | ||
resolveTheme() { | ||
return { | ||
offset: this.helipopperOffset || [0, this.isTooltip ? 5 : 10], | ||
theme: this.isTooltip ? null : 'light', | ||
arrow: this.isTooltip === false, | ||
animation: this.isTooltip ? `scale` : null, | ||
interactive: !this.isTooltip | ||
}; | ||
} | ||
addCloseButton(instance) { | ||
const popper = instance.popper; | ||
const closeIcon = this.mergedConfig.closeIcon; | ||
const closeButtonElement = createElement('div'); | ||
addClass(closeButtonElement, 'tippy-close'); | ||
closeButtonElement.innerHTML = closeIcon; | ||
const closeButtonSubscription = fromEvent(closeButtonElement, 'click').subscribe(() => this.hide()); | ||
popper.appendChild(closeButtonElement); | ||
instance.closeButtonElement = closeButtonElement; | ||
instance.closeButtonSubscription = closeButtonSubscription; | ||
} | ||
removeCloseButton(instance) { | ||
instance.popper.removeChild(instance.closeButtonElement); | ||
instance.closeButtonSubscription.unsubscribe(); | ||
instance.closeButtonElement = null; | ||
instance.closeButtonSubscription = null; | ||
} | ||
checkOverflow() { | ||
if (this.showOnlyOnTextOverflow) { | ||
requestAnimationFrame(() => this.markDisabled(this.isElementOverflow() === false)); | ||
} | ||
} | ||
destroyTemplate() { | ||
this.appRef.detachView(this.tplPortal.viewRef); | ||
this.tplPortal.destroy(); | ||
this.tplPortal = null; | ||
} | ||
createConfig(config) { | ||
const defaults = { | ||
closeIcon: icon, | ||
beforeRender(content) { | ||
return content; | ||
checkOverflow(isElementOverflow) { | ||
var _a; | ||
if (isElementOverflow) { | ||
if (!this.instance) { | ||
this.createInstance(); | ||
} | ||
}; | ||
return Object.assign(Object.assign({}, defaults), config); | ||
} | ||
resolveComponent(content) { | ||
const factory = this.resolver.resolveComponentFactory(content); | ||
const injector = this.injector || this.hostInjector; | ||
this.innerComponentRef = factory.create(injector); | ||
this.appRef.attachView(this.innerComponentRef.hostView); | ||
this.innerComponentRef.hostView.detectChanges(); | ||
return this.innerComponentRef.location.nativeElement; | ||
} | ||
destroyComponent() { | ||
this.innerComponentRef.destroy(); | ||
this.appRef.detachView(this.innerComponentRef.hostView); | ||
this.innerComponentRef = null; | ||
} | ||
resolveContent() { | ||
const content = this._content; | ||
let finalContent; | ||
if (content instanceof TemplateRef) { | ||
finalContent = this.resolveTemplate(content); | ||
else { | ||
this.instance.enable(); | ||
} | ||
} | ||
else if (typeof content === 'string') { | ||
finalContent = this.mergedConfig.beforeRender(content); | ||
} | ||
else { | ||
finalContent = this.resolveComponent(content); | ||
(_a = this.instance) === null || _a === void 0 ? void 0 : _a.disable(); | ||
} | ||
return finalContent; | ||
} | ||
}; | ||
HelipopperDirective.ctorParameters = () => [ | ||
{ type: ElementRef }, | ||
{ type: ApplicationRef }, | ||
TippyDirective.ctorParameters = () => [ | ||
{ type: String, decorators: [{ type: Inject, args: [PLATFORM_ID,] }] }, | ||
{ type: undefined, decorators: [{ type: Inject, args: [TIPPY_CONFIG,] }] }, | ||
{ type: Injector }, | ||
{ type: ViewService }, | ||
{ type: ViewContainerRef }, | ||
{ type: NgZone }, | ||
{ type: ComponentFactoryResolver }, | ||
{ type: Injector }, | ||
{ type: String, decorators: [{ type: Inject, args: [PLATFORM_ID,] }] }, | ||
{ type: undefined, decorators: [{ type: Inject, args: [HELIPOPPER_CONFIG,] }] }, | ||
{ type: undefined, decorators: [{ type: Inject, args: [INITIAL_HELIPOPPER_OPTIONS,] }] } | ||
{ type: ElementRef } | ||
]; | ||
__decorate([ | ||
Input() | ||
], HelipopperDirective.prototype, "helipopperOptions", void 0); | ||
], TippyDirective.prototype, "appendTo", void 0); | ||
__decorate([ | ||
Input('helipopperTextOverflow') | ||
], HelipopperDirective.prototype, "showOnlyOnTextOverflow", void 0); | ||
Input() | ||
], TippyDirective.prototype, "delay", void 0); | ||
__decorate([ | ||
Input() | ||
], HelipopperDirective.prototype, "triggerTarget", void 0); | ||
], TippyDirective.prototype, "duration", void 0); | ||
__decorate([ | ||
Input() | ||
], HelipopperDirective.prototype, "helipopperHost", void 0); | ||
], TippyDirective.prototype, "hideOnClick", void 0); | ||
__decorate([ | ||
Input() | ||
], HelipopperDirective.prototype, "helipopperAppendTo", void 0); | ||
], TippyDirective.prototype, "interactive", void 0); | ||
__decorate([ | ||
Input() | ||
], HelipopperDirective.prototype, "helipopperTrigger", void 0); | ||
], TippyDirective.prototype, "interactiveBorder", void 0); | ||
__decorate([ | ||
Input() | ||
], HelipopperDirective.prototype, "helipopperMaxWidth", void 0); | ||
], TippyDirective.prototype, "maxWidth", void 0); | ||
__decorate([ | ||
Input() | ||
], HelipopperDirective.prototype, "helipopperUseHostWidth", void 0); | ||
], TippyDirective.prototype, "offset", void 0); | ||
__decorate([ | ||
Input() | ||
], HelipopperDirective.prototype, "helipopperAllowClose", void 0); | ||
], TippyDirective.prototype, "placement", void 0); | ||
__decorate([ | ||
Input() | ||
], HelipopperDirective.prototype, "helipopperClass", void 0); | ||
], TippyDirective.prototype, "popperOptions", void 0); | ||
__decorate([ | ||
Input() | ||
], HelipopperDirective.prototype, "helipopperOffset", void 0); | ||
], TippyDirective.prototype, "showOnCreate", void 0); | ||
__decorate([ | ||
Input('helipopperInjector') | ||
], HelipopperDirective.prototype, "injector", void 0); | ||
Input() | ||
], TippyDirective.prototype, "trigger", void 0); | ||
__decorate([ | ||
Input('helipopperPlacement') | ||
], HelipopperDirective.prototype, "placement", null); | ||
Input() | ||
], TippyDirective.prototype, "triggerTarget", void 0); | ||
__decorate([ | ||
Input('helipopperVariation') | ||
], HelipopperDirective.prototype, "variation", null); | ||
Input() | ||
], TippyDirective.prototype, "zIndex", void 0); | ||
__decorate([ | ||
Input('helipopperDisabled') | ||
], HelipopperDirective.prototype, "disabled", null); | ||
Input() | ||
], TippyDirective.prototype, "lazy", void 0); | ||
__decorate([ | ||
Input('helipopperSticky') | ||
], HelipopperDirective.prototype, "sticky", null); | ||
Input() | ||
], TippyDirective.prototype, "variation", void 0); | ||
__decorate([ | ||
Input() | ||
], HelipopperDirective.prototype, "helipopper", null); | ||
], TippyDirective.prototype, "isEnable", void 0); | ||
__decorate([ | ||
Output() | ||
], HelipopperDirective.prototype, "helipopperClose", void 0); | ||
Input() | ||
], TippyDirective.prototype, "className", void 0); | ||
__decorate([ | ||
Input() | ||
], TippyDirective.prototype, "onlyTextOverflow", void 0); | ||
__decorate([ | ||
Input() | ||
], TippyDirective.prototype, "data", void 0); | ||
__decorate([ | ||
Input() | ||
], TippyDirective.prototype, "useHostWidth", void 0); | ||
__decorate([ | ||
Input("tippy") | ||
], TippyDirective.prototype, "content", void 0); | ||
__decorate([ | ||
Output() | ||
], HelipopperDirective.prototype, "helipopperVisible", void 0); | ||
HelipopperDirective = __decorate([ | ||
Directive({ selector: `[helipopper]`, exportAs: 'helipopper' }), | ||
__param(5, Inject(PLATFORM_ID)), | ||
__param(6, Inject(HELIPOPPER_CONFIG)), | ||
__param(7, Inject(INITIAL_HELIPOPPER_OPTIONS)) | ||
], HelipopperDirective); | ||
], TippyDirective.prototype, "visible", void 0); | ||
TippyDirective = __decorate([ | ||
Directive({ | ||
selector: "[tippy]", | ||
exportAs: "tippy" | ||
}), | ||
__param(0, Inject(PLATFORM_ID)), | ||
__param(1, Inject(TIPPY_CONFIG)) | ||
], TippyDirective); | ||
function isChanged(key, changes) { | ||
return key in changes; | ||
} | ||
var HelipopperModule_1; | ||
let HelipopperModule = HelipopperModule_1 = class HelipopperModule { | ||
var TippyModule_1; | ||
let TippyModule = TippyModule_1 = class TippyModule { | ||
static forRoot(config = {}) { | ||
return { | ||
ngModule: HelipopperModule_1, | ||
ngModule: TippyModule_1, | ||
providers: [ | ||
{ | ||
provide: HELIPOPPER_CONFIG, | ||
provide: TIPPY_CONFIG, | ||
useValue: config | ||
@@ -505,62 +390,81 @@ } | ||
}; | ||
HelipopperModule = HelipopperModule_1 = __decorate([ | ||
TippyModule = TippyModule_1 = __decorate([ | ||
NgModule({ | ||
declarations: [HelipopperDirective], | ||
exports: [HelipopperDirective] | ||
declarations: [TippyDirective], | ||
exports: [TippyDirective] | ||
}) | ||
], HelipopperModule); | ||
], TippyModule); | ||
let HelipopperService = class HelipopperService { | ||
constructor(appRef, zone, resolver, hostInjector, platformId, config, initialOptions) { | ||
this.appRef = appRef; | ||
this.zone = zone; | ||
this.resolver = resolver; | ||
this.hostInjector = hostInjector; | ||
this.platformId = platformId; | ||
this.config = config; | ||
this.initialOptions = initialOptions; | ||
const tooltipVariation = { | ||
theme: null, | ||
arrow: false, | ||
animation: 'scale', | ||
trigger: 'mouseenter', | ||
offset: [0, 5] | ||
}; | ||
const popperVariation = { | ||
theme: 'light', | ||
arrow: true, | ||
offset: [0, 10], | ||
animation: null, | ||
trigger: 'click', | ||
interactive: true | ||
}; | ||
function withContextMenuVariation(baseVariation) { | ||
return Object.assign(Object.assign({}, baseVariation), { placement: 'right-start', trigger: 'manual', arrow: false, offset: [0, 0] }); | ||
} | ||
let TippyService = class TippyService { | ||
constructor(globalConfig, view, injector) { | ||
this.globalConfig = globalConfig; | ||
this.view = view; | ||
this.injector = injector; | ||
} | ||
open(host, helipopper, options) { | ||
let directive = new HelipopperDirective(host, this.appRef, this.zone, this.resolver, this.hostInjector, this.platformId, this.config, this.initialOptions); | ||
directive.helipopper = helipopper; | ||
directive.helipopperOptions = (options === null || options === void 0 ? void 0 : options.options) || this.initialOptions.options; | ||
directive.showOnlyOnTextOverflow = isDefined(options === null || options === void 0 ? void 0 : options.textOverflow) | ||
? options === null || options === void 0 ? void 0 : options.textOverflow : this.initialOptions.textOverflow; | ||
directive.triggerTarget = options === null || options === void 0 ? void 0 : options.triggerTarget; | ||
directive.helipopperAppendTo = (options === null || options === void 0 ? void 0 : options.appendTo) || this.initialOptions.appendTo; | ||
directive.helipopperTrigger = options === null || options === void 0 ? void 0 : options.trigger; | ||
directive.helipopperClass = options === null || options === void 0 ? void 0 : options.class; | ||
directive.helipopperOffset = options === null || options === void 0 ? void 0 : options.offset; | ||
directive.injector = options === null || options === void 0 ? void 0 : options.injector; | ||
directive.placement = (options === null || options === void 0 ? void 0 : options.placement) || this.initialOptions.placement; | ||
directive.variation = (options === null || options === void 0 ? void 0 : options.variation) || this.initialOptions.variation; | ||
directive.disabled = isDefined(options === null || options === void 0 ? void 0 : options.disabled) ? options === null || options === void 0 ? void 0 : options.disabled : this.initialOptions.disabled; | ||
directive.sticky = options === null || options === void 0 ? void 0 : options.sticky; | ||
directive.helipopperAllowClose = isDefined(options === null || options === void 0 ? void 0 : options.allowClose) | ||
? options === null || options === void 0 ? void 0 : options.allowClose : this.initialOptions.allowClose; | ||
directive.whenStable.subscribe(() => directive.show()); | ||
return directive; | ||
create(host, content, options = {}) { | ||
let view; | ||
const config = Object.assign(Object.assign(Object.assign({ $viewOptions: undefined, onShow: instance => { | ||
var _a; | ||
if (!config.$viewOptions) { | ||
config.$viewOptions = {}; | ||
if (isTemplateRef(content)) { | ||
config.$viewOptions.context = { | ||
$implicit: instance.hide.bind(instance) | ||
}; | ||
} | ||
else if (isComponent(content)) { | ||
config.$viewOptions.injector = Injector.create({ | ||
providers: [{ provide: TIPPY_REF, useValue: instance }], | ||
parent: options.injector || this.injector | ||
}); | ||
} | ||
} | ||
view = this.view.createView(content, Object.assign(Object.assign({}, options), config.$viewOptions)); | ||
instance.setContent(view.getElement()); | ||
(_a = options === null || options === void 0 ? void 0 : options.onShow) === null || _a === void 0 ? void 0 : _a.call(options, instance); | ||
}, onHidden: instance => { | ||
var _a; | ||
view.destroy(); | ||
(_a = options === null || options === void 0 ? void 0 : options.onHidden) === null || _a === void 0 ? void 0 : _a.call(options, instance); | ||
view = null; | ||
} }, this.globalConfig), this.globalConfig.variations[options.variation || this.globalConfig.defaultVariation]), options); | ||
const instance = tippy(host, config); | ||
const original = instance.destroy; | ||
instance.destroy = () => { | ||
original.call(tippy); | ||
view === null || view === void 0 ? void 0 : view.destroy(); | ||
view = null; | ||
}; | ||
return instance; | ||
} | ||
}; | ||
HelipopperService.ctorParameters = () => [ | ||
{ type: ApplicationRef }, | ||
{ type: NgZone }, | ||
{ type: ComponentFactoryResolver }, | ||
{ type: Injector }, | ||
{ type: String, decorators: [{ type: Inject, args: [PLATFORM_ID,] }] }, | ||
{ type: undefined, decorators: [{ type: Inject, args: [HELIPOPPER_CONFIG,] }] }, | ||
{ type: undefined, decorators: [{ type: Inject, args: [INITIAL_HELIPOPPER_OPTIONS,] }] } | ||
TippyService.ctorParameters = () => [ | ||
{ type: undefined, decorators: [{ type: Inject, args: [TIPPY_CONFIG,] }] }, | ||
{ type: ViewService }, | ||
{ type: Injector } | ||
]; | ||
HelipopperService.ɵprov = ɵɵdefineInjectable({ factory: function HelipopperService_Factory() { return new HelipopperService(ɵɵinject(ApplicationRef), ɵɵinject(NgZone), ɵɵinject(ComponentFactoryResolver), ɵɵinject(INJECTOR), ɵɵinject(PLATFORM_ID), ɵɵinject(HELIPOPPER_CONFIG), ɵɵinject(INITIAL_HELIPOPPER_OPTIONS)); }, token: HelipopperService, providedIn: "root" }); | ||
HelipopperService = __decorate([ | ||
Injectable({ | ||
providedIn: 'root' | ||
}), | ||
__param(4, Inject(PLATFORM_ID)), | ||
__param(5, Inject(HELIPOPPER_CONFIG)), | ||
__param(6, Inject(INITIAL_HELIPOPPER_OPTIONS)) | ||
], HelipopperService); | ||
function isDefined(value) { | ||
return value !== undefined; | ||
} | ||
TippyService.ɵprov = ɵɵdefineInjectable({ factory: function TippyService_Factory() { return new TippyService(ɵɵinject(TIPPY_CONFIG), ɵɵinject(ViewService), ɵɵinject(INJECTOR)); }, token: TippyService, providedIn: "root" }); | ||
TippyService = __decorate([ | ||
Injectable({ providedIn: 'root' }), | ||
__param(0, Inject(TIPPY_CONFIG)) | ||
], TippyService); | ||
@@ -571,3 +475,3 @@ /** | ||
export { HelipopperDirective, HelipopperModule, HelipopperService, HELIPOPPER_CONFIG as ɵb, INITIAL_HELIPOPPER_OPTIONS as ɵc }; | ||
export { TIPPY_REF, TippyModule, TippyService, inView, overflowChanges, popperVariation, tooltipVariation, withContextMenuVariation, TIPPY_CONFIG as ɵa, TippyDirective as ɵc }; | ||
//# sourceMappingURL=ngneat-helipopper.js.map |
@@ -1,9 +0,22 @@ | ||
import { __read, __spread, __assign, __decorate, __param } from 'tslib'; | ||
import { ElementRef, InjectionToken, inject, TemplateRef, ApplicationRef, NgZone, ComponentFactoryResolver, Injector, Inject, PLATFORM_ID, Input, Output, Directive, NgModule, ɵɵdefineInjectable, ɵɵinject, INJECTOR, Injectable } from '@angular/core'; | ||
import { DOCUMENT, isPlatformServer } from '@angular/common'; | ||
import { __assign, __decorate, __param } from 'tslib'; | ||
import { InjectionToken, ElementRef, EventEmitter, Injector, Inject, PLATFORM_ID, ViewContainerRef, NgZone, Input, Output, Directive, NgModule, ɵɵdefineInjectable, ɵɵinject, INJECTOR, Injectable } from '@angular/core'; | ||
import tippy from 'tippy.js'; | ||
import { Observable, fromEvent, Subject } from 'rxjs'; | ||
import { auditTime, map, distinctUntilChanged, takeUntil } from 'rxjs/operators'; | ||
import { Observable, Subject, fromEvent } from 'rxjs'; | ||
import { auditTime, map, switchMap, takeUntil } from 'rxjs/operators'; | ||
import { isString, isComponent, isTemplateRef, ViewService } from '@ngneat/overview'; | ||
import { isPlatformServer } from '@angular/common'; | ||
var supportsIntersectionObserver = false, supportsResizeObserver = false; | ||
var TIPPY_CONFIG = new InjectionToken("Tippy config", { | ||
providedIn: "root", | ||
factory: function () { | ||
return {}; | ||
} | ||
}); | ||
var TIPPY_REF = new InjectionToken("TIPPY_REF"); | ||
function coerceElement(element) { | ||
return element instanceof ElementRef ? element.nativeElement : element; | ||
} | ||
var supportsIntersectionObserver = false; | ||
var supportsResizeObserver = false; | ||
if (typeof window !== 'undefined') { | ||
@@ -13,3 +26,3 @@ supportsIntersectionObserver = 'IntersectionObserver' in window; | ||
} | ||
function inView(element, options) { | ||
function inView(host, options) { | ||
if (options === void 0) { options = { | ||
@@ -19,2 +32,3 @@ root: null, | ||
}; } | ||
var element = coerceElement(host); | ||
return new Observable(function (subscriber) { | ||
@@ -24,4 +38,2 @@ if (!supportsIntersectionObserver) { | ||
subscriber.complete(); | ||
// If the browser doesn't support the `IntersectionObserver` then | ||
// we "return" since it will throw `IntersectionObserver is not defined`. | ||
return; | ||
@@ -31,3 +43,3 @@ } | ||
// Several changes may occur in the same tick, we want to check the latest entry state. | ||
var entry = last(entries); | ||
var entry = entries[entries.length - 1]; | ||
if (entry.isIntersecting) { | ||
@@ -42,271 +54,149 @@ subscriber.next(); | ||
} | ||
var AUDIT_TIME = 150; | ||
function dimensionsChanges(target, options) { | ||
return supportsResizeObserver | ||
? resizeObserverStrategy(target, options).pipe(auditTime(AUDIT_TIME)) | ||
: resizeWindowStrategy(target); | ||
function isElementOverflow(host) { | ||
var parentEl = host.parentElement; | ||
var parentTest = host.offsetWidth > parentEl.offsetWidth; | ||
var elementTest = host.offsetWidth < host.scrollWidth; | ||
return parentTest || elementTest; | ||
} | ||
function resizeWindowStrategy(target) { | ||
return fromEvent(window, 'resize').pipe(auditTime(AUDIT_TIME), map(function () { return ({ | ||
width: target.offsetWidth, | ||
height: target.offsetHeight | ||
}); }), distinctUntilChanged(function (prev, current) { | ||
return prev.width === current.width && prev.height === current.height; | ||
function overflowChanges(host) { | ||
var element = coerceElement(host); | ||
return dimensionsChanges(element).pipe(map(function () { | ||
return isElementOverflow(element); | ||
})); | ||
} | ||
function resizeObserverStrategy(target, options) { | ||
if (options === void 0) { options = { box: 'border-box' }; } | ||
function dimensionsChanges(target) { | ||
return resizeObserverStrategy(target).pipe(auditTime(150)); | ||
} | ||
function resizeObserverStrategy(target) { | ||
return new Observable(function (subscriber) { | ||
var observer = new ResizeObserver(function (_a) { | ||
var _b = __read(_a, 1), entry = _b[0]; | ||
// Currently, only Firefox supports `borderBoxSize` property which | ||
// gives the border-box value include padding and border | ||
if (entry.borderBoxSize) { | ||
subscriber.next({ | ||
width: entry.borderBoxSize.inlineSize, | ||
height: entry.borderBoxSize.blockSize | ||
}); | ||
} | ||
else { | ||
subscriber.next({ | ||
width: entry.target.offsetWidth, | ||
height: entry.target.offsetHeight | ||
}); | ||
} | ||
}); | ||
observer.observe(target, options); | ||
if (!supportsResizeObserver) { | ||
subscriber.next(); | ||
subscriber.complete(); | ||
return; | ||
} | ||
var observer = new ResizeObserver(function () { return subscriber.next(true); }); | ||
observer.observe(target); | ||
return function () { return observer.disconnect(); }; | ||
}); | ||
} | ||
function coerceElement(elementOrRef) { | ||
return elementOrRef instanceof ElementRef ? elementOrRef.nativeElement : elementOrRef; | ||
} | ||
function isString(value) { | ||
return typeof value === 'string'; | ||
} | ||
function addClass(element, className) { | ||
if (Array.isArray(className)) { | ||
className.forEach(function (name) { return element.classList.add(name); }); | ||
var TippyDirective = /** @class */ (function () { | ||
function TippyDirective(platformId, globalConfig, injector, viewService, vcr, zone, host) { | ||
this.platformId = platformId; | ||
this.globalConfig = globalConfig; | ||
this.injector = injector; | ||
this.viewService = viewService; | ||
this.vcr = vcr; | ||
this.zone = zone; | ||
this.host = host; | ||
this.onlyTextOverflow = false; | ||
this.useHostWidth = false; | ||
this.visible = new EventEmitter(); | ||
this.isVisible = false; | ||
this.destroyed = new Subject(); | ||
this.enabled = true; | ||
this.variationDefined = false; | ||
} | ||
else { | ||
element.classList.add(className); | ||
} | ||
} | ||
function addStyle(element, prop, value) { | ||
element.style[prop] = value; | ||
} | ||
function createElement(tagName) { | ||
return document.createElement(tagName); | ||
} | ||
function closest(element, selector) { | ||
if (window['Element'] && !Element.prototype.closest) { | ||
Element.prototype.closest = function (s) { | ||
var matches = (this.document || this.ownerDocument).querySelectorAll(s), i, el = this; | ||
do { | ||
i = matches.length; | ||
while (--i >= 0 && matches.item(i) !== el) { } | ||
} while (i < 0 && (el = el.parentElement)); | ||
return el; | ||
}; | ||
} | ||
return element.closest(selector); | ||
} | ||
var TemplatePortal = /** @class */ (function () { | ||
function TemplatePortal(tpl) { | ||
var _a; | ||
this.wrapper = null; | ||
this.viewRef = tpl.createEmbeddedView({}); | ||
this.viewRef.detectChanges(); | ||
if (this.viewRef.rootNodes.length === 1) { | ||
this.elementRef = this.viewRef.rootNodes[0]; | ||
TippyDirective.prototype.ngOnChanges = function (changes) { | ||
if (isPlatformServer(this.platformId)) | ||
return; | ||
if (changes.content) { | ||
this.view = changes.content.currentValue; | ||
} | ||
else { | ||
this.wrapper = document.createElement('div'); | ||
// The `node` might be an instance of the `Comment` class, | ||
// which is an `ng-container` element. We shouldn't filter it | ||
// out since there can be `ngIf` or any other directive bound | ||
// to the `ng-container`. | ||
(_a = this.wrapper).append.apply(_a, __spread(this.viewRef.rootNodes)); | ||
this.elementRef = this.wrapper; | ||
var props = Object.keys(changes).reduce(function (acc, change) { | ||
acc[change] = changes[change].currentValue; | ||
return acc; | ||
}, {}); | ||
var variation; | ||
if (isChanged("variation", changes)) { | ||
variation = changes.variation.currentValue; | ||
} | ||
} | ||
TemplatePortal.prototype.destroy = function () { | ||
if (this.wrapper !== null) { | ||
this.wrapper.parentNode.removeChild(this.wrapper); | ||
this.wrapper = null; | ||
else if (!this.variationDefined) { | ||
variation = this.globalConfig.defaultVariation; | ||
this.variationDefined = true; | ||
} | ||
this.viewRef.destroy(); | ||
if (variation) { | ||
props = __assign(__assign({}, this.globalConfig.variations[variation]), props); | ||
} | ||
if (isChanged("isEnable", changes)) { | ||
this.enabled = changes.isEnable.currentValue; | ||
this.setStatus(); | ||
} | ||
// We don't want to save the content, we control it manually | ||
delete props.content; | ||
this.setProps(props); | ||
}; | ||
return TemplatePortal; | ||
}()); | ||
function last(arr) { | ||
return arr[arr.length - 1]; | ||
} | ||
var HELIPOPPER_CONFIG = new InjectionToken('HELIPOPPER_CONFIG'); | ||
var INITIAL_HELIPOPPER_OPTIONS = new InjectionToken('InitialHelipopperOptions', { | ||
providedIn: 'root', | ||
factory: function () { | ||
var document = inject(DOCUMENT); | ||
// The code actually shouldn't be executed on the server-side, | ||
// but these options are "statically" initialized, thus Universal | ||
// will throw an error "document is not defined". | ||
return { | ||
options: {}, | ||
textOverflow: false, | ||
appendTo: document.body, | ||
placement: 'top', | ||
variation: 'tooltip', | ||
disabled: false, | ||
allowClose: true | ||
}; | ||
} | ||
}); | ||
var icon = "\n <svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 24 24\" fit=\"\" preserveAspectRatio=\"xMidYMid meet\" focusable=\"false\">\n<path d=\"M12.793 12l4.039-4.025c0.219-0.219 0.224-0.578 0.012-0.802-0.213-0.225-0.563-0.231-0.782-0.011l-4.062 4.049-4.062-4.049c-0.219-0.22-0.569-0.213-0.782 0.011s-0.208 0.583 0.012 0.802l4.039 4.025-4.039 4.025c-0.22 0.219-0.224 0.578-0.012 0.802 0.108 0.115 0.252 0.172 0.397 0.172 0.138 0 0.278-0.053 0.385-0.161l4.062-4.049 4.062 4.049c0.107 0.108 0.245 0.161 0.385 0.161 0.144 0 0.287-0.058 0.397-0.172 0.212-0.225 0.207-0.583-0.012-0.802l-4.039-4.025z\"></path>\n</svg>\n "; | ||
var HelipopperDirective = /** @class */ (function () { | ||
function HelipopperDirective(host, appRef, zone, resolver, hostInjector, platformId, config, initialOptions) { | ||
this.host = host; | ||
this.appRef = appRef; | ||
this.zone = zone; | ||
this.resolver = resolver; | ||
this.hostInjector = hostInjector; | ||
this.platformId = platformId; | ||
this.initialOptions = initialOptions; | ||
this.helipopperOptions = this.initialOptions.options; | ||
this.showOnlyOnTextOverflow = this.initialOptions.textOverflow; | ||
this.helipopperAppendTo = this.initialOptions.appendTo; | ||
this.helipopperUseHostWidth = false; | ||
this.helipopperAllowClose = this.initialOptions.allowClose; | ||
this.helipopperClose = new Subject(); | ||
this.helipopperVisible = new Subject(); | ||
this._destroy = new Subject(); | ||
this._placement = this.initialOptions.placement; | ||
this._disabled = false; | ||
this._variation = this.initialOptions.variation; | ||
this.whenStable = new Subject(); | ||
this.isVisible = false; | ||
this.mergedConfig = this.createConfig(config); | ||
} | ||
Object.defineProperty(HelipopperDirective.prototype, "placement", { | ||
set: function (placement) { | ||
this._placement = placement; | ||
this.setProps({ placement: placement }); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(HelipopperDirective.prototype, "variation", { | ||
set: function (variation) { | ||
this._variation = variation; | ||
this.setProps(this.resolveTheme()); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(HelipopperDirective.prototype, "disabled", { | ||
set: function (disabled) { | ||
this._disabled = disabled; | ||
this.markDisabled(this._disabled); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(HelipopperDirective.prototype, "sticky", { | ||
set: function (isSticky) { | ||
if (!this.instance) { | ||
return; | ||
TippyDirective.prototype.ngOnInit = function () { | ||
if (this.useHostWidth) { | ||
this.props.maxWidth = this.hostWidth; | ||
} | ||
}; | ||
TippyDirective.prototype.ngAfterViewInit = function () { | ||
var _this = this; | ||
if (this.lazy) { | ||
if (this.onlyTextOverflow) { | ||
inView(this.host) | ||
.pipe(switchMap(function () { return overflowChanges(_this.host); }), takeUntil(this.destroyed)) | ||
.subscribe(function (isElementOverflow) { | ||
_this.checkOverflow(isElementOverflow); | ||
}); | ||
} | ||
if (isSticky) { | ||
this.setProps({ trigger: 'manual', hideOnClick: false }); | ||
this.show(); | ||
} | ||
else { | ||
this.hide(); | ||
this.setProps({ trigger: this.helipopperTrigger }); | ||
} | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(HelipopperDirective.prototype, "helipopper", { | ||
set: function (content) { | ||
var _this = this; | ||
// We shouldn't do anything on the server side, | ||
// it will throw `requestAnimationFrame is not defined`, | ||
// we could replace it with `setTimeout` on the server side, | ||
// but `tippy.js` should be initialized only on the client side. | ||
// The `tippy.js` library is browser-compatible only! | ||
// It doesn't have any checks inside like `typeof window !== 'undefined`' | ||
// and should it be called only if the code is executed on the client side. | ||
if (isPlatformServer(this.platformId)) { | ||
return; | ||
} | ||
// Clear previously created view | ||
this.destroyView(); | ||
this._content = content; | ||
if (this.instance) { | ||
this.checkOverflow(); | ||
} | ||
else { | ||
requestAnimationFrame(function () { | ||
inView(_this.host.nativeElement) | ||
.pipe(takeUntil(_this._destroy)) | ||
.subscribe(function () { return _this.create(); }); | ||
inView(this.host) | ||
.pipe(takeUntil(this.destroyed)) | ||
.subscribe(function () { | ||
_this.createInstance(); | ||
}); | ||
} | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(HelipopperDirective.prototype, "_tooltipTarget", { | ||
get: function () { | ||
return coerceElement(this.triggerTarget) || this.host.nativeElement; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(HelipopperDirective.prototype, "_tooltipHost", { | ||
get: function () { | ||
return coerceElement(this.helipopperHost) || this.host.nativeElement; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(HelipopperDirective.prototype, "isTooltip", { | ||
get: function () { | ||
return this._variation === 'tooltip'; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(HelipopperDirective.prototype, "isPopper", { | ||
get: function () { | ||
return this._variation === 'popper'; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
HelipopperDirective.prototype.setProps = function (props) { | ||
this.instance && this.instance.setProps(props); | ||
} | ||
else if (this.onlyTextOverflow) { | ||
overflowChanges(this.host) | ||
.pipe(takeUntil(this.destroyed)) | ||
.subscribe(function (isElementOverflow) { | ||
_this.checkOverflow(isElementOverflow); | ||
}); | ||
} | ||
else { | ||
this.createInstance(); | ||
} | ||
}; | ||
HelipopperDirective.prototype.hide = function () { | ||
this.instance.hide(); | ||
TippyDirective.prototype.ngOnDestroy = function () { | ||
var _a; | ||
this.destroyed.next(); | ||
(_a = this.instance) === null || _a === void 0 ? void 0 : _a.destroy(); | ||
this.destroyView(); | ||
}; | ||
HelipopperDirective.prototype.show = function () { | ||
this.instance.show(); | ||
TippyDirective.prototype.destroyView = function () { | ||
var _a; | ||
(_a = this.viewRef) === null || _a === void 0 ? void 0 : _a.destroy(); | ||
this.viewRef = null; | ||
}; | ||
HelipopperDirective.prototype.ngOnDestroy = function () { | ||
this.destroyView(); | ||
this.instance && this.instance.destroy(); | ||
this.instance = null; | ||
this._destroy.next(); | ||
TippyDirective.prototype.show = function () { | ||
var _a; | ||
(_a = this.instance) === null || _a === void 0 ? void 0 : _a.show(); | ||
}; | ||
HelipopperDirective.prototype.destroy = function () { | ||
this.ngOnDestroy(); | ||
TippyDirective.prototype.hide = function () { | ||
var _a; | ||
(_a = this.instance) === null || _a === void 0 ? void 0 : _a.hide(); | ||
}; | ||
Object.defineProperty(HelipopperDirective.prototype, "hostWidth", { | ||
TippyDirective.prototype.enable = function () { | ||
var _a; | ||
(_a = this.instance) === null || _a === void 0 ? void 0 : _a.enable(); | ||
}; | ||
TippyDirective.prototype.disable = function () { | ||
var _a; | ||
(_a = this.instance) === null || _a === void 0 ? void 0 : _a.disable(); | ||
}; | ||
TippyDirective.prototype.setProps = function (props) { | ||
var _a; | ||
this.props = props; | ||
(_a = this.instance) === null || _a === void 0 ? void 0 : _a.setProps(props); | ||
}; | ||
TippyDirective.prototype.setStatus = function () { | ||
var _a, _b; | ||
this.enabled ? (_a = this.instance) === null || _a === void 0 ? void 0 : _a.enable() : (_b = this.instance) === null || _b === void 0 ? void 0 : _b.disable(); | ||
}; | ||
Object.defineProperty(TippyDirective.prototype, "hostWidth", { | ||
get: function () { | ||
return this._tooltipHost.getBoundingClientRect().width + "px"; | ||
return this.host.nativeElement.getBoundingClientRect().width + "px"; | ||
}, | ||
@@ -316,237 +206,193 @@ enumerable: true, | ||
}); | ||
HelipopperDirective.prototype.destroyView = function () { | ||
this.tplPortal && this.destroyTemplate(); | ||
this.innerComponentRef && this.destroyComponent(); | ||
}; | ||
HelipopperDirective.prototype.create = function () { | ||
TippyDirective.prototype.createInstance = function () { | ||
var _this = this; | ||
this.zone.runOutsideAngular(function () { return _this.createInstance(); }); | ||
}; | ||
HelipopperDirective.prototype.createInstance = function () { | ||
var _this = this; | ||
if (this.showOnlyOnTextOverflow) { | ||
dimensionsChanges(this._tooltipHost) | ||
.pipe(takeUntil(this._destroy)) | ||
.subscribe(function () { | ||
_this.markDisabled(_this.isElementOverflow() === false); | ||
}); | ||
} | ||
this.helipopperTrigger = this.resolveTrigger(); | ||
var maxWidth = this.helipopperUseHostWidth ? this.hostWidth : this.helipopperMaxWidth; | ||
this.instance = tippy(this._tooltipHost, __assign(__assign({ content: undefined, appendTo: this.getParent(), arrow: !this.isTooltip, allowHTML: true, zIndex: 1000000, trigger: this.helipopperTrigger, placement: this._placement, triggerTarget: this._tooltipTarget, maxWidth: maxWidth, hideOnClick: this.helipopperAllowClose, | ||
// TODO: Merge the following methods with the passed config | ||
onMount: function () { | ||
this.instance = tippy(this.host.nativeElement, __assign(__assign(__assign({ allowHTML: true }, this.globalConfig), this.props), { onMount: function (instance) { | ||
var _a, _b; | ||
_this.isVisible = true; | ||
_this.helipopperVisible.next(true); | ||
_this.visible.next(true); | ||
(_b = (_a = _this.globalConfig).onMount) === null || _b === void 0 ? void 0 : _b.call(_a, instance); | ||
}, onCreate: function (instance) { | ||
_this.helipopperClass && addClass(instance.popper, _this.helipopperClass); | ||
_this.helipopperUseHostWidth && addStyle(instance.popper, 'width', _this.hostWidth); | ||
var _a, _b; | ||
_this.className && instance.popper.classList.add(_this.className); | ||
if (_this.useHostWidth) { | ||
instance.popper.style.width = _this.hostWidth; | ||
} | ||
(_b = (_a = _this.globalConfig).onCreate) === null || _b === void 0 ? void 0 : _b.call(_a, instance); | ||
}, onShow: function (instance) { | ||
var _a, _b; | ||
_this.zone.run(function () { return _this.instance.setContent(_this.resolveContent()); }); | ||
_this.helipopperAllowClose && _this.isPopper && _this.addCloseButton(instance); | ||
(_b = (_a = _this.globalConfig).onShow) === null || _b === void 0 ? void 0 : _b.call(_a, instance); | ||
}, onHidden: function (instance) { | ||
_this.helipopperAllowClose && _this.isPopper && _this.removeCloseButton(instance); | ||
var _a, _b; | ||
_this.destroyView(); | ||
_this.isVisible = false; | ||
_this.helipopperClose.next(); | ||
_this.helipopperVisible.next(false); | ||
} }, this.resolveTheme()), this.helipopperOptions)); | ||
this.whenStable.next(true); | ||
this.markDisabled(this._disabled); | ||
_this.visible.next(false); | ||
(_b = (_a = _this.globalConfig).onHidden) === null || _b === void 0 ? void 0 : _b.call(_a, instance); | ||
} })); | ||
this.setStatus(); | ||
this.setProps(this.props); | ||
this.variation === "contextMenu" && this.handleContextMenu(); | ||
}; | ||
HelipopperDirective.prototype.resolveTrigger = function () { | ||
return this.helipopperTrigger || (this.isTooltip ? 'mouseenter' : 'click'); | ||
}; | ||
HelipopperDirective.prototype.resolveTemplate = function (content) { | ||
if (this.tplPortal) { | ||
this.destroyTemplate(); | ||
TippyDirective.prototype.resolveContent = function () { | ||
if (!this.viewOptions$ && !isString(this.content)) { | ||
if (isComponent(this.content)) { | ||
this.viewOptions$ = { | ||
injector: Injector.create({ | ||
providers: [{ provide: TIPPY_REF, useValue: this.instance }], | ||
parent: this.injector | ||
}) | ||
}; | ||
} | ||
else if (isTemplateRef(this.content)) { | ||
this.viewOptions$ = { | ||
context: { | ||
$implicit: this.hide.bind(this), | ||
data: this.data | ||
} | ||
}; | ||
} | ||
} | ||
this.tplPortal = new TemplatePortal(content); | ||
this.appRef.attachView(this.tplPortal.viewRef); | ||
return this.tplPortal.elementRef; | ||
}; | ||
HelipopperDirective.prototype.isElementOverflow = function () { | ||
var element = this._tooltipTarget; | ||
var parentEl = element.parentElement; | ||
var parentTest = element.offsetWidth > parentEl.offsetWidth; | ||
var elementTest = element.offsetWidth < element.scrollWidth; | ||
return parentTest || elementTest; | ||
}; | ||
HelipopperDirective.prototype.getParent = function () { | ||
var containerElement; | ||
if (isString(this.helipopperAppendTo)) { | ||
containerElement = closest(this.host.nativeElement, this.helipopperAppendTo); | ||
this.viewRef = this.viewService.createView(this.content, __assign({ vcr: this.vcr }, this.viewOptions$)); | ||
var content = this.viewRef.getElement(); | ||
if (isString(content) && this.globalConfig.beforeRender) { | ||
content = this.globalConfig.beforeRender(content); | ||
} | ||
else { | ||
containerElement = this.helipopperAppendTo; | ||
} | ||
return containerElement || document.body; | ||
return content; | ||
}; | ||
HelipopperDirective.prototype.markDisabled = function (disabled) { | ||
if (disabled === void 0) { disabled = true; } | ||
if (this.instance) { | ||
disabled ? this.instance.disable() : this.instance.enable(); | ||
} | ||
}; | ||
HelipopperDirective.prototype.resolveTheme = function () { | ||
return { | ||
offset: this.helipopperOffset || [0, this.isTooltip ? 5 : 10], | ||
theme: this.isTooltip ? null : 'light', | ||
arrow: this.isTooltip === false, | ||
animation: this.isTooltip ? "scale" : null, | ||
interactive: !this.isTooltip | ||
}; | ||
}; | ||
HelipopperDirective.prototype.addCloseButton = function (instance) { | ||
TippyDirective.prototype.handleContextMenu = function () { | ||
var _this = this; | ||
var popper = instance.popper; | ||
var closeIcon = this.mergedConfig.closeIcon; | ||
var closeButtonElement = createElement('div'); | ||
addClass(closeButtonElement, 'tippy-close'); | ||
closeButtonElement.innerHTML = closeIcon; | ||
var closeButtonSubscription = fromEvent(closeButtonElement, 'click').subscribe(function () { return _this.hide(); }); | ||
popper.appendChild(closeButtonElement); | ||
instance.closeButtonElement = closeButtonElement; | ||
instance.closeButtonSubscription = closeButtonSubscription; | ||
fromEvent(this.host.nativeElement, "contextmenu") | ||
.pipe(takeUntil(this.destroyed)) | ||
.subscribe(function (event) { | ||
event.preventDefault(); | ||
_this.instance.setProps({ | ||
getReferenceClientRect: function () { return ({ | ||
width: 0, | ||
height: 0, | ||
top: event.clientY, | ||
bottom: event.clientY, | ||
left: event.clientX, | ||
right: event.clientX | ||
}); } | ||
}); | ||
_this.instance.show(); | ||
}); | ||
}; | ||
HelipopperDirective.prototype.removeCloseButton = function (instance) { | ||
instance.popper.removeChild(instance.closeButtonElement); | ||
instance.closeButtonSubscription.unsubscribe(); | ||
instance.closeButtonElement = null; | ||
instance.closeButtonSubscription = null; | ||
}; | ||
HelipopperDirective.prototype.checkOverflow = function () { | ||
var _this = this; | ||
if (this.showOnlyOnTextOverflow) { | ||
requestAnimationFrame(function () { return _this.markDisabled(_this.isElementOverflow() === false); }); | ||
} | ||
}; | ||
HelipopperDirective.prototype.destroyTemplate = function () { | ||
this.appRef.detachView(this.tplPortal.viewRef); | ||
this.tplPortal.destroy(); | ||
this.tplPortal = null; | ||
}; | ||
HelipopperDirective.prototype.createConfig = function (config) { | ||
var defaults = { | ||
closeIcon: icon, | ||
beforeRender: function (content) { | ||
return content; | ||
TippyDirective.prototype.checkOverflow = function (isElementOverflow) { | ||
var _a; | ||
if (isElementOverflow) { | ||
if (!this.instance) { | ||
this.createInstance(); | ||
} | ||
}; | ||
return __assign(__assign({}, defaults), config); | ||
}; | ||
HelipopperDirective.prototype.resolveComponent = function (content) { | ||
var factory = this.resolver.resolveComponentFactory(content); | ||
var injector = this.injector || this.hostInjector; | ||
this.innerComponentRef = factory.create(injector); | ||
this.appRef.attachView(this.innerComponentRef.hostView); | ||
this.innerComponentRef.hostView.detectChanges(); | ||
return this.innerComponentRef.location.nativeElement; | ||
}; | ||
HelipopperDirective.prototype.destroyComponent = function () { | ||
this.innerComponentRef.destroy(); | ||
this.appRef.detachView(this.innerComponentRef.hostView); | ||
this.innerComponentRef = null; | ||
}; | ||
HelipopperDirective.prototype.resolveContent = function () { | ||
var content = this._content; | ||
var finalContent; | ||
if (content instanceof TemplateRef) { | ||
finalContent = this.resolveTemplate(content); | ||
else { | ||
this.instance.enable(); | ||
} | ||
} | ||
else if (typeof content === 'string') { | ||
finalContent = this.mergedConfig.beforeRender(content); | ||
} | ||
else { | ||
finalContent = this.resolveComponent(content); | ||
(_a = this.instance) === null || _a === void 0 ? void 0 : _a.disable(); | ||
} | ||
return finalContent; | ||
}; | ||
HelipopperDirective.ctorParameters = function () { return [ | ||
{ type: ElementRef }, | ||
{ type: ApplicationRef }, | ||
TippyDirective.ctorParameters = function () { return [ | ||
{ type: String, decorators: [{ type: Inject, args: [PLATFORM_ID,] }] }, | ||
{ type: undefined, decorators: [{ type: Inject, args: [TIPPY_CONFIG,] }] }, | ||
{ type: Injector }, | ||
{ type: ViewService }, | ||
{ type: ViewContainerRef }, | ||
{ type: NgZone }, | ||
{ type: ComponentFactoryResolver }, | ||
{ type: Injector }, | ||
{ type: String, decorators: [{ type: Inject, args: [PLATFORM_ID,] }] }, | ||
{ type: undefined, decorators: [{ type: Inject, args: [HELIPOPPER_CONFIG,] }] }, | ||
{ type: undefined, decorators: [{ type: Inject, args: [INITIAL_HELIPOPPER_OPTIONS,] }] } | ||
{ type: ElementRef } | ||
]; }; | ||
__decorate([ | ||
Input() | ||
], HelipopperDirective.prototype, "helipopperOptions", void 0); | ||
], TippyDirective.prototype, "appendTo", void 0); | ||
__decorate([ | ||
Input('helipopperTextOverflow') | ||
], HelipopperDirective.prototype, "showOnlyOnTextOverflow", void 0); | ||
Input() | ||
], TippyDirective.prototype, "delay", void 0); | ||
__decorate([ | ||
Input() | ||
], HelipopperDirective.prototype, "triggerTarget", void 0); | ||
], TippyDirective.prototype, "duration", void 0); | ||
__decorate([ | ||
Input() | ||
], HelipopperDirective.prototype, "helipopperHost", void 0); | ||
], TippyDirective.prototype, "hideOnClick", void 0); | ||
__decorate([ | ||
Input() | ||
], HelipopperDirective.prototype, "helipopperAppendTo", void 0); | ||
], TippyDirective.prototype, "interactive", void 0); | ||
__decorate([ | ||
Input() | ||
], HelipopperDirective.prototype, "helipopperTrigger", void 0); | ||
], TippyDirective.prototype, "interactiveBorder", void 0); | ||
__decorate([ | ||
Input() | ||
], HelipopperDirective.prototype, "helipopperMaxWidth", void 0); | ||
], TippyDirective.prototype, "maxWidth", void 0); | ||
__decorate([ | ||
Input() | ||
], HelipopperDirective.prototype, "helipopperUseHostWidth", void 0); | ||
], TippyDirective.prototype, "offset", void 0); | ||
__decorate([ | ||
Input() | ||
], HelipopperDirective.prototype, "helipopperAllowClose", void 0); | ||
], TippyDirective.prototype, "placement", void 0); | ||
__decorate([ | ||
Input() | ||
], HelipopperDirective.prototype, "helipopperClass", void 0); | ||
], TippyDirective.prototype, "popperOptions", void 0); | ||
__decorate([ | ||
Input() | ||
], HelipopperDirective.prototype, "helipopperOffset", void 0); | ||
], TippyDirective.prototype, "showOnCreate", void 0); | ||
__decorate([ | ||
Input('helipopperInjector') | ||
], HelipopperDirective.prototype, "injector", void 0); | ||
Input() | ||
], TippyDirective.prototype, "trigger", void 0); | ||
__decorate([ | ||
Input('helipopperPlacement') | ||
], HelipopperDirective.prototype, "placement", null); | ||
Input() | ||
], TippyDirective.prototype, "triggerTarget", void 0); | ||
__decorate([ | ||
Input('helipopperVariation') | ||
], HelipopperDirective.prototype, "variation", null); | ||
Input() | ||
], TippyDirective.prototype, "zIndex", void 0); | ||
__decorate([ | ||
Input('helipopperDisabled') | ||
], HelipopperDirective.prototype, "disabled", null); | ||
Input() | ||
], TippyDirective.prototype, "lazy", void 0); | ||
__decorate([ | ||
Input('helipopperSticky') | ||
], HelipopperDirective.prototype, "sticky", null); | ||
Input() | ||
], TippyDirective.prototype, "variation", void 0); | ||
__decorate([ | ||
Input() | ||
], HelipopperDirective.prototype, "helipopper", null); | ||
], TippyDirective.prototype, "isEnable", void 0); | ||
__decorate([ | ||
Output() | ||
], HelipopperDirective.prototype, "helipopperClose", void 0); | ||
Input() | ||
], TippyDirective.prototype, "className", void 0); | ||
__decorate([ | ||
Input() | ||
], TippyDirective.prototype, "onlyTextOverflow", void 0); | ||
__decorate([ | ||
Input() | ||
], TippyDirective.prototype, "data", void 0); | ||
__decorate([ | ||
Input() | ||
], TippyDirective.prototype, "useHostWidth", void 0); | ||
__decorate([ | ||
Input("tippy") | ||
], TippyDirective.prototype, "content", void 0); | ||
__decorate([ | ||
Output() | ||
], HelipopperDirective.prototype, "helipopperVisible", void 0); | ||
HelipopperDirective = __decorate([ | ||
Directive({ selector: "[helipopper]", exportAs: 'helipopper' }), | ||
__param(5, Inject(PLATFORM_ID)), | ||
__param(6, Inject(HELIPOPPER_CONFIG)), | ||
__param(7, Inject(INITIAL_HELIPOPPER_OPTIONS)) | ||
], HelipopperDirective); | ||
return HelipopperDirective; | ||
], TippyDirective.prototype, "visible", void 0); | ||
TippyDirective = __decorate([ | ||
Directive({ | ||
selector: "[tippy]", | ||
exportAs: "tippy" | ||
}), | ||
__param(0, Inject(PLATFORM_ID)), | ||
__param(1, Inject(TIPPY_CONFIG)) | ||
], TippyDirective); | ||
return TippyDirective; | ||
}()); | ||
function isChanged(key, changes) { | ||
return key in changes; | ||
} | ||
var HelipopperModule = /** @class */ (function () { | ||
function HelipopperModule() { | ||
var TippyModule = /** @class */ (function () { | ||
function TippyModule() { | ||
} | ||
HelipopperModule_1 = HelipopperModule; | ||
HelipopperModule.forRoot = function (config) { | ||
TippyModule_1 = TippyModule; | ||
TippyModule.forRoot = function (config) { | ||
if (config === void 0) { config = {}; } | ||
return { | ||
ngModule: HelipopperModule_1, | ||
ngModule: TippyModule_1, | ||
providers: [ | ||
{ | ||
provide: HELIPOPPER_CONFIG, | ||
provide: TIPPY_CONFIG, | ||
useValue: config | ||
@@ -557,66 +403,87 @@ } | ||
}; | ||
var HelipopperModule_1; | ||
HelipopperModule = HelipopperModule_1 = __decorate([ | ||
var TippyModule_1; | ||
TippyModule = TippyModule_1 = __decorate([ | ||
NgModule({ | ||
declarations: [HelipopperDirective], | ||
exports: [HelipopperDirective] | ||
declarations: [TippyDirective], | ||
exports: [TippyDirective] | ||
}) | ||
], HelipopperModule); | ||
return HelipopperModule; | ||
], TippyModule); | ||
return TippyModule; | ||
}()); | ||
var HelipopperService = /** @class */ (function () { | ||
function HelipopperService(appRef, zone, resolver, hostInjector, platformId, config, initialOptions) { | ||
this.appRef = appRef; | ||
this.zone = zone; | ||
this.resolver = resolver; | ||
this.hostInjector = hostInjector; | ||
this.platformId = platformId; | ||
this.config = config; | ||
this.initialOptions = initialOptions; | ||
var tooltipVariation = { | ||
theme: null, | ||
arrow: false, | ||
animation: 'scale', | ||
trigger: 'mouseenter', | ||
offset: [0, 5] | ||
}; | ||
var popperVariation = { | ||
theme: 'light', | ||
arrow: true, | ||
offset: [0, 10], | ||
animation: null, | ||
trigger: 'click', | ||
interactive: true | ||
}; | ||
function withContextMenuVariation(baseVariation) { | ||
return __assign(__assign({}, baseVariation), { placement: 'right-start', trigger: 'manual', arrow: false, offset: [0, 0] }); | ||
} | ||
var TippyService = /** @class */ (function () { | ||
function TippyService(globalConfig, view, injector) { | ||
this.globalConfig = globalConfig; | ||
this.view = view; | ||
this.injector = injector; | ||
} | ||
HelipopperService.prototype.open = function (host, helipopper, options) { | ||
var directive = new HelipopperDirective(host, this.appRef, this.zone, this.resolver, this.hostInjector, this.platformId, this.config, this.initialOptions); | ||
directive.helipopper = helipopper; | ||
directive.helipopperOptions = (options === null || options === void 0 ? void 0 : options.options) || this.initialOptions.options; | ||
directive.showOnlyOnTextOverflow = isDefined(options === null || options === void 0 ? void 0 : options.textOverflow) | ||
? options === null || options === void 0 ? void 0 : options.textOverflow : this.initialOptions.textOverflow; | ||
directive.triggerTarget = options === null || options === void 0 ? void 0 : options.triggerTarget; | ||
directive.helipopperAppendTo = (options === null || options === void 0 ? void 0 : options.appendTo) || this.initialOptions.appendTo; | ||
directive.helipopperTrigger = options === null || options === void 0 ? void 0 : options.trigger; | ||
directive.helipopperClass = options === null || options === void 0 ? void 0 : options.class; | ||
directive.helipopperOffset = options === null || options === void 0 ? void 0 : options.offset; | ||
directive.injector = options === null || options === void 0 ? void 0 : options.injector; | ||
directive.placement = (options === null || options === void 0 ? void 0 : options.placement) || this.initialOptions.placement; | ||
directive.variation = (options === null || options === void 0 ? void 0 : options.variation) || this.initialOptions.variation; | ||
directive.disabled = isDefined(options === null || options === void 0 ? void 0 : options.disabled) ? options === null || options === void 0 ? void 0 : options.disabled : this.initialOptions.disabled; | ||
directive.sticky = options === null || options === void 0 ? void 0 : options.sticky; | ||
directive.helipopperAllowClose = isDefined(options === null || options === void 0 ? void 0 : options.allowClose) | ||
? options === null || options === void 0 ? void 0 : options.allowClose : this.initialOptions.allowClose; | ||
directive.whenStable.subscribe(function () { return directive.show(); }); | ||
return directive; | ||
TippyService.prototype.create = function (host, content, options) { | ||
var _this = this; | ||
if (options === void 0) { options = {}; } | ||
var view; | ||
var config = __assign(__assign(__assign({ $viewOptions: undefined, onShow: function (instance) { | ||
var _a; | ||
if (!config.$viewOptions) { | ||
config.$viewOptions = {}; | ||
if (isTemplateRef(content)) { | ||
config.$viewOptions.context = { | ||
$implicit: instance.hide.bind(instance) | ||
}; | ||
} | ||
else if (isComponent(content)) { | ||
config.$viewOptions.injector = Injector.create({ | ||
providers: [{ provide: TIPPY_REF, useValue: instance }], | ||
parent: options.injector || _this.injector | ||
}); | ||
} | ||
} | ||
view = _this.view.createView(content, __assign(__assign({}, options), config.$viewOptions)); | ||
instance.setContent(view.getElement()); | ||
(_a = options === null || options === void 0 ? void 0 : options.onShow) === null || _a === void 0 ? void 0 : _a.call(options, instance); | ||
}, onHidden: function (instance) { | ||
var _a; | ||
view.destroy(); | ||
(_a = options === null || options === void 0 ? void 0 : options.onHidden) === null || _a === void 0 ? void 0 : _a.call(options, instance); | ||
view = null; | ||
} }, this.globalConfig), this.globalConfig.variations[options.variation || this.globalConfig.defaultVariation]), options); | ||
var instance = tippy(host, config); | ||
var original = instance.destroy; | ||
instance.destroy = function () { | ||
original.call(tippy); | ||
view === null || view === void 0 ? void 0 : view.destroy(); | ||
view = null; | ||
}; | ||
return instance; | ||
}; | ||
HelipopperService.ctorParameters = function () { return [ | ||
{ type: ApplicationRef }, | ||
{ type: NgZone }, | ||
{ type: ComponentFactoryResolver }, | ||
{ type: Injector }, | ||
{ type: String, decorators: [{ type: Inject, args: [PLATFORM_ID,] }] }, | ||
{ type: undefined, decorators: [{ type: Inject, args: [HELIPOPPER_CONFIG,] }] }, | ||
{ type: undefined, decorators: [{ type: Inject, args: [INITIAL_HELIPOPPER_OPTIONS,] }] } | ||
TippyService.ctorParameters = function () { return [ | ||
{ type: undefined, decorators: [{ type: Inject, args: [TIPPY_CONFIG,] }] }, | ||
{ type: ViewService }, | ||
{ type: Injector } | ||
]; }; | ||
HelipopperService.ɵprov = ɵɵdefineInjectable({ factory: function HelipopperService_Factory() { return new HelipopperService(ɵɵinject(ApplicationRef), ɵɵinject(NgZone), ɵɵinject(ComponentFactoryResolver), ɵɵinject(INJECTOR), ɵɵinject(PLATFORM_ID), ɵɵinject(HELIPOPPER_CONFIG), ɵɵinject(INITIAL_HELIPOPPER_OPTIONS)); }, token: HelipopperService, providedIn: "root" }); | ||
HelipopperService = __decorate([ | ||
Injectable({ | ||
providedIn: 'root' | ||
}), | ||
__param(4, Inject(PLATFORM_ID)), | ||
__param(5, Inject(HELIPOPPER_CONFIG)), | ||
__param(6, Inject(INITIAL_HELIPOPPER_OPTIONS)) | ||
], HelipopperService); | ||
return HelipopperService; | ||
TippyService.ɵprov = ɵɵdefineInjectable({ factory: function TippyService_Factory() { return new TippyService(ɵɵinject(TIPPY_CONFIG), ɵɵinject(ViewService), ɵɵinject(INJECTOR)); }, token: TippyService, providedIn: "root" }); | ||
TippyService = __decorate([ | ||
Injectable({ providedIn: 'root' }), | ||
__param(0, Inject(TIPPY_CONFIG)) | ||
], TippyService); | ||
return TippyService; | ||
}()); | ||
function isDefined(value) { | ||
return value !== undefined; | ||
} | ||
@@ -627,3 +494,3 @@ /** | ||
export { HelipopperDirective, HelipopperModule, HelipopperService, HELIPOPPER_CONFIG as ɵb, INITIAL_HELIPOPPER_OPTIONS as ɵc }; | ||
export { TIPPY_REF, TippyModule, TippyService, inView, overflowChanges, popperVariation, tooltipVariation, withContextMenuVariation, TIPPY_CONFIG as ɵa, TippyDirective as ɵc }; | ||
//# sourceMappingURL=ngneat-helipopper.js.map |
import { Observable } from 'rxjs'; | ||
import { ElementRef, EmbeddedViewRef, TemplateRef } from '@angular/core'; | ||
export declare function inView(element: HTMLElement, options?: IntersectionObserverInit): Observable<unknown>; | ||
interface ResizeObserverOptions { | ||
box?: 'content-box' | 'border-box'; | ||
} | ||
declare type ElementDimensions = { | ||
width: number; | ||
height: number; | ||
}; | ||
export declare function dimensionsChanges(target: HTMLElement, options?: ResizeObserverOptions): Observable<ElementDimensions>; | ||
export declare function coerceElement<T>(elementOrRef: ElementRef<T> | T): T; | ||
export declare function isString(value: any): value is string; | ||
export declare function addClass(element: any, className: string | string[]): void; | ||
export declare function addStyle(element: any, prop: string, value: string): void; | ||
export declare function createElement(tagName: string): HTMLElement; | ||
export declare function closest(element: Element, selector: string): Element; | ||
export declare class TemplatePortal { | ||
viewRef: EmbeddedViewRef<{}>; | ||
elementRef: HTMLElement; | ||
private wrapper; | ||
constructor(tpl: TemplateRef<{}>); | ||
destroy(): void; | ||
} | ||
export {}; | ||
import { TippyElement } from './tippy.types'; | ||
export declare function inView(host: TippyElement, options?: IntersectionObserverInit): Observable<unknown>; | ||
export declare function overflowChanges(host: TippyElement): Observable<boolean>; | ||
export declare function dimensionsChanges(target: HTMLElement): Observable<boolean>; |
@@ -5,3 +5,3 @@ /** | ||
export * from './public-api'; | ||
export { INITIAL_HELIPOPPER_OPTIONS as ɵc, PartialHelipopperOptions as ɵd } from './lib/helipopper-options'; | ||
export { HELIPOPPER_CONFIG as ɵb, HelipopperConfig as ɵa } from './lib/helipopper.types'; | ||
export { TippyDirective as ɵc } from './lib/tippy.directive'; | ||
export { TIPPY_CONFIG as ɵa, TippyConfig as ɵb } from './lib/tippy.types'; |
@@ -1,1 +0,1 @@ | ||
{"__symbolic":"module","version":4,"metadata":{"HelipopperModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule","line":4,"character":1},"arguments":[{"declarations":[{"__symbolic":"reference","name":"HelipopperDirective"}],"exports":[{"__symbolic":"reference","name":"HelipopperDirective"}]}]}],"members":{},"statics":{"forRoot":{"__symbolic":"function","parameters":["config"],"defaults":[{}],"value":{"ngModule":{"__symbolic":"reference","name":"HelipopperModule"},"providers":[{"provide":{"__symbolic":"reference","name":"ɵb"},"useValue":{"__symbolic":"reference","name":"config"}}]}}}},"HelipopperDirective":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Directive","line":41,"character":1},"arguments":[{"selector":"[helipopper]","exportAs":"helipopper"}]}],"members":{"helipopperOptions":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":43,"character":3}}]}],"showOnlyOnTextOverflow":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":46,"character":3},"arguments":["helipopperTextOverflow"]}]}],"triggerTarget":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":50,"character":3}}]}],"helipopperHost":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":53,"character":3}}]}],"helipopperAppendTo":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":56,"character":3}}]}],"helipopperTrigger":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":59,"character":3}}]}],"helipopperMaxWidth":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":62,"character":3}}]}],"helipopperUseHostWidth":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":65,"character":3}}]}],"helipopperAllowClose":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":68,"character":3}}]}],"helipopperClass":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":71,"character":3}}]}],"helipopperOffset":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":74,"character":3}}]}],"injector":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":77,"character":3},"arguments":["helipopperInjector"]}]}],"placement":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":80,"character":3},"arguments":["helipopperPlacement"]}]}],"variation":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":86,"character":3},"arguments":["helipopperVariation"]}]}],"disabled":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":92,"character":3},"arguments":["helipopperDisabled"]}]}],"sticky":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":98,"character":3},"arguments":["helipopperSticky"]}]}],"helipopper":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":113,"character":3}}]}],"helipopperClose":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output","line":141,"character":3}}]}],"helipopperVisible":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output","line":142,"character":3}}]}],"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[null,null,null,null,null,[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject","line":162,"character":5},"arguments":[{"__symbolic":"reference","module":"@angular/core","name":"PLATFORM_ID","line":162,"character":12}]}],[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject","line":163,"character":5},"arguments":[{"__symbolic":"reference","name":"ɵb"}]}],[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject","line":164,"character":5},"arguments":[{"__symbolic":"reference","name":"ɵc"}]}]],"parameters":[{"__symbolic":"reference","module":"@angular/core","name":"ElementRef","line":157,"character":18},{"__symbolic":"reference","module":"@angular/core","name":"ApplicationRef","line":158,"character":20},{"__symbolic":"reference","module":"@angular/core","name":"NgZone","line":159,"character":18},{"__symbolic":"reference","module":"@angular/core","name":"ComponentFactoryResolver","line":160,"character":22},{"__symbolic":"reference","module":"@angular/core","name":"Injector","line":161,"character":26},{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","name":"ɵa"},{"__symbolic":"reference","name":"ɵd"}]}],"setProps":[{"__symbolic":"method"}],"hide":[{"__symbolic":"method"}],"show":[{"__symbolic":"method"}],"ngOnDestroy":[{"__symbolic":"method"}],"destroy":[{"__symbolic":"method"}],"destroyView":[{"__symbolic":"method"}],"create":[{"__symbolic":"method"}],"createInstance":[{"__symbolic":"method"}],"resolveTrigger":[{"__symbolic":"method"}],"resolveTemplate":[{"__symbolic":"method"}],"isElementOverflow":[{"__symbolic":"method"}],"getParent":[{"__symbolic":"method"}],"markDisabled":[{"__symbolic":"method"}],"resolveTheme":[{"__symbolic":"method"}],"addCloseButton":[{"__symbolic":"method"}],"removeCloseButton":[{"__symbolic":"method"}],"checkOverflow":[{"__symbolic":"method"}],"destroyTemplate":[{"__symbolic":"method"}],"createConfig":[{"__symbolic":"method"}],"resolveComponent":[{"__symbolic":"method"}],"destroyComponent":[{"__symbolic":"method"}],"resolveContent":[{"__symbolic":"method"}]}},"HelipopperService":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":16,"character":1},"arguments":[{"providedIn":"root"}]}],"members":{"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[null,null,null,null,[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject","line":25,"character":5},"arguments":[{"__symbolic":"reference","module":"@angular/core","name":"PLATFORM_ID","line":25,"character":12}]}],[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject","line":26,"character":5},"arguments":[{"__symbolic":"reference","name":"ɵb"}]}],[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject","line":27,"character":5},"arguments":[{"__symbolic":"reference","name":"ɵc"}]}]],"parameters":[{"__symbolic":"reference","module":"@angular/core","name":"ApplicationRef","line":21,"character":20},{"__symbolic":"reference","module":"@angular/core","name":"NgZone","line":22,"character":18},{"__symbolic":"reference","module":"@angular/core","name":"ComponentFactoryResolver","line":23,"character":22},{"__symbolic":"reference","module":"@angular/core","name":"Injector","line":24,"character":26},{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","name":"ɵa"},{"__symbolic":"reference","name":"ɵd"}]}],"open":[{"__symbolic":"method"}]},"statics":{"ɵprov":{}}},"ɵa":{"__symbolic":"interface"},"ɵb":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":26,"character":37},"arguments":["HELIPOPPER_CONFIG"]},"ɵc":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":6,"character":46},"arguments":["InitialHelipopperOptions",{"__symbolic":"error","message":"Lambda not supported","line":8,"character":11,"module":"./lib/helipopper-options"}]},"ɵd":{"__symbolic":"interface"}},"origins":{"HelipopperModule":"./lib/helipopper.module","HelipopperDirective":"./lib/helipopper.directive","HelipopperService":"./lib/helipopper.service","ɵa":"./lib/helipopper.types","ɵb":"./lib/helipopper.types","ɵc":"./lib/helipopper-options","ɵd":"./lib/helipopper-options"},"importAs":"@ngneat/helipopper"} | ||
{"__symbolic":"module","version":4,"metadata":{"TippyModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule","line":4,"character":1},"arguments":[{"declarations":[{"__symbolic":"reference","name":"ɵc"}],"exports":[{"__symbolic":"reference","name":"ɵc"}]}]}],"members":{},"statics":{"forRoot":{"__symbolic":"function","parameters":["config"],"defaults":[{}],"value":{"ngModule":{"__symbolic":"reference","name":"TippyModule"},"providers":[{"provide":{"__symbolic":"reference","name":"ɵa"},"useValue":{"__symbolic":"reference","name":"config"}}]}}}},"tooltipVariation":{"theme":null,"arrow":false,"animation":"scale","trigger":"mouseenter","offset":[0,5]},"popperVariation":{"theme":"light","arrow":true,"offset":[0,10],"animation":null,"trigger":"click","interactive":true},"withContextMenuVariation":{"__symbolic":"function","parameters":["baseVariation"],"value":{"placement":"right-start","trigger":"manual","arrow":false,"offset":[0,0]}},"TippyService":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":6,"character":1},"arguments":[{"providedIn":"root"}]}],"members":{"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject","line":9,"character":5},"arguments":[{"__symbolic":"reference","name":"ɵa"}]}],null,null],"parameters":[{"__symbolic":"reference","name":"ɵb"},{"__symbolic":"reference","module":"@ngneat/overview","name":"ViewService","line":10,"character":18},{"__symbolic":"reference","module":"@angular/core","name":"Injector","line":11,"character":22}]}],"create":[{"__symbolic":"method"}]},"statics":{"ɵprov":{}}},"inView":{"__symbolic":"function"},"overflowChanges":{"__symbolic":"function"},"ɵa":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":23,"character":32},"arguments":["Tippy config",{"providedIn":"root"}]},"ɵb":{"__symbolic":"interface"},"TippyInstance":{"__symbolic":"interface"},"TIPPY_REF":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":29,"character":29},"arguments":["TIPPY_REF"]},"ɵc":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Directive","line":25,"character":1},"arguments":[{"selector":"[tippy]","exportAs":"tippy"}]}],"members":{"appendTo":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":30,"character":3}}]}],"delay":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":31,"character":3}}]}],"duration":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":32,"character":3}}]}],"hideOnClick":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":33,"character":3}}]}],"interactive":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":34,"character":3}}]}],"interactiveBorder":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":35,"character":3}}]}],"maxWidth":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":36,"character":3}}]}],"offset":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":37,"character":3}}]}],"placement":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":38,"character":3}}]}],"popperOptions":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":39,"character":3}}]}],"showOnCreate":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":40,"character":3}}]}],"trigger":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":41,"character":3}}]}],"triggerTarget":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":42,"character":3}}]}],"zIndex":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":43,"character":3}}]}],"lazy":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":45,"character":3}}]}],"variation":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":46,"character":3}}]}],"isEnable":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":47,"character":3}}]}],"className":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":48,"character":3}}]}],"onlyTextOverflow":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":49,"character":3}}]}],"data":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":50,"character":3}}]}],"useHostWidth":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":51,"character":3}}]}],"content":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":52,"character":3},"arguments":["tippy"]}]}],"visible":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output","line":54,"character":3}}]}],"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject","line":67,"character":5},"arguments":[{"__symbolic":"reference","module":"@angular/core","name":"PLATFORM_ID","line":67,"character":12}]}],[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject","line":68,"character":5},"arguments":[{"__symbolic":"reference","name":"ɵa"}]}],null,null,null,null,null],"parameters":[{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","name":"ɵb"},{"__symbolic":"reference","module":"@angular/core","name":"Injector","line":69,"character":22},{"__symbolic":"reference","module":"@ngneat/overview","name":"ViewService","line":70,"character":25},{"__symbolic":"reference","module":"@angular/core","name":"ViewContainerRef","line":71,"character":17},{"__symbolic":"reference","module":"@angular/core","name":"NgZone","line":72,"character":18},{"__symbolic":"reference","module":"@angular/core","name":"ElementRef","line":73,"character":18}]}],"ngOnChanges":[{"__symbolic":"method"}],"ngOnInit":[{"__symbolic":"method"}],"ngAfterViewInit":[{"__symbolic":"method"}],"ngOnDestroy":[{"__symbolic":"method"}],"destroyView":[{"__symbolic":"method"}],"show":[{"__symbolic":"method"}],"hide":[{"__symbolic":"method"}],"enable":[{"__symbolic":"method"}],"disable":[{"__symbolic":"method"}],"setProps":[{"__symbolic":"method"}],"setStatus":[{"__symbolic":"method"}],"createInstance":[{"__symbolic":"method"}],"resolveContent":[{"__symbolic":"method"}],"handleContextMenu":[{"__symbolic":"method"}],"checkOverflow":[{"__symbolic":"method"}]}}},"origins":{"TippyModule":"./lib/tippy.module","tooltipVariation":"./lib/defaults","popperVariation":"./lib/defaults","withContextMenuVariation":"./lib/defaults","TippyService":"./lib/tippy.service","inView":"./lib/utils","overflowChanges":"./lib/utils","ɵa":"./lib/tippy.types","ɵb":"./lib/tippy.types","TippyInstance":"./lib/tippy.types","TIPPY_REF":"./lib/tippy.types","ɵc":"./lib/tippy.directive"},"importAs":"@ngneat/helipopper"} |
{ | ||
"name": "@ngneat/helipopper", | ||
"version": "1.6.0", | ||
"version": "2.0.0-beta.1", | ||
"description": "A Powerful Tooltip and Popover for Angular Applications", | ||
@@ -8,3 +8,4 @@ "schematics": "./schematics/collection.json", | ||
"tslib": "^1.10.0", | ||
"tippy.js": "^6.2.3" | ||
"tippy.js": "^6.2.3", | ||
"@ngneat/overview": "^1.0.0-beta.0" | ||
}, | ||
@@ -11,0 +12,0 @@ "keywords": [ |
@@ -1,3 +0,5 @@ | ||
export * from './lib/helipopper.module'; | ||
export * from './lib/helipopper.directive'; | ||
export * from './lib/helipopper.service'; | ||
export { TippyModule } from "./lib/tippy.module"; | ||
export { tooltipVariation, popperVariation, withContextMenuVariation } from "./lib/defaults"; | ||
export { TippyService } from "./lib/tippy.service"; | ||
export { inView, overflowChanges } from "./lib/utils"; | ||
export { TippyInstance, TIPPY_REF } from "./lib/tippy.types"; |
304
README.md
@@ -18,13 +18,14 @@ <p align="center"> | ||
[Tippy.js](https://atomiks.github.io/tippyjs/v6/getting-started/) is the complete tooltip, popover, dropdown, and menu solution for the web, powered by Popper.js. | ||
[Tippy.js](https://atomiks.github.io/tippyjs/v6/getting-started/) is the complete tooltip, popover, dropdown, and menu | ||
solution for the web, powered by Popper.js. | ||
It is an abstraction over Popper that provides the logic and optionally the styling involved in all types of elements that pop out from the flow of the document and get overlaid on top of the UI, positioned next to a reference element. | ||
It is an abstraction over Popper that provides the logic and optionally the styling involved in all types of elements | ||
that pop out from the flow of the document and get overlaid on top of the UI, positioned next to a reference element. | ||
This is a lightweight wrapper with additional features that lets you use it declaratively in Angular. Tippy has virtually no restrictions over Popper and gives you limitless control while providing useful behavior and defaults. | ||
This is a lightweight wrapper with additional features that lets you use it declaratively in Angular. Tippy has | ||
virtually no restrictions over Popper and gives you limitless control while providing useful behavior and defaults. | ||
<a href="https://www.buymeacoffee.com/basalnetanel" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" alt="Buy Me A Coffee" style="height: 41px !important;width: 174px !important;box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;-webkit-box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;" ></a> | ||
## Features | ||
✅ Tooltip & Popover Variations <br> | ||
✅ Predefined Variations <br> | ||
✅ TemplateRef/Component Support<br> | ||
@@ -34,5 +35,5 @@ ✅ Lazy Registration<br> | ||
✅ Text Overflow Support<br> | ||
✅ Sticky Support | ||
✅ Context Menu Support<br> | ||
## Installation | ||
### Installation | ||
@@ -43,19 +44,37 @@ ``` | ||
Add the `HelipopperModule` to your `AppModule`: | ||
Add the `TippyModule` to your `AppModule`: | ||
```ts | ||
import { HelipopperModule } from '@ngneat/helipopper'; | ||
import { TippyModule, tooltipVariation, popperVariation } from '@ngneat/helipopper'; | ||
@NgModule({ | ||
declarations: [AppComponent], | ||
imports: [HelipopperModule.forRoot()], | ||
imports: [TippyModule.forRoot({ | ||
defaultVariation: 'tooltip', | ||
variations: { | ||
tooltip: tooltipVariation, | ||
popper: popperVariation, | ||
} | ||
})], | ||
bootstrap: [AppComponent] | ||
}) | ||
export class AppModule {} | ||
export class AppModule { | ||
} | ||
``` | ||
Now you can use it: | ||
Add the styles you want to `styles.scss`: | ||
```scss | ||
@import '~tippy.js/dist/tippy.css'; | ||
@import '~tippy.js/themes/light.css'; | ||
@import '~tippy.js/animations/scale.css'; | ||
``` | ||
You have the freedom to [customize](https://atomiks.github.io/tippyjs/v6/themes/) it if you need to. | ||
Now you can use it in your templates: | ||
```html | ||
<button helipopper="Helpful Message"> | ||
<button tippy="Helpful Message"> | ||
I have a tooltip | ||
@@ -65,19 +84,43 @@ </button> | ||
#### TemplateRef: | ||
The library exposes default variations for `tooltip` and `popper`. You can use them, extend them, or pass your own | ||
variations. A `variation` is a set of predefined `tippy` properties. For example, here's how the built-in `tooltip` | ||
variation looks like: | ||
```ts | ||
export const tooltipVariation = { | ||
theme: null, | ||
arrow: false, | ||
animation: 'scale', | ||
trigger: 'mouseenter', | ||
offset: [0, 5] | ||
}; | ||
``` | ||
### Use `TemplateRef` as content | ||
```html | ||
<button [helipopper]="tpl" helipopperVariation="popper"> | ||
<button [tippy]="tpl" variation="popper"> | ||
Click Me | ||
</button> | ||
<ng-template #tpl> | ||
<div *ngFor="let msg of messages">{{ msg }}</div> | ||
<button (click)="talk()">Click to talk ☮️️</button> | ||
<ng-template #tpl let-hide> | ||
<h6>Popover title</h6> | ||
<p>And here's some amazing content. It's very engaging. Right?</p> | ||
</ng-template> | ||
``` | ||
#### Component: | ||
### Use `Component` as content | ||
```ts | ||
import { TIPPY_REF, TippyInstance } from '@ngneat/helipopper'; | ||
@Component() | ||
class MyComponent { | ||
constructor(@Inject(TIPPY_REF) tippy: TippyInstance) { | ||
} | ||
} | ||
``` | ||
```html | ||
<button [helipopper]="component" (helipopperClose)="onClose()"> | ||
<button [tippy]="MyComponent"> | ||
Click Me | ||
@@ -87,24 +130,55 @@ </button> | ||
#### Handle current status as boolean | ||
### Text Overflow | ||
You can pass the `onlyTextOverflow` input to show the tooltip only when the host overflows its container: | ||
```html | ||
<button helipopper="Helpful Message" (helipopperVisible)="handleStatus($event)"> | ||
Click Me | ||
</button> | ||
<div style="max-width: 100px;" class="overflow-hidden flex"> | ||
<p class="ellipsis" [tippy]="text" placement="right" [onlyTextOverflow]="true"> | ||
{{ text }} | ||
</p> | ||
</div> | ||
``` | ||
and on .ts | ||
### Context Menu | ||
First, define the `contextMenu` variation: | ||
```ts | ||
import { | ||
popperVariation, | ||
TippyModule, | ||
tooltipVariation, | ||
withContextMenuVariation | ||
} from '@ngneat/helipopper'; | ||
```ts | ||
handleStatus($event: boolean): void { | ||
console.log('show tooltip', $event); | ||
} | ||
@NgModule({ | ||
imports: [ | ||
TippyModule.forRoot({ | ||
defaultVariation: 'tooltip', | ||
variations: { | ||
tooltip: tooltipVariation, | ||
popper: popperVariation, | ||
contextMenu: withContextMenuVariation(popperVariation), | ||
} | ||
}) | ||
], | ||
}) | ||
export class AppModule {} | ||
``` | ||
#### Text Overflow: | ||
Now you can use it in your template: | ||
```html | ||
<ul style="max-width: 100px;"> | ||
<li class="ellipsis" [helipopper]="text" helipopperPlacement="right" [helipopperTextOverflow]="true"> | ||
{{ text }} | ||
<ng-template #contextMenu let-hide let-item="data"> | ||
<ul> | ||
<li (click)="copy(item); hide()">Copy</li> | ||
<li (click)="duplicate(item); hide()">Duplicate</li> | ||
</ul> | ||
</ng-template> | ||
<ul> | ||
<li *ngFor="let item of list" | ||
[tippy]="contextMenu" | ||
[data]="item" | ||
variation="contextMenu"> | ||
{{ item.label }} | ||
</li> | ||
@@ -114,6 +188,8 @@ </ul> | ||
#### Manual Trigger: | ||
### Manual Trigger | ||
```html | ||
<span helipopper="Helpful Message" helipopperTrigger="manual" #tooltip="helipopper">Click Open to see me</span> | ||
<div tippy="Helpful Message" trigger="manual" #tooltip="tippy"> | ||
Click Open to see me | ||
</div> | ||
@@ -124,120 +200,64 @@ <button (click)="tooltip.show()">Open</button> | ||
You can see more examples in our [playground](https://github.com/ngneat/helipopper/blob/master/src/app/app.component.html), or live [here](https://ngneat.github.io/helipopper/). | ||
You can see more examples in | ||
our [playground](https://github.com/ngneat/helipopper/blob/master/src/app/app.component.html), or | ||
live [here](https://ngneat.github.io/helipopper/). | ||
## Styling | ||
### Inputs | ||
Add the following style to your main `scss` file: | ||
```ts | ||
appendTo: TippyProps['appendTo']; | ||
delay: TippyProps['delay']; | ||
duration: TippyProps['duration']; | ||
hideOnClick: TippyProps['hideOnClick']; | ||
interactive: TippyProps['interactive']; | ||
interactiveBorder: TippyProps['interactiveBorder']; | ||
maxWidth: TippyProps['maxWidth']; | ||
offset: TippyProps['offset']; | ||
placement: TippyProps['placement']; | ||
popperOptions: TippyProps['popperOptions']; | ||
showOnCreate: TippyProps['showOnCreate']; | ||
trigger: TippyProps['trigger']; | ||
triggerTarget: TippyProps['triggerTarget']; | ||
zIndex: TippyProps['zIndex']; | ||
```scss | ||
@import '~tippy.js/dist/tippy.css'; | ||
@import '~tippy.js/themes/light.css'; | ||
@import '~tippy.js/animations/scale.css'; | ||
.tippy-content { | ||
position: relative; | ||
} | ||
.tippy-close { | ||
position: absolute; | ||
width: 24px; | ||
height: 24px; | ||
top: 9px; | ||
right: 9px; | ||
fill: rgb(158, 160, 165); | ||
cursor: pointer; | ||
z-index: 1; | ||
} | ||
.tippy-box { | ||
border-radius: 4px; | ||
font-size: 11px; | ||
.tippy-content { | ||
padding: 4px 6px; | ||
} | ||
} | ||
.tippy-box[data-theme~='light'] { | ||
font-size: 12px; | ||
word-break: break-word; | ||
border-radius: 0; | ||
background-color: rgb(255, 255, 255); | ||
box-shadow: 0 2px 14px 0 rgba(0, 0, 0, 0.2); | ||
color: rgb(79, 80, 83); | ||
.tippy-content { | ||
padding: 13px 48px 13px 20px; | ||
} | ||
} | ||
.tippy-arrow::before { | ||
box-shadow: -4px 4px 14px -4px rgba(0, 0, 0, 0.2); | ||
} | ||
lazy: boolean; | ||
variation: string; | ||
isEnable: boolean; | ||
className: string; | ||
onlyTextOverflow = false; | ||
data: any; | ||
``` | ||
You have the freedom to [customize](https://atomiks.github.io/tippyjs/v6/themes/) it if you need to. | ||
### Outputs | ||
## Inputs | ||
| @Input | Type | Description | Default | | ||
| ---------------------- | ------------------------- | ------------------------------------------------------------ | ---------------------------------------------------------------------- | | ||
| helipopperVariation | `tooltip` \| `popper` | The tooltip type | `tooltip` | | ||
| helipopper | `string` \| `TemplateRef` | The tooltip content | `none` | | ||
| helipopperPlacement | `Popper placement` | The tooltip placement | `top` | | ||
| helipopperTrigger | `string` | The tooltip trigger | | | ||
| helipopperClass | `string` \| `string[]` | Custom class that'll be added to the tooltip | `none` | | ||
| helipopperOffset | `[number, number]` | Set tooltip offset position | `[0, 10]` | | ||
| helipopperDisabled | `Boolean` | Whether to disabled the tooltip | `false` | | ||
| helipopperHost | `ElementRef` \| `Element` | The target element | `Host` | | ||
| helipopperUseHostWidth | `Boolean` | Set the tooltip's width & maxWidth according to the host | `false` | | ||
| helipopperAppendTo | `string`\| `Element` | The element to append the tooltip to | [`appendTo`](https://atomiks.github.io/tippyjs/v6/all-props/#appendto) | | ||
| helipopperOptions | `tippy` options | `tippy` options | [docs](https://atomiks.github.io/tippyjs/v6/all-props) | | ||
| helipopperTextOverflow | `Boolean` | Show the tooltip only when the text overflows its container | `false` | | ||
| helipopperSticky | `Boolean` | Whether the tooltip should be sticky (i.e. always displayed) | `false` | | ||
| helipopperInjector | `Injector` \| `undefined` | The custom injector to be provided | `none` | | ||
## Outputs | ||
| @Output | Type | Description | | ||
| ----------------- | --------- | --------------------------------------------------------- | | ||
| helipopperClose | `void` | Method called when tooltip is closed | | ||
| helipopperVisible | `boolean` | Method that emits the tooltip's current status as boolean | | ||
## Config | ||
- `beforeRender` - Hook that'll be called before rendering the tooltip content: ( applies only for string ) | ||
```ts | ||
import { HelipopperModule } from '@ngneat/helipopper'; | ||
@NgModule({ | ||
imports: [ | ||
HelipopperModule.forRoot({ | ||
beforeRender(content) { | ||
return sanitize(content); | ||
} | ||
}) | ||
] | ||
}) | ||
export class AppModule {} | ||
visible = new EventEmitter<boolean>(); | ||
``` | ||
- `closeIcon` - The svg close icon that'll be used inside the popper. | ||
### Global Config | ||
- You can pass any `tippy` option at global config level. | ||
- `beforeRender` - Hook that'll be called before rendering the tooltip content ( applies only for string ) | ||
## Attach the Popper Manually | ||
### Create `tippy` Programmatically | ||
```typescript | ||
import { TippyService, TippyInstance } from '@ngneat/helipopper'; | ||
class Component { | ||
@ViewChild('inputName', { static: true }) inputName: ElementRef; | ||
@ViewChild('inputName') inputName: ElementRef; | ||
private tippy: TippyInstance; | ||
constructor(private service: HelipopperService) {} | ||
constructor(private tippy: TippyService) { | ||
} | ||
open() { | ||
if (!this.popper) { | ||
this.popper = this.service.open(this.inputName, 'this field is required', options); | ||
if(!this.tippy) { | ||
this.tippy = this.tippy.create(this.inputName, 'this field is required'); | ||
} | ||
this.tippy.open(); | ||
} | ||
close() { | ||
this.popper.hide(); | ||
ngOnDestroy() { | ||
this.tippy?.destroy(); | ||
} | ||
@@ -247,10 +267,2 @@ } | ||
`open()` returns an `HelipopperDirective` which allows you to use [manual trigger](#manual-trigger) on it. | ||
It takes the following paramaters: | ||
- The host Element | ||
- The popper content | ||
- An optional options object with all the [@Input options](#inputs) available. | ||
## Contributors ✨ | ||
@@ -278,3 +290,5 @@ | ||
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! | ||
Icon made by <a href="https://www.flaticon.com/authors/freepik" title="freepik">Airport</a> from <a href="https://www.flaticon.com/" title="Flaticon"> www.flaticon.com</a> | ||
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. | ||
Contributions of any kind welcome! | ||
Icon made by <a href="https://www.flaticon.com/authors/freepik" title="freepik">Airport</a> | ||
from <a href="https://www.flaticon.com/" title="Flaticon"> www.flaticon.com</a> |
@@ -56,4 +56,4 @@ "use strict"; | ||
return schematics_1.chain([ | ||
addImportsToModuleFile(options, ['HelipopperModule']), | ||
addImportsToModuleDeclaration(options, ['HelipopperModule.forRoot()']) | ||
addImportsToModuleFile(options, ['TippyModule']), | ||
addImportsToModuleDeclaration(options, ['TippyModule.forRoot()']) | ||
])(host, context); | ||
@@ -60,0 +60,0 @@ }; |
@@ -64,6 +64,6 @@ import { chain, Rule, SchematicContext, SchematicsException, Tree } from '@angular-devkit/schematics'; | ||
return chain([ | ||
addImportsToModuleFile(options, ['HelipopperModule']), | ||
addImportsToModuleDeclaration(options, ['HelipopperModule.forRoot()']) | ||
addImportsToModuleFile(options, ['TippyModule']), | ||
addImportsToModuleDeclaration(options, ['TippyModule.forRoot()']) | ||
])(host, context); | ||
}; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
286
455231
3
4513
2
1
+ Added@ngneat/overview@1.0.0(transitive)
+ Addedtslib@2.8.1(transitive)