ng-primitives 0.0.5
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.
- package/README.md +7 -0
- package/a11y/README.md +3 -0
- package/a11y/index.d.ts +8 -0
- package/a11y/visually-hidden/visually-hidden.directive.d.ts +5 -0
- package/accordion/README.md +3 -0
- package/accordion/accordion/accordion.directive.d.ts +45 -0
- package/accordion/accordion/accordion.token.d.ts +15 -0
- package/accordion/accordion-content/accordion-content.directive.d.ts +25 -0
- package/accordion/accordion-content/accordion-content.token.d.ts +15 -0
- package/accordion/accordion-item/accordion-item.directive.d.ts +45 -0
- package/accordion/accordion-item/accordion-item.token.d.ts +15 -0
- package/accordion/accordion-trigger/accordion-trigger.directive.d.ts +21 -0
- package/accordion/accordion-trigger/accordion-trigger.token.d.ts +15 -0
- package/accordion/config/accordion.config.d.ts +39 -0
- package/accordion/index.d.ts +16 -0
- package/avatar/README.md +3 -0
- package/avatar/avatar/avatar.directive.d.ts +22 -0
- package/avatar/avatar/avatar.token.d.ts +15 -0
- package/avatar/avatar-fallback/avatar-fallback.directive.d.ts +45 -0
- package/avatar/avatar-image/avatar-image.directive.d.ts +28 -0
- package/avatar/config/avatar.config.d.ts +28 -0
- package/avatar/index.d.ts +12 -0
- package/checkbox/README.md +3 -0
- package/checkbox/checkbox/checkbox.directive.d.ts +89 -0
- package/checkbox/checkbox/checkbox.token.d.ts +15 -0
- package/checkbox/checkbox-indicator/checkbox-indicator.directive.d.ts +19 -0
- package/checkbox/checkbox-indicator/checkbox-indicator.token.d.ts +15 -0
- package/checkbox/checkbox-input/checkbox-input.directive.d.ts +10 -0
- package/checkbox/checkbox-label/checkbox-label.directive.d.ts +9 -0
- package/checkbox/index.d.ts +13 -0
- package/esm2022/a11y/index.mjs +9 -0
- package/esm2022/a11y/ng-primitives-a11y.mjs +5 -0
- package/esm2022/a11y/visually-hidden/visually-hidden.directive.mjs +25 -0
- package/esm2022/accordion/accordion/accordion.directive.mjs +90 -0
- package/esm2022/accordion/accordion/accordion.token.mjs +17 -0
- package/esm2022/accordion/accordion-content/accordion-content.directive.mjs +55 -0
- package/esm2022/accordion/accordion-content/accordion-content.token.mjs +17 -0
- package/esm2022/accordion/accordion-item/accordion-item.directive.mjs +64 -0
- package/esm2022/accordion/accordion-item/accordion-item.token.mjs +17 -0
- package/esm2022/accordion/accordion-trigger/accordion-trigger.directive.mjs +58 -0
- package/esm2022/accordion/accordion-trigger/accordion-trigger.token.mjs +17 -0
- package/esm2022/accordion/config/accordion.config.mjs +35 -0
- package/esm2022/accordion/index.mjs +17 -0
- package/esm2022/accordion/ng-primitives-accordion.mjs +5 -0
- package/esm2022/avatar/avatar/avatar.directive.mjs +45 -0
- package/esm2022/avatar/avatar/avatar.token.mjs +17 -0
- package/esm2022/avatar/avatar-fallback/avatar-fallback.directive.mjs +61 -0
- package/esm2022/avatar/avatar-image/avatar-image.directive.mjs +64 -0
- package/esm2022/avatar/config/avatar.config.mjs +33 -0
- package/esm2022/avatar/index.mjs +13 -0
- package/esm2022/avatar/ng-primitives-avatar.mjs +5 -0
- package/esm2022/checkbox/checkbox/checkbox.directive.mjs +141 -0
- package/esm2022/checkbox/checkbox/checkbox.token.mjs +17 -0
- package/esm2022/checkbox/checkbox-indicator/checkbox-indicator.directive.mjs +51 -0
- package/esm2022/checkbox/checkbox-indicator/checkbox-indicator.token.mjs +17 -0
- package/esm2022/checkbox/checkbox-input/checkbox-input.directive.mjs +40 -0
- package/esm2022/checkbox/checkbox-label/checkbox-label.directive.mjs +32 -0
- package/esm2022/checkbox/index.mjs +14 -0
- package/esm2022/checkbox/ng-primitives-checkbox.mjs +5 -0
- package/esm2022/index.mjs +10 -0
- package/esm2022/ng-primitives.mjs +5 -0
- package/esm2022/progress/index.mjs +10 -0
- package/esm2022/progress/ng-primitives-progress.mjs +5 -0
- package/esm2022/progress/progress/progress.directive.mjs +60 -0
- package/esm2022/progress/progress/progress.token.mjs +16 -0
- package/esm2022/progress/progress-indicator/progress-indicator.directive.mjs +33 -0
- package/esm2022/radio/index.mjs +13 -0
- package/esm2022/radio/ng-primitives-radio.mjs +5 -0
- package/esm2022/radio/radio-group/radio-group.directive.mjs +100 -0
- package/esm2022/radio/radio-group/radio-group.token.mjs +17 -0
- package/esm2022/radio/radio-indicator/radio-indicator.directive.mjs +41 -0
- package/esm2022/radio/radio-item/radio-item.directive.mjs +68 -0
- package/esm2022/radio/radio-item/radio-item.token.mjs +17 -0
- package/esm2022/resize/index.mjs +10 -0
- package/esm2022/resize/ng-primitives-resize.mjs +5 -0
- package/esm2022/resize/resize/resize.directive.mjs +49 -0
- package/esm2022/resize/utils/resize.mjs +41 -0
- package/esm2022/roving-focus/index.mjs +12 -0
- package/esm2022/roving-focus/ng-primitives-roving-focus.mjs +5 -0
- package/esm2022/roving-focus/roving-focus-group/roving-focus-group.directive.mjs +244 -0
- package/esm2022/roving-focus/roving-focus-group/roving-focus-group.token.mjs +17 -0
- package/esm2022/roving-focus/roving-focus-item/roving-focus-item.directive.mjs +98 -0
- package/esm2022/roving-focus/roving-focus-item/roving-focus-item.token.mjs +17 -0
- package/esm2022/select/index.mjs +16 -0
- package/esm2022/select/ng-primitives-select.mjs +5 -0
- package/esm2022/select/select/select.directive.mjs +54 -0
- package/esm2022/select/select/select.token.mjs +16 -0
- package/esm2022/select/select-button/select-button.directive.mjs +84 -0
- package/esm2022/select/select-button/select-button.token.mjs +16 -0
- package/esm2022/select/select-option/select-option.directive.mjs +90 -0
- package/esm2022/select/select-option/select-option.token.mjs +16 -0
- package/esm2022/select/select-options/select-options.directive.mjs +157 -0
- package/esm2022/select/select-options/select-options.token.mjs +16 -0
- package/esm2022/slider/index.mjs +16 -0
- package/esm2022/slider/ng-primitives-slider.mjs +5 -0
- package/esm2022/slider/slider/slider.directive.mjs +68 -0
- package/esm2022/slider/slider/slider.token.mjs +16 -0
- package/esm2022/slider/slider-range/slider-range.directive.mjs +36 -0
- package/esm2022/slider/slider-range/slider-range.token.mjs +16 -0
- package/esm2022/slider/slider-thumb/slider-thumb.directive.mjs +109 -0
- package/esm2022/slider/slider-thumb/slider-thumb.token.mjs +16 -0
- package/esm2022/slider/slider-track/slider-track.directive.mjs +54 -0
- package/esm2022/slider/slider-track/slider-track.token.mjs +16 -0
- package/esm2022/switch/index.mjs +11 -0
- package/esm2022/switch/ng-primitives-switch.mjs +5 -0
- package/esm2022/switch/switch/switch.directive.mjs +126 -0
- package/esm2022/switch/switch/switch.token.mjs +17 -0
- package/esm2022/switch/switch-thumb/switch-thumb.directive.mjs +32 -0
- package/esm2022/tabs/config/tabs.config.mjs +35 -0
- package/esm2022/tabs/index.mjs +15 -0
- package/esm2022/tabs/ng-primitives-tabs.mjs +5 -0
- package/esm2022/tabs/tab-button/tab-button.directive.mjs +84 -0
- package/esm2022/tabs/tab-list/tab-list.directive.mjs +34 -0
- package/esm2022/tabs/tab-panel/tab-panel.directive.mjs +62 -0
- package/esm2022/tabs/tab-panel/tab-panel.token.mjs +17 -0
- package/esm2022/tabs/tabset/tabset.directive.mjs +91 -0
- package/esm2022/tabs/tabset/tabset.token.mjs +17 -0
- package/esm2022/toggle/index.mjs +9 -0
- package/esm2022/toggle/ng-primitives-toggle.mjs +5 -0
- package/esm2022/toggle/toggle/toggle.directive.mjs +48 -0
- package/esm2022/tooltip/config/tooltip.config.mjs +38 -0
- package/esm2022/tooltip/index.mjs +13 -0
- package/esm2022/tooltip/ng-primitives-tooltip.mjs +5 -0
- package/esm2022/tooltip/tooltip/tooltip.directive.mjs +57 -0
- package/esm2022/tooltip/tooltip/tooltip.token.mjs +16 -0
- package/esm2022/tooltip/tooltip-trigger/tooltip-trigger.directive.mjs +190 -0
- package/esm2022/tooltip/tooltip-trigger/tooltip-trigger.token.mjs +23 -0
- package/esm2022/utils/helpers/disposables.mjs +72 -0
- package/esm2022/utils/helpers/focus-manager.mjs +28 -0
- package/esm2022/utils/helpers/unique-id.mjs +22 -0
- package/esm2022/utils/hover/hover.directive.mjs +183 -0
- package/esm2022/utils/hover/hover.token.mjs +16 -0
- package/esm2022/utils/index.mjs +14 -0
- package/esm2022/utils/ng-primitives-utils.mjs +5 -0
- package/esm2022/utils/ui/dimensions.mjs +40 -0
- package/fesm2022/ng-primitives-a11y.mjs +40 -0
- package/fesm2022/ng-primitives-a11y.mjs.map +1 -0
- package/fesm2022/ng-primitives-accordion.mjs +361 -0
- package/fesm2022/ng-primitives-accordion.mjs.map +1 -0
- package/fesm2022/ng-primitives-avatar.mjs +223 -0
- package/fesm2022/ng-primitives-avatar.mjs.map +1 -0
- package/fesm2022/ng-primitives-checkbox.mjs +299 -0
- package/fesm2022/ng-primitives-checkbox.mjs.map +1 -0
- package/fesm2022/ng-primitives-progress.mjs +119 -0
- package/fesm2022/ng-primitives-progress.mjs.map +1 -0
- package/fesm2022/ng-primitives-radio.mjs +245 -0
- package/fesm2022/ng-primitives-radio.mjs.map +1 -0
- package/fesm2022/ng-primitives-resize.mjs +104 -0
- package/fesm2022/ng-primitives-resize.mjs.map +1 -0
- package/fesm2022/ng-primitives-roving-focus.mjs +384 -0
- package/fesm2022/ng-primitives-roving-focus.mjs.map +1 -0
- package/fesm2022/ng-primitives-select.mjs +442 -0
- package/fesm2022/ng-primitives-select.mjs.map +1 -0
- package/fesm2022/ng-primitives-slider.mjs +328 -0
- package/fesm2022/ng-primitives-slider.mjs.map +1 -0
- package/fesm2022/ng-primitives-switch.mjs +185 -0
- package/fesm2022/ng-primitives-switch.mjs.map +1 -0
- package/fesm2022/ng-primitives-tabs.mjs +337 -0
- package/fesm2022/ng-primitives-tabs.mjs.map +1 -0
- package/fesm2022/ng-primitives-toggle.mjs +63 -0
- package/fesm2022/ng-primitives-toggle.mjs.map +1 -0
- package/fesm2022/ng-primitives-tooltip.mjs +330 -0
- package/fesm2022/ng-primitives-tooltip.mjs.map +1 -0
- package/fesm2022/ng-primitives-utils.mjs +370 -0
- package/fesm2022/ng-primitives-utils.mjs.map +1 -0
- package/fesm2022/ng-primitives.mjs +14 -0
- package/fesm2022/ng-primitives.mjs.map +1 -0
- package/index.d.ts +9 -0
- package/package.json +120 -0
- package/progress/README.md +3 -0
- package/progress/index.d.ts +9 -0
- package/progress/progress/progress.directive.d.ts +40 -0
- package/progress/progress/progress.token.d.ts +14 -0
- package/progress/progress-indicator/progress-indicator.directive.d.ts +9 -0
- package/radio/README.md +3 -0
- package/radio/index.d.ts +12 -0
- package/radio/radio-group/radio-group.directive.d.ts +71 -0
- package/radio/radio-group/radio-group.token.d.ts +15 -0
- package/radio/radio-indicator/radio-indicator.directive.d.ts +17 -0
- package/radio/radio-item/radio-item.directive.d.ts +41 -0
- package/radio/radio-item/radio-item.token.d.ts +15 -0
- package/resize/README.md +3 -0
- package/resize/index.d.ts +9 -0
- package/resize/resize/resize.directive.d.ts +31 -0
- package/resize/utils/resize.d.ts +18 -0
- package/roving-focus/README.md +3 -0
- package/roving-focus/index.d.ts +11 -0
- package/roving-focus/roving-focus-group/roving-focus-group.directive.d.ts +94 -0
- package/roving-focus/roving-focus-group/roving-focus-group.token.d.ts +15 -0
- package/roving-focus/roving-focus-item/roving-focus-item.directive.d.ts +57 -0
- package/roving-focus/roving-focus-item/roving-focus-item.token.d.ts +15 -0
- package/select/README.md +3 -0
- package/select/index.d.ts +15 -0
- package/select/select/select.directive.d.ts +35 -0
- package/select/select/select.token.d.ts +14 -0
- package/select/select-button/select-button.directive.d.ts +51 -0
- package/select/select-button/select-button.token.d.ts +14 -0
- package/select/select-option/select-option.directive.d.ts +57 -0
- package/select/select-option/select-option.token.d.ts +14 -0
- package/select/select-options/select-options.directive.d.ts +65 -0
- package/select/select-options/select-options.token.d.ts +14 -0
- package/slider/README.md +3 -0
- package/slider/index.d.ts +15 -0
- package/slider/slider/slider.directive.d.ts +45 -0
- package/slider/slider/slider.token.d.ts +14 -0
- package/slider/slider-range/slider-range.directive.d.ts +9 -0
- package/slider/slider-range/slider-range.token.d.ts +14 -0
- package/slider/slider-thumb/slider-thumb.directive.d.ts +21 -0
- package/slider/slider-thumb/slider-thumb.token.d.ts +14 -0
- package/slider/slider-track/slider-track.directive.d.ts +26 -0
- package/slider/slider-track/slider-track.token.d.ts +14 -0
- package/switch/README.md +3 -0
- package/switch/index.d.ts +10 -0
- package/switch/switch/switch.directive.d.ts +82 -0
- package/switch/switch/switch.token.d.ts +15 -0
- package/switch/switch-thumb/switch-thumb.directive.d.ts +9 -0
- package/tabs/README.md +3 -0
- package/tabs/config/tabs.config.d.ts +38 -0
- package/tabs/index.d.ts +14 -0
- package/tabs/tab-button/tab-button.directive.d.ts +54 -0
- package/tabs/tab-list/tab-list.directive.d.ts +9 -0
- package/tabs/tab-panel/tab-panel.directive.d.ts +32 -0
- package/tabs/tab-panel/tab-panel.token.d.ts +15 -0
- package/tabs/tabset/tabset.directive.d.ts +53 -0
- package/tabs/tabset/tabset.token.d.ts +15 -0
- package/toggle/README.md +3 -0
- package/toggle/index.d.ts +8 -0
- package/toggle/toggle/toggle.directive.d.ts +27 -0
- package/tooltip/README.md +3 -0
- package/tooltip/config/tooltip.config.d.ts +54 -0
- package/tooltip/index.d.ts +12 -0
- package/tooltip/tooltip/tooltip.directive.d.ts +30 -0
- package/tooltip/tooltip/tooltip.token.d.ts +14 -0
- package/tooltip/tooltip-trigger/tooltip-trigger.directive.d.ts +111 -0
- package/tooltip/tooltip-trigger/tooltip-trigger.token.d.ts +22 -0
- package/utils/README.md +3 -0
- package/utils/helpers/disposables.d.ts +40 -0
- package/utils/helpers/focus-manager.d.ts +19 -0
- package/utils/helpers/unique-id.d.ts +13 -0
- package/utils/hover/hover.directive.d.ts +62 -0
- package/utils/hover/hover.token.d.ts +14 -0
- package/utils/index.d.ts +13 -0
- package/utils/ui/dimensions.d.ts +9 -0
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { InjectionToken, inject, ElementRef, ViewContainerRef, Injector, input, model, booleanAttribute, numberAttribute, computed, signal, effect, Directive, isDevMode } from '@angular/core';
|
|
3
|
+
import { TemplatePortal, DomPortalOutlet } from '@angular/cdk/portal';
|
|
4
|
+
import { offset, shift, flip, autoUpdate, computePosition } from '@floating-ui/dom';
|
|
5
|
+
import { injectDisposables } from 'ng-primitives/utils';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Copyright © 2024 Angular Primitives.
|
|
9
|
+
* https://github.com/ng-primitives/ng-primitives
|
|
10
|
+
*
|
|
11
|
+
* This source code is licensed under the CC BY-ND 4.0 license found in the
|
|
12
|
+
* LICENSE file in the root directory of this source tree.
|
|
13
|
+
*/
|
|
14
|
+
const defaultTooltipConfig = {
|
|
15
|
+
offset: 4,
|
|
16
|
+
placement: 'top',
|
|
17
|
+
showDelay: 0,
|
|
18
|
+
hideDelay: 0,
|
|
19
|
+
flip: true,
|
|
20
|
+
container: document.body,
|
|
21
|
+
};
|
|
22
|
+
const NgpTooltipConfigToken = new InjectionToken('NgpTooltipConfigToken');
|
|
23
|
+
/**
|
|
24
|
+
* Provide the default Tooltip configuration
|
|
25
|
+
* @param config The Tooltip configuration
|
|
26
|
+
* @returns The provider
|
|
27
|
+
*/
|
|
28
|
+
function provideTooltipConfig(config) {
|
|
29
|
+
return [
|
|
30
|
+
{
|
|
31
|
+
provide: NgpTooltipConfigToken,
|
|
32
|
+
useValue: { ...defaultTooltipConfig, ...config },
|
|
33
|
+
},
|
|
34
|
+
];
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Inject the Tooltip configuration
|
|
38
|
+
* @returns The global Tooltip configuration
|
|
39
|
+
*/
|
|
40
|
+
function injectTooltipConfig() {
|
|
41
|
+
return inject(NgpTooltipConfigToken, { optional: true }) ?? defaultTooltipConfig;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Copyright © 2024 Angular Primitives.
|
|
46
|
+
* https://github.com/ng-primitives/ng-primitives
|
|
47
|
+
*
|
|
48
|
+
* This source code is licensed under the CC BY-ND 4.0 license found in the
|
|
49
|
+
* LICENSE file in the root directory of this source tree.
|
|
50
|
+
*/
|
|
51
|
+
const NgpTooltipTriggerToken = new InjectionToken('NgpTooltipTriggerToken');
|
|
52
|
+
/**
|
|
53
|
+
* Inject the TooltipTrigger directive instance
|
|
54
|
+
*/
|
|
55
|
+
function injectTooltipTrigger() {
|
|
56
|
+
return inject(NgpTooltipTriggerToken);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Provides the TooltipTrigger directive instance
|
|
60
|
+
* @param trigger
|
|
61
|
+
*/
|
|
62
|
+
function provideTooltipTrigger(trigger) {
|
|
63
|
+
return { provide: NgpTooltipTriggerToken, useValue: trigger };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
class NgpTooltipTrigger {
|
|
67
|
+
constructor() {
|
|
68
|
+
/**
|
|
69
|
+
* Access the trigger element
|
|
70
|
+
*/
|
|
71
|
+
this.trigger = inject((ElementRef));
|
|
72
|
+
/**
|
|
73
|
+
* Access the view container ref.
|
|
74
|
+
*/
|
|
75
|
+
this.viewContainerRef = inject(ViewContainerRef);
|
|
76
|
+
/**
|
|
77
|
+
* Access the injector.
|
|
78
|
+
*/
|
|
79
|
+
this.injector = inject(Injector);
|
|
80
|
+
/**
|
|
81
|
+
* Access the global tooltip configuration.
|
|
82
|
+
*/
|
|
83
|
+
this.config = injectTooltipConfig();
|
|
84
|
+
/**
|
|
85
|
+
* Access the disposable utilities
|
|
86
|
+
*/
|
|
87
|
+
this.disposables = injectDisposables();
|
|
88
|
+
/**
|
|
89
|
+
* Access the tooltip template ref.
|
|
90
|
+
*/
|
|
91
|
+
this.tooltip = input.required({
|
|
92
|
+
alias: 'ngpTooltipTrigger',
|
|
93
|
+
});
|
|
94
|
+
/**
|
|
95
|
+
* The open state of the tooltip.
|
|
96
|
+
* @default false
|
|
97
|
+
*/
|
|
98
|
+
this.open = model(false, {
|
|
99
|
+
alias: 'ngpTooltipTriggerOpen',
|
|
100
|
+
});
|
|
101
|
+
/**
|
|
102
|
+
* Define if the trigger should be disabled.
|
|
103
|
+
* @default false
|
|
104
|
+
*/
|
|
105
|
+
this.disabled = input(false, {
|
|
106
|
+
alias: 'ngpTooltipTriggerDisabled',
|
|
107
|
+
transform: booleanAttribute,
|
|
108
|
+
});
|
|
109
|
+
/**
|
|
110
|
+
* Define the placement of the tooltip relative to the trigger.
|
|
111
|
+
* @default 'top'
|
|
112
|
+
*/
|
|
113
|
+
this.placement = input(this.config.placement, {
|
|
114
|
+
alias: 'ngpTooltipTriggerPlacement',
|
|
115
|
+
});
|
|
116
|
+
/**
|
|
117
|
+
* Define the offset of the tooltip relative to the trigger.
|
|
118
|
+
* @default 0
|
|
119
|
+
*/
|
|
120
|
+
this.offset = input(this.config.offset, {
|
|
121
|
+
alias: 'ngpTooltipTriggerOffset',
|
|
122
|
+
transform: numberAttribute,
|
|
123
|
+
});
|
|
124
|
+
/**
|
|
125
|
+
* Define the delay before the tooltip is displayed.
|
|
126
|
+
* @default 0
|
|
127
|
+
*/
|
|
128
|
+
this.showDelay = input(this.config.showDelay, {
|
|
129
|
+
alias: 'ngpTooltipTriggerShowDelay',
|
|
130
|
+
transform: numberAttribute,
|
|
131
|
+
});
|
|
132
|
+
/**
|
|
133
|
+
* Define the delay before the tooltip is hidden.
|
|
134
|
+
* @default 0
|
|
135
|
+
*/
|
|
136
|
+
this.hideDelay = input(this.config.hideDelay, {
|
|
137
|
+
alias: 'ngpTooltipTriggerHideDelay',
|
|
138
|
+
transform: numberAttribute,
|
|
139
|
+
});
|
|
140
|
+
/**
|
|
141
|
+
* Define whether the tooltip should flip when there is not enough space for the tooltip.
|
|
142
|
+
* @default true
|
|
143
|
+
*/
|
|
144
|
+
this.flip = input(this.config.flip, {
|
|
145
|
+
alias: 'ngpTooltipTriggerFlip',
|
|
146
|
+
transform: booleanAttribute,
|
|
147
|
+
});
|
|
148
|
+
/**
|
|
149
|
+
* Define the container in which the tooltip should be attached.
|
|
150
|
+
* @default document.body
|
|
151
|
+
*/
|
|
152
|
+
this.container = input(this.config.container, {
|
|
153
|
+
alias: 'ngpTooltipTriggerContainer',
|
|
154
|
+
});
|
|
155
|
+
/**
|
|
156
|
+
* Store the tooltip view ref.
|
|
157
|
+
*/
|
|
158
|
+
this.viewRef = null;
|
|
159
|
+
/**
|
|
160
|
+
* Derive the tooltip middleware from the provided configuration.
|
|
161
|
+
*/
|
|
162
|
+
this.middleware = computed(() => {
|
|
163
|
+
const middleware = [offset(this.offset()), shift()];
|
|
164
|
+
if (this.flip()) {
|
|
165
|
+
middleware.push(flip());
|
|
166
|
+
}
|
|
167
|
+
return middleware;
|
|
168
|
+
});
|
|
169
|
+
/**
|
|
170
|
+
* Store the computed position of the tooltip.
|
|
171
|
+
* @internal
|
|
172
|
+
*/
|
|
173
|
+
this.position = signal({
|
|
174
|
+
x: 0,
|
|
175
|
+
y: 0,
|
|
176
|
+
});
|
|
177
|
+
/**
|
|
178
|
+
* Store the state of the tooltip.
|
|
179
|
+
* @internal
|
|
180
|
+
*/
|
|
181
|
+
this.state = signal('closed');
|
|
182
|
+
// any time the open state changes then show or hide the tooltip
|
|
183
|
+
effect(() => (this.open() ? this.show() : this.hide()), { allowSignalWrites: true });
|
|
184
|
+
}
|
|
185
|
+
ngOnDestroy() {
|
|
186
|
+
this.destroyTooltip();
|
|
187
|
+
}
|
|
188
|
+
show() {
|
|
189
|
+
// if the trigger is disabled or the tooltip is already open then do not show the tooltip
|
|
190
|
+
if (this.disabled() || this.state() === 'open' || this.state() === 'opening') {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
this.state.set('opening');
|
|
194
|
+
this.disposables.setTimeout(() => this.createTooltip(), this.showDelay());
|
|
195
|
+
}
|
|
196
|
+
hide() {
|
|
197
|
+
// if the trigger is disabled or the tooltip is already closed then do not hide the tooltip
|
|
198
|
+
if (this.disabled() || this.state() === 'closed' || this.state() === 'closing') {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
this.state.set('closing');
|
|
202
|
+
this.disposables.setTimeout(() => this.destroyTooltip(), this.hideDelay());
|
|
203
|
+
}
|
|
204
|
+
createTooltip() {
|
|
205
|
+
const portal = new TemplatePortal(this.tooltip(), this.viewContainerRef, undefined, this.injector);
|
|
206
|
+
const domOutlet = new DomPortalOutlet(this.container(), undefined, undefined, Injector.create({
|
|
207
|
+
parent: this.injector,
|
|
208
|
+
providers: [provideTooltipTrigger(this)],
|
|
209
|
+
}));
|
|
210
|
+
this.viewRef = domOutlet.attach(portal);
|
|
211
|
+
this.viewRef.detectChanges();
|
|
212
|
+
const outletElement = this.viewRef.rootNodes[0];
|
|
213
|
+
this.dispose = autoUpdate(this.trigger.nativeElement, outletElement, async () => {
|
|
214
|
+
const position = await computePosition(this.trigger.nativeElement, outletElement, {
|
|
215
|
+
placement: this.placement(),
|
|
216
|
+
middleware: this.middleware(),
|
|
217
|
+
});
|
|
218
|
+
this.position.set({ x: position.x, y: position.y });
|
|
219
|
+
});
|
|
220
|
+
this.state.set('open');
|
|
221
|
+
}
|
|
222
|
+
destroyTooltip() {
|
|
223
|
+
this.viewRef?.destroy();
|
|
224
|
+
this.viewRef = null;
|
|
225
|
+
this.dispose?.();
|
|
226
|
+
this.state.set('closed');
|
|
227
|
+
}
|
|
228
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: NgpTooltipTrigger, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
229
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "18.0.2", type: NgpTooltipTrigger, isStandalone: true, selector: "[ngpTooltipTrigger]", inputs: { tooltip: { classPropertyName: "tooltip", publicName: "ngpTooltipTrigger", isSignal: true, isRequired: true, transformFunction: null }, open: { classPropertyName: "open", publicName: "ngpTooltipTriggerOpen", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "ngpTooltipTriggerDisabled", isSignal: true, isRequired: false, transformFunction: null }, placement: { classPropertyName: "placement", publicName: "ngpTooltipTriggerPlacement", isSignal: true, isRequired: false, transformFunction: null }, offset: { classPropertyName: "offset", publicName: "ngpTooltipTriggerOffset", isSignal: true, isRequired: false, transformFunction: null }, showDelay: { classPropertyName: "showDelay", publicName: "ngpTooltipTriggerShowDelay", isSignal: true, isRequired: false, transformFunction: null }, hideDelay: { classPropertyName: "hideDelay", publicName: "ngpTooltipTriggerHideDelay", isSignal: true, isRequired: false, transformFunction: null }, flip: { classPropertyName: "flip", publicName: "ngpTooltipTriggerFlip", isSignal: true, isRequired: false, transformFunction: null }, container: { classPropertyName: "container", publicName: "ngpTooltipTriggerContainer", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { open: "ngpTooltipTriggerOpenChange" }, host: { listeners: { "mouseenter": "open.set(true)", "mouseleave": "open.set(false)", "focus": "open.set(true)", "blur": "open.set(false)" }, properties: { "attr.data-state": "state()", "attr.data-disabled": "disabled()" } }, providers: [{ provide: NgpTooltipTriggerToken, useExisting: NgpTooltipTrigger }], exportAs: ["ngpTooltipTrigger"], ngImport: i0 }); }
|
|
230
|
+
}
|
|
231
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: NgpTooltipTrigger, decorators: [{
|
|
232
|
+
type: Directive,
|
|
233
|
+
args: [{
|
|
234
|
+
standalone: true,
|
|
235
|
+
selector: '[ngpTooltipTrigger]',
|
|
236
|
+
exportAs: 'ngpTooltipTrigger',
|
|
237
|
+
providers: [{ provide: NgpTooltipTriggerToken, useExisting: NgpTooltipTrigger }],
|
|
238
|
+
host: {
|
|
239
|
+
'[attr.data-state]': 'state()',
|
|
240
|
+
'[attr.data-disabled]': 'disabled()',
|
|
241
|
+
'(mouseenter)': 'open.set(true)',
|
|
242
|
+
'(mouseleave)': 'open.set(false)',
|
|
243
|
+
'(focus)': 'open.set(true)',
|
|
244
|
+
'(blur)': 'open.set(false)',
|
|
245
|
+
},
|
|
246
|
+
}]
|
|
247
|
+
}], ctorParameters: () => [] });
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Copyright © 2024 Angular Primitives.
|
|
251
|
+
* https://github.com/ng-primitives/ng-primitives
|
|
252
|
+
*
|
|
253
|
+
* This source code is licensed under the CC BY-ND 4.0 license found in the
|
|
254
|
+
* LICENSE file in the root directory of this source tree.
|
|
255
|
+
*/
|
|
256
|
+
const NgpTooltipToken = new InjectionToken('NgpTooltipToken');
|
|
257
|
+
/**
|
|
258
|
+
* Inject the Tooltip directive instance
|
|
259
|
+
*/
|
|
260
|
+
function injectTooltip() {
|
|
261
|
+
return inject(NgpTooltipToken);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Copyright © 2024 Angular Primitives.
|
|
266
|
+
* https://github.com/ng-primitives/ng-primitives
|
|
267
|
+
*
|
|
268
|
+
* This source code is licensed under the CC BY-ND 4.0 license found in the
|
|
269
|
+
* LICENSE file in the root directory of this source tree.
|
|
270
|
+
*/
|
|
271
|
+
class NgpTooltip {
|
|
272
|
+
constructor() {
|
|
273
|
+
/**
|
|
274
|
+
* Access the tooltip element.
|
|
275
|
+
*/
|
|
276
|
+
this.tooltip = inject((ElementRef));
|
|
277
|
+
/**
|
|
278
|
+
* Access the trigger instance.
|
|
279
|
+
*/
|
|
280
|
+
this.trigger = injectTooltipTrigger();
|
|
281
|
+
/**
|
|
282
|
+
* Compute the x position of the tooltip.
|
|
283
|
+
*/
|
|
284
|
+
this.x = computed(() => this.trigger.position().x);
|
|
285
|
+
/**
|
|
286
|
+
* Compute the y position of the tooltip.
|
|
287
|
+
*/
|
|
288
|
+
this.y = computed(() => this.trigger.position().y);
|
|
289
|
+
}
|
|
290
|
+
ngOnInit() {
|
|
291
|
+
// if the element does not have a fixed position then throw a warning in dev mode
|
|
292
|
+
if (isDevMode()) {
|
|
293
|
+
const { position } = getComputedStyle(this.tooltip.nativeElement);
|
|
294
|
+
if (position !== 'absolute') {
|
|
295
|
+
console.warn(`The tooltip element must have an absolute position. The current position is ${position}.`);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: NgpTooltip, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
300
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.0.2", type: NgpTooltip, isStandalone: true, selector: "[ngpTooltip]", host: { attributes: { "role": "tooltip" }, properties: { "style.left.px": "x()", "style.top.px": "y()" } }, providers: [{ provide: NgpTooltipToken, useExisting: NgpTooltip }], exportAs: ["ngpTooltip"], ngImport: i0 }); }
|
|
301
|
+
}
|
|
302
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: NgpTooltip, decorators: [{
|
|
303
|
+
type: Directive,
|
|
304
|
+
args: [{
|
|
305
|
+
standalone: true,
|
|
306
|
+
selector: '[ngpTooltip]',
|
|
307
|
+
exportAs: 'ngpTooltip',
|
|
308
|
+
providers: [{ provide: NgpTooltipToken, useExisting: NgpTooltip }],
|
|
309
|
+
host: {
|
|
310
|
+
role: 'tooltip',
|
|
311
|
+
'[style.left.px]': 'x()',
|
|
312
|
+
'[style.top.px]': 'y()',
|
|
313
|
+
},
|
|
314
|
+
}]
|
|
315
|
+
}] });
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Copyright © 2024 Angular Primitives.
|
|
319
|
+
* https://github.com/ng-primitives/ng-primitives
|
|
320
|
+
*
|
|
321
|
+
* This source code is licensed under the CC BY-ND 4.0 license found in the
|
|
322
|
+
* LICENSE file in the root directory of this source tree.
|
|
323
|
+
*/
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Generated bundle index. Do not edit.
|
|
327
|
+
*/
|
|
328
|
+
|
|
329
|
+
export { NgpTooltip, NgpTooltipToken, NgpTooltipTrigger, NgpTooltipTriggerToken, provideTooltipConfig };
|
|
330
|
+
//# sourceMappingURL=ng-primitives-tooltip.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ng-primitives-tooltip.mjs","sources":["../../../../packages/ng-primitives/tooltip/src/config/tooltip.config.ts","../../../../packages/ng-primitives/tooltip/src/tooltip-trigger/tooltip-trigger.token.ts","../../../../packages/ng-primitives/tooltip/src/tooltip-trigger/tooltip-trigger.directive.ts","../../../../packages/ng-primitives/tooltip/src/tooltip/tooltip.token.ts","../../../../packages/ng-primitives/tooltip/src/tooltip/tooltip.directive.ts","../../../../packages/ng-primitives/tooltip/src/index.ts","../../../../packages/ng-primitives/tooltip/src/ng-primitives-tooltip.ts"],"sourcesContent":["/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the CC BY-ND 4.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { InjectionToken, Provider, inject } from '@angular/core';\nimport { type Placement } from '@floating-ui/dom';\n\nexport interface NgpTooltipConfig {\n /**\n * Define the offset of the tooltip relative to the trigger.\n * @default 4\n */\n offset: number;\n\n /**\n * Define the placement of the tooltip relative to the trigger.\n * @default 'top'\n */\n placement: Placement;\n\n /**\n * Define the delay before the tooltip is shown.\n * @default 0\n */\n showDelay: number;\n\n /**\n * Define the delay before the tooltip is hidden.\n * @default 0\n */\n hideDelay: number;\n\n /**\n * Define whether the tooltip should flip when there is not enough space for the tooltip.\n * @default true\n */\n flip: boolean;\n\n /**\n * Define the container in to which the tooltip should be attached.\n * @default document.body\n */\n container: HTMLElement;\n}\n\nexport const defaultTooltipConfig: NgpTooltipConfig = {\n offset: 4,\n placement: 'top',\n showDelay: 0,\n hideDelay: 0,\n flip: true,\n container: document.body,\n};\n\nexport const NgpTooltipConfigToken = new InjectionToken<NgpTooltipConfig>('NgpTooltipConfigToken');\n\n/**\n * Provide the default Tooltip configuration\n * @param config The Tooltip configuration\n * @returns The provider\n */\nexport function provideTooltipConfig(config: Partial<NgpTooltipConfig>): Provider[] {\n return [\n {\n provide: NgpTooltipConfigToken,\n useValue: { ...defaultTooltipConfig, ...config },\n },\n ];\n}\n\n/**\n * Inject the Tooltip configuration\n * @returns The global Tooltip configuration\n */\nexport function injectTooltipConfig(): NgpTooltipConfig {\n return inject(NgpTooltipConfigToken, { optional: true }) ?? defaultTooltipConfig;\n}\n","/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the CC BY-ND 4.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { InjectionToken, inject } from '@angular/core';\nimport type { NgpTooltipTrigger } from './tooltip-trigger.directive';\n\nexport const NgpTooltipTriggerToken = new InjectionToken<NgpTooltipTrigger>(\n 'NgpTooltipTriggerToken',\n);\n\n/**\n * Inject the TooltipTrigger directive instance\n */\nexport function injectTooltipTrigger(): NgpTooltipTrigger {\n return inject(NgpTooltipTriggerToken);\n}\n\n/**\n * Provides the TooltipTrigger directive instance\n * @param trigger\n */\nexport function provideTooltipTrigger(trigger: NgpTooltipTrigger) {\n return { provide: NgpTooltipTriggerToken, useValue: trigger };\n}\n","/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the CC BY-ND 4.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { BooleanInput, NumberInput } from '@angular/cdk/coercion';\nimport { DomPortalOutlet, TemplatePortal } from '@angular/cdk/portal';\nimport {\n Directive,\n ElementRef,\n EmbeddedViewRef,\n Injector,\n OnDestroy,\n TemplateRef,\n ViewContainerRef,\n booleanAttribute,\n computed,\n effect,\n inject,\n input,\n model,\n numberAttribute,\n signal,\n} from '@angular/core';\nimport {\n Middleware,\n Placement,\n autoUpdate,\n computePosition,\n flip,\n offset,\n shift,\n} from '@floating-ui/dom';\nimport { injectDisposables } from 'ng-primitives/utils';\nimport { injectTooltipConfig } from '../config/tooltip.config';\nimport { NgpTooltipTriggerToken, provideTooltipTrigger } from './tooltip-trigger.token';\n\n@Directive({\n standalone: true,\n selector: '[ngpTooltipTrigger]',\n exportAs: 'ngpTooltipTrigger',\n providers: [{ provide: NgpTooltipTriggerToken, useExisting: NgpTooltipTrigger }],\n host: {\n '[attr.data-state]': 'state()',\n '[attr.data-disabled]': 'disabled()',\n '(mouseenter)': 'open.set(true)',\n '(mouseleave)': 'open.set(false)',\n '(focus)': 'open.set(true)',\n '(blur)': 'open.set(false)',\n },\n})\nexport class NgpTooltipTrigger implements OnDestroy {\n /**\n * Access the trigger element\n */\n private readonly trigger = inject(ElementRef<HTMLElement>);\n\n /**\n * Access the view container ref.\n */\n private readonly viewContainerRef = inject(ViewContainerRef);\n\n /**\n * Access the injector.\n */\n private readonly injector = inject(Injector);\n\n /**\n * Access the global tooltip configuration.\n */\n private readonly config = injectTooltipConfig();\n\n /**\n * Access the disposable utilities\n */\n private readonly disposables = injectDisposables();\n\n /**\n * Access the tooltip template ref.\n */\n readonly tooltip = input.required<TemplateRef<void>>({\n alias: 'ngpTooltipTrigger',\n });\n\n /**\n * The open state of the tooltip.\n * @default false\n */\n readonly open = model<boolean>(false, {\n alias: 'ngpTooltipTriggerOpen',\n });\n\n /**\n * Define if the trigger should be disabled.\n * @default false\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n alias: 'ngpTooltipTriggerDisabled',\n transform: booleanAttribute,\n });\n\n /**\n * Define the placement of the tooltip relative to the trigger.\n * @default 'top'\n */\n readonly placement = input<Placement>(this.config.placement, {\n alias: 'ngpTooltipTriggerPlacement',\n });\n\n /**\n * Define the offset of the tooltip relative to the trigger.\n * @default 0\n */\n readonly offset = input<number, NumberInput>(this.config.offset, {\n alias: 'ngpTooltipTriggerOffset',\n transform: numberAttribute,\n });\n\n /**\n * Define the delay before the tooltip is displayed.\n * @default 0\n */\n readonly showDelay = input<number, NumberInput>(this.config.showDelay, {\n alias: 'ngpTooltipTriggerShowDelay',\n transform: numberAttribute,\n });\n\n /**\n * Define the delay before the tooltip is hidden.\n * @default 0\n */\n readonly hideDelay = input<number, NumberInput>(this.config.hideDelay, {\n alias: 'ngpTooltipTriggerHideDelay',\n transform: numberAttribute,\n });\n\n /**\n * Define whether the tooltip should flip when there is not enough space for the tooltip.\n * @default true\n */\n readonly flip = input<boolean, BooleanInput>(this.config.flip, {\n alias: 'ngpTooltipTriggerFlip',\n transform: booleanAttribute,\n });\n\n /**\n * Define the container in which the tooltip should be attached.\n * @default document.body\n */\n readonly container = input<HTMLElement>(this.config.container, {\n alias: 'ngpTooltipTriggerContainer',\n });\n\n /**\n * Store the tooltip view ref.\n */\n private viewRef: EmbeddedViewRef<void> | null = null;\n\n /**\n * Derive the tooltip middleware from the provided configuration.\n */\n private readonly middleware = computed(() => {\n const middleware: Middleware[] = [offset(this.offset()), shift()];\n\n if (this.flip()) {\n middleware.push(flip());\n }\n\n return middleware;\n });\n\n /**\n * Store the computed position of the tooltip.\n * @internal\n */\n readonly position = signal<{ x: number; y: number }>({\n x: 0,\n y: 0,\n });\n\n /**\n * Store the state of the tooltip.\n * @internal\n */\n readonly state = signal<TooltipState>('closed');\n\n /**\n * The dispose function to stop computing the position of the tooltip.\n */\n private dispose?: () => void;\n\n constructor() {\n // any time the open state changes then show or hide the tooltip\n effect(() => (this.open() ? this.show() : this.hide()), { allowSignalWrites: true });\n }\n\n ngOnDestroy(): void {\n this.destroyTooltip();\n }\n\n private show(): void {\n // if the trigger is disabled or the tooltip is already open then do not show the tooltip\n if (this.disabled() || this.state() === 'open' || this.state() === 'opening') {\n return;\n }\n\n this.state.set('opening');\n this.disposables.setTimeout(() => this.createTooltip(), this.showDelay());\n }\n\n private hide(): void {\n // if the trigger is disabled or the tooltip is already closed then do not hide the tooltip\n if (this.disabled() || this.state() === 'closed' || this.state() === 'closing') {\n return;\n }\n\n this.state.set('closing');\n this.disposables.setTimeout(() => this.destroyTooltip(), this.hideDelay());\n }\n\n private createTooltip(): void {\n const portal = new TemplatePortal(\n this.tooltip(),\n this.viewContainerRef,\n undefined,\n this.injector,\n );\n\n const domOutlet = new DomPortalOutlet(\n this.container(),\n undefined,\n undefined,\n Injector.create({\n parent: this.injector,\n providers: [provideTooltipTrigger(this)],\n }),\n );\n\n this.viewRef = domOutlet.attach(portal);\n this.viewRef.detectChanges();\n\n const outletElement = this.viewRef.rootNodes[0];\n\n this.dispose = autoUpdate(this.trigger.nativeElement, outletElement, async () => {\n const position = await computePosition(this.trigger.nativeElement, outletElement, {\n placement: this.placement(),\n middleware: this.middleware(),\n });\n\n this.position.set({ x: position.x, y: position.y });\n });\n\n this.state.set('open');\n }\n\n private destroyTooltip(): void {\n this.viewRef?.destroy();\n this.viewRef = null;\n this.dispose?.();\n this.state.set('closed');\n }\n}\n\nexport type TooltipState = 'closed' | 'opening' | 'open' | 'closing';\n","/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the CC BY-ND 4.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { InjectionToken, inject } from '@angular/core';\nimport type { NgpTooltip } from './tooltip.directive';\n\nexport const NgpTooltipToken = new InjectionToken<NgpTooltip>('NgpTooltipToken');\n\n/**\n * Inject the Tooltip directive instance\n */\nexport function injectTooltip(): NgpTooltip {\n return inject(NgpTooltipToken);\n}\n","/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the CC BY-ND 4.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { Directive, ElementRef, OnInit, computed, inject, isDevMode } from '@angular/core';\nimport { injectTooltipTrigger } from '../tooltip-trigger/tooltip-trigger.token';\nimport { NgpTooltipToken } from './tooltip.token';\n\n@Directive({\n standalone: true,\n selector: '[ngpTooltip]',\n exportAs: 'ngpTooltip',\n providers: [{ provide: NgpTooltipToken, useExisting: NgpTooltip }],\n host: {\n role: 'tooltip',\n '[style.left.px]': 'x()',\n '[style.top.px]': 'y()',\n },\n})\nexport class NgpTooltip implements OnInit {\n /**\n * Access the tooltip element.\n */\n private readonly tooltip = inject(ElementRef<HTMLElement>);\n\n /**\n * Access the trigger instance.\n */\n private readonly trigger = injectTooltipTrigger();\n\n /**\n * Compute the x position of the tooltip.\n */\n protected readonly x = computed(() => this.trigger.position().x);\n\n /**\n * Compute the y position of the tooltip.\n */\n protected readonly y = computed(() => this.trigger.position().y);\n\n ngOnInit(): void {\n // if the element does not have a fixed position then throw a warning in dev mode\n if (isDevMode()) {\n const { position } = getComputedStyle(this.tooltip.nativeElement);\n\n if (position !== 'absolute') {\n console.warn(\n `The tooltip element must have an absolute position. The current position is ${position}.`,\n );\n }\n }\n }\n}\n","/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the CC BY-ND 4.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nexport { NgpTooltipConfig, provideTooltipConfig } from './config/tooltip.config';\nexport { NgpTooltipTrigger } from './tooltip-trigger/tooltip-trigger.directive';\nexport { NgpTooltipTriggerToken } from './tooltip-trigger/tooltip-trigger.token';\nexport { NgpTooltip } from './tooltip/tooltip.directive';\nexport { NgpTooltipToken } from './tooltip/tooltip.token';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;AAAA;;;;;;AAMG;AA0CI,MAAM,oBAAoB,GAAqB;AACpD,IAAA,MAAM,EAAE,CAAC;AACT,IAAA,SAAS,EAAE,KAAK;AAChB,IAAA,SAAS,EAAE,CAAC;AACZ,IAAA,SAAS,EAAE,CAAC;AACZ,IAAA,IAAI,EAAE,IAAI;IACV,SAAS,EAAE,QAAQ,CAAC,IAAI;CACzB,CAAC;AAEK,MAAM,qBAAqB,GAAG,IAAI,cAAc,CAAmB,uBAAuB,CAAC,CAAC;AAEnG;;;;AAIG;AACG,SAAU,oBAAoB,CAAC,MAAiC,EAAA;IACpE,OAAO;AACL,QAAA;AACE,YAAA,OAAO,EAAE,qBAAqB;AAC9B,YAAA,QAAQ,EAAE,EAAE,GA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