@ship-ui/core 0.17.9 → 0.17.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1046,10 +1046,27 @@
|
|
|
1046
1046
|
"type": "boolean",
|
|
1047
1047
|
"description": "",
|
|
1048
1048
|
"defaultValue": "false"
|
|
1049
|
+
},
|
|
1050
|
+
{
|
|
1051
|
+
"name": "content",
|
|
1052
|
+
"type": "string | TemplateRef<any> | null | undefined",
|
|
1053
|
+
"description": ""
|
|
1054
|
+
},
|
|
1055
|
+
{
|
|
1056
|
+
"name": "close",
|
|
1057
|
+
"type": "() => void",
|
|
1058
|
+
"description": "",
|
|
1059
|
+
"defaultValue": "("
|
|
1049
1060
|
}
|
|
1050
1061
|
],
|
|
1051
1062
|
"outputs": [],
|
|
1052
1063
|
"methods": [
|
|
1064
|
+
{
|
|
1065
|
+
"name": "untracked",
|
|
1066
|
+
"parameters": "() => {\n if (this.isOpen() && openRef?.component === this && openRef?.wrapperComponentRef",
|
|
1067
|
+
"returnType": "any",
|
|
1068
|
+
"description": ""
|
|
1069
|
+
},
|
|
1053
1070
|
{
|
|
1054
1071
|
"name": "onMouseEnter",
|
|
1055
1072
|
"parameters": "",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { InjectionToken, inject, computed, ElementRef, Renderer2, input, ChangeDetectionStrategy, Component, viewChild, effect, HostListener, NgModule, signal, Injectable, DOCUMENT, model, output, ApplicationRef, createComponent, isSignal, OutputEmitterRef, DestroyRef, PLATFORM_ID, ViewChild, contentChild, contentChildren, afterNextRender, Injector, HostBinding, TemplateRef, runInInjectionContext, Directive, ChangeDetectorRef, viewChildren, ViewContainerRef, EnvironmentInjector } from '@angular/core';
|
|
2
|
+
import { InjectionToken, inject, computed, ElementRef, Renderer2, input, ChangeDetectionStrategy, Component, viewChild, effect, HostListener, NgModule, signal, Injectable, DOCUMENT, model, output, ApplicationRef, createComponent, isSignal, OutputEmitterRef, DestroyRef, PLATFORM_ID, ViewChild, contentChild, contentChildren, afterNextRender, Injector, HostBinding, TemplateRef, runInInjectionContext, Directive, ChangeDetectorRef, viewChildren, untracked, ViewContainerRef, EnvironmentInjector } from '@angular/core';
|
|
3
3
|
import { isPlatformBrowser, JsonPipe, DatePipe, isPlatformServer, NgTemplateOutlet } from '@angular/common';
|
|
4
4
|
import { NgModel } from '@angular/forms';
|
|
5
5
|
import { SIGNAL } from '@angular/core/primitives/signals';
|
|
@@ -6892,10 +6892,15 @@ class ShipTooltipWrapper {
|
|
|
6892
6892
|
this.positionAnchorName = input.required(...(ngDevMode ? [{ debugName: "positionAnchorName" }] : []));
|
|
6893
6893
|
this.anchorEl = input.required(...(ngDevMode ? [{ debugName: "anchorEl" }] : []));
|
|
6894
6894
|
this.isOpen = input(false, ...(ngDevMode ? [{ debugName: "isOpen" }] : []));
|
|
6895
|
+
this.content = input(...(ngDevMode ? [undefined, { debugName: "content" }] : []));
|
|
6896
|
+
this.close = input(() => { }, ...(ngDevMode ? [{ debugName: "close" }] : []));
|
|
6897
|
+
this.tooltipContext = {
|
|
6898
|
+
close: () => this.close()(),
|
|
6899
|
+
};
|
|
6900
|
+
this.isTemplate = computed(() => this.content() instanceof TemplateRef, ...(ngDevMode ? [{ debugName: "isTemplate" }] : []));
|
|
6895
6901
|
this.#selfRef = inject((ElementRef));
|
|
6896
6902
|
this.#renderer = inject(Renderer2);
|
|
6897
6903
|
this.#positionAbort = null;
|
|
6898
|
-
// readonly BASE_SPACE = 8;
|
|
6899
6904
|
this.SUPPORTS_ANCHOR = typeof CSS !== 'undefined' && CSS.supports('position-anchor', '--abc');
|
|
6900
6905
|
this.isBelow = signal(false, ...(ngDevMode ? [{ debugName: "isBelow" }] : []));
|
|
6901
6906
|
this.openEffect = effect(() => {
|
|
@@ -6952,20 +6957,29 @@ class ShipTooltipWrapper {
|
|
|
6952
6957
|
this.#positionAbort?.abort();
|
|
6953
6958
|
}
|
|
6954
6959
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.0", ngImport: i0, type: ShipTooltipWrapper, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
6955
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.
|
|
6960
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.0.0", type: ShipTooltipWrapper, isStandalone: true, selector: "ship-tooltip-wrapper", inputs: { positionAnchorName: { classPropertyName: "positionAnchorName", publicName: "positionAnchorName", isSignal: true, isRequired: true, transformFunction: null }, anchorEl: { classPropertyName: "anchorEl", publicName: "anchorEl", isSignal: true, isRequired: true, transformFunction: null }, isOpen: { classPropertyName: "isOpen", publicName: "isOpen", isSignal: true, isRequired: false, transformFunction: null }, content: { classPropertyName: "content", publicName: "content", isSignal: true, isRequired: false, transformFunction: null }, close: { classPropertyName: "close", publicName: "close", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "tooltip" }, properties: { "attr.popover": "\"manual\"", "style.position-anchor": "positionAnchorName()", "class.below": "isBelow()" } }, ngImport: i0, template: `
|
|
6956
6961
|
<div class="tooltip-content">
|
|
6957
|
-
|
|
6962
|
+
@if (isTemplate()) {
|
|
6963
|
+
<ng-container *ngTemplateOutlet="$any(content()); context: { $implicit: tooltipContext }" />
|
|
6964
|
+
} @else {
|
|
6965
|
+
{{ content() }}
|
|
6966
|
+
}
|
|
6958
6967
|
</div>
|
|
6959
|
-
`, isInline: true }); }
|
|
6968
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] }); }
|
|
6960
6969
|
}
|
|
6961
6970
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.0", ngImport: i0, type: ShipTooltipWrapper, decorators: [{
|
|
6962
6971
|
type: Component,
|
|
6963
6972
|
args: [{
|
|
6964
6973
|
selector: 'ship-tooltip-wrapper',
|
|
6965
6974
|
standalone: true,
|
|
6975
|
+
imports: [NgTemplateOutlet],
|
|
6966
6976
|
template: `
|
|
6967
6977
|
<div class="tooltip-content">
|
|
6968
|
-
|
|
6978
|
+
@if (isTemplate()) {
|
|
6979
|
+
<ng-container *ngTemplateOutlet="$any(content()); context: { $implicit: tooltipContext }" />
|
|
6980
|
+
} @else {
|
|
6981
|
+
{{ content() }}
|
|
6982
|
+
}
|
|
6969
6983
|
</div>
|
|
6970
6984
|
`,
|
|
6971
6985
|
host: {
|
|
@@ -6975,25 +6989,33 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.0", ngImpor
|
|
|
6975
6989
|
'[class.below]': 'isBelow()',
|
|
6976
6990
|
},
|
|
6977
6991
|
}]
|
|
6978
|
-
}], propDecorators: { positionAnchorName: [{ type: i0.Input, args: [{ isSignal: true, alias: "positionAnchorName", required: true }] }], anchorEl: [{ type: i0.Input, args: [{ isSignal: true, alias: "anchorEl", required: true }] }], isOpen: [{ type: i0.Input, args: [{ isSignal: true, alias: "isOpen", required: false }] }] } });
|
|
6992
|
+
}], propDecorators: { positionAnchorName: [{ type: i0.Input, args: [{ isSignal: true, alias: "positionAnchorName", required: true }] }], anchorEl: [{ type: i0.Input, args: [{ isSignal: true, alias: "anchorEl", required: true }] }], isOpen: [{ type: i0.Input, args: [{ isSignal: true, alias: "isOpen", required: false }] }], content: [{ type: i0.Input, args: [{ isSignal: true, alias: "content", required: false }] }], close: [{ type: i0.Input, args: [{ isSignal: true, alias: "close", required: false }] }] } });
|
|
6979
6993
|
let openRef = null;
|
|
6980
6994
|
class ShipTooltip {
|
|
6981
6995
|
constructor() {
|
|
6982
6996
|
this.shTooltip = input.required(...(ngDevMode ? [{ debugName: "shTooltip" }] : []));
|
|
6997
|
+
this.#contentReplacedEffect = effect(() => {
|
|
6998
|
+
const content = this.shTooltip();
|
|
6999
|
+
untracked(() => {
|
|
7000
|
+
if (this.isOpen() && openRef?.component === this && openRef?.wrapperComponentRef) {
|
|
7001
|
+
openRef.wrapperComponentRef.setInput('content', content);
|
|
7002
|
+
openRef.wrapperComponentRef.changeDetectorRef.detectChanges();
|
|
7003
|
+
}
|
|
7004
|
+
});
|
|
7005
|
+
}, ...(ngDevMode ? [{ debugName: "#contentReplacedEffect" }] : []));
|
|
6983
7006
|
this.#elementRef = inject((ElementRef));
|
|
6984
7007
|
this.#viewContainerRef = inject(ViewContainerRef);
|
|
6985
7008
|
this.#environmentInjector = inject(EnvironmentInjector);
|
|
6986
7009
|
this.#renderer = inject(Renderer2);
|
|
6987
|
-
this.#projectedViewRef = null;
|
|
6988
7010
|
this.DEBOUNCE_DELAY = 500;
|
|
6989
7011
|
this.anchorName = `--${generateUniqueId()}`;
|
|
6990
7012
|
this.isOpen = signal(false, ...(ngDevMode ? [{ debugName: "isOpen" }] : []));
|
|
6991
7013
|
}
|
|
7014
|
+
#contentReplacedEffect;
|
|
6992
7015
|
#elementRef;
|
|
6993
7016
|
#viewContainerRef;
|
|
6994
7017
|
#environmentInjector;
|
|
6995
7018
|
#renderer;
|
|
6996
|
-
#projectedViewRef;
|
|
6997
7019
|
onMouseEnter() {
|
|
6998
7020
|
if (openRef?.component.anchorName !== this.anchorName) {
|
|
6999
7021
|
this.cleanupTooltip();
|
|
@@ -7021,31 +7043,23 @@ class ShipTooltip {
|
|
|
7021
7043
|
}
|
|
7022
7044
|
}
|
|
7023
7045
|
showTooltip() {
|
|
7024
|
-
if (openRef?.wrapperComponentRef || !this.shTooltip())
|
|
7025
|
-
|
|
7026
|
-
|
|
7027
|
-
|
|
7028
|
-
if (typeof content === 'string') {
|
|
7029
|
-
nodesToProject = [[this.#renderer.createText(content)]];
|
|
7030
|
-
}
|
|
7031
|
-
else if (content instanceof TemplateRef) {
|
|
7032
|
-
this.#projectedViewRef = content.createEmbeddedView({});
|
|
7033
|
-
this.#projectedViewRef.detectChanges();
|
|
7034
|
-
nodesToProject = [this.#projectedViewRef.rootNodes];
|
|
7035
|
-
}
|
|
7036
|
-
else {
|
|
7046
|
+
if (openRef?.wrapperComponentRef || !this.shTooltip()) {
|
|
7047
|
+
if (openRef?.component === this && openRef?.wrapperComponentRef) {
|
|
7048
|
+
openRef.wrapperComponentRef.setInput('content', this.shTooltip());
|
|
7049
|
+
}
|
|
7037
7050
|
return;
|
|
7038
7051
|
}
|
|
7039
7052
|
openRef = {
|
|
7040
7053
|
wrapperComponentRef: this.#viewContainerRef.createComponent(ShipTooltipWrapper, {
|
|
7041
7054
|
environmentInjector: this.#environmentInjector,
|
|
7042
|
-
projectableNodes: nodesToProject,
|
|
7043
7055
|
}),
|
|
7044
7056
|
component: this,
|
|
7045
7057
|
};
|
|
7046
7058
|
openRef.wrapperComponentRef.setInput('positionAnchorName', this.anchorName);
|
|
7047
7059
|
openRef.wrapperComponentRef.setInput('anchorEl', this.#elementRef);
|
|
7048
|
-
openRef.wrapperComponentRef
|
|
7060
|
+
openRef.wrapperComponentRef.setInput('isOpen', this.isOpen);
|
|
7061
|
+
openRef.wrapperComponentRef.setInput('content', this.shTooltip());
|
|
7062
|
+
openRef.wrapperComponentRef.setInput('close', () => this.cleanupTooltip());
|
|
7049
7063
|
openRef.wrapperComponentRef.changeDetectorRef.detectChanges();
|
|
7050
7064
|
openRef.wrapperComponentRef.location.nativeElement.addEventListener('mouseenter', () => {
|
|
7051
7065
|
this.cancelCleanupTimer();
|
|
@@ -7064,10 +7078,6 @@ class ShipTooltip {
|
|
|
7064
7078
|
openRef.component.isOpen.set(false);
|
|
7065
7079
|
openRef = null;
|
|
7066
7080
|
}
|
|
7067
|
-
if (this.#projectedViewRef) {
|
|
7068
|
-
this.#projectedViewRef.destroy();
|
|
7069
|
-
this.#projectedViewRef = null;
|
|
7070
|
-
}
|
|
7071
7081
|
}
|
|
7072
7082
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.0", ngImport: i0, type: ShipTooltip, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
7073
7083
|
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.0.0", type: ShipTooltip, isStandalone: true, selector: "[shTooltip]", inputs: { shTooltip: { classPropertyName: "shTooltip", publicName: "shTooltip", isSignal: true, isRequired: true, transformFunction: null } }, host: { listeners: { "mouseenter": "onMouseEnter()", "mouseleave": "onMouseLeave()" }, properties: { "style.anchor-name": "anchorName", "class.active": "isOpen()" }, classAttribute: "tooltip" }, ngImport: i0 }); }
|