@radix-ng/primitives 0.16.0 → 0.18.0

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.
Files changed (203) hide show
  1. package/checkbox/src/checkbox-input.directive.d.ts +2 -1
  2. package/compodoc/documentation.json +7419 -2200
  3. package/esm2022/accordion/index.mjs +4 -4
  4. package/esm2022/accordion/src/accordion-content.directive.mjs +3 -3
  5. package/esm2022/accordion/src/accordion-header.directive.mjs +3 -3
  6. package/esm2022/accordion/src/accordion-item.directive.mjs +3 -3
  7. package/esm2022/accordion/src/accordion-root.directive.mjs +3 -3
  8. package/esm2022/accordion/src/accordion-trigger.directive.mjs +3 -3
  9. package/esm2022/alert-dialog/index.mjs +4 -4
  10. package/esm2022/alert-dialog/src/alert-dialog-cancel.directive.mjs +3 -3
  11. package/esm2022/alert-dialog/src/alert-dialog-content.directive.mjs +3 -3
  12. package/esm2022/alert-dialog/src/alert-dialog-root.directive.mjs +3 -3
  13. package/esm2022/alert-dialog/src/alert-dialog-title.directive.mjs +3 -3
  14. package/esm2022/alert-dialog/src/alert-dialog-trigger.directive.mjs +3 -3
  15. package/esm2022/alert-dialog/src/alert-dialog.service.mjs +3 -3
  16. package/esm2022/aspect-ratio/src/aspect-ratio.directive.mjs +3 -3
  17. package/esm2022/avatar/src/avatar-fallback.directive.mjs +3 -3
  18. package/esm2022/avatar/src/avatar-image.directive.mjs +3 -3
  19. package/esm2022/avatar/src/avatar-root.directive.mjs +3 -3
  20. package/esm2022/checkbox/src/checkbox-button.directive.mjs +3 -3
  21. package/esm2022/checkbox/src/checkbox-indicator.directive.mjs +3 -3
  22. package/esm2022/checkbox/src/checkbox-input.directive.mjs +7 -4
  23. package/esm2022/checkbox/src/checkbox.directive.mjs +3 -3
  24. package/esm2022/collapsible/src/collapsible-content.directive.mjs +3 -3
  25. package/esm2022/collapsible/src/collapsible-root.directive.mjs +3 -3
  26. package/esm2022/collapsible/src/collapsible-trigger.directive.mjs +3 -3
  27. package/esm2022/context-menu/index.mjs +4 -4
  28. package/esm2022/context-menu/src/context-menu-content.directive.mjs +3 -3
  29. package/esm2022/context-menu/src/context-menu-item-checkbox.directive.mjs +3 -3
  30. package/esm2022/context-menu/src/context-menu-item-indicator.directive.mjs +3 -3
  31. package/esm2022/context-menu/src/context-menu-item-radio-group.directive.mjs +3 -3
  32. package/esm2022/context-menu/src/context-menu-item-radio.directive.mjs +3 -3
  33. package/esm2022/context-menu/src/context-menu-item-selectable.mjs +3 -3
  34. package/esm2022/context-menu/src/context-menu-item.directive.mjs +3 -3
  35. package/esm2022/context-menu/src/context-menu-label.directive.mjs +3 -3
  36. package/esm2022/context-menu/src/context-menu-separator.directive.mjs +3 -3
  37. package/esm2022/context-menu/src/context-menu-trigger.directive.mjs +3 -3
  38. package/esm2022/core/src/auto-focus.directive.mjs +3 -3
  39. package/esm2022/dialog/index.mjs +4 -4
  40. package/esm2022/dialog/src/dialog-close.directive.mjs +3 -3
  41. package/esm2022/dialog/src/dialog-content.directive.mjs +3 -3
  42. package/esm2022/dialog/src/dialog-description.directive.mjs +3 -3
  43. package/esm2022/dialog/src/dialog-dismiss.directive.mjs +3 -3
  44. package/esm2022/dialog/src/dialog-title.directive.mjs +3 -3
  45. package/esm2022/dialog/src/dialog-trigger.directive.mjs +3 -3
  46. package/esm2022/dialog/src/dialog.service.mjs +3 -3
  47. package/esm2022/dropdown-menu/index.mjs +4 -4
  48. package/esm2022/dropdown-menu/src/dropdown-menu-content.directive.mjs +3 -3
  49. package/esm2022/dropdown-menu/src/dropdown-menu-item-checkbox.directive.mjs +3 -3
  50. package/esm2022/dropdown-menu/src/dropdown-menu-item-indicator.directive.mjs +3 -3
  51. package/esm2022/dropdown-menu/src/dropdown-menu-item-radio-group.directive.mjs +3 -3
  52. package/esm2022/dropdown-menu/src/dropdown-menu-item-radio.directive.mjs +3 -3
  53. package/esm2022/dropdown-menu/src/dropdown-menu-item-selectable.mjs +3 -3
  54. package/esm2022/dropdown-menu/src/dropdown-menu-item.directive.mjs +3 -3
  55. package/esm2022/dropdown-menu/src/dropdown-menu-label.directive.mjs +3 -3
  56. package/esm2022/dropdown-menu/src/dropdown-menu-separator.directive.mjs +3 -3
  57. package/esm2022/dropdown-menu/src/dropdown-menu-trigger.directive.mjs +3 -3
  58. package/esm2022/label/src/label.directive.mjs +3 -3
  59. package/esm2022/menu/index.mjs +4 -4
  60. package/esm2022/menu/src/menu-content.directive.mjs +3 -3
  61. package/esm2022/menu/src/menu-directive.mjs +3 -3
  62. package/esm2022/menu/src/menu-group.directive.mjs +3 -3
  63. package/esm2022/menu/src/menu-item.directive.mjs +3 -3
  64. package/esm2022/menu/src/menu-label.directive.mjs +3 -3
  65. package/esm2022/menu/src/menu-separator.directive.mjs +3 -3
  66. package/esm2022/menubar/index.mjs +4 -4
  67. package/esm2022/menubar/src/menubar-content.directive.mjs +3 -3
  68. package/esm2022/menubar/src/menubar-item-checkbox.directive.mjs +3 -3
  69. package/esm2022/menubar/src/menubar-item-indicator.directive.mjs +3 -3
  70. package/esm2022/menubar/src/menubar-item-radio.directive.mjs +3 -3
  71. package/esm2022/menubar/src/menubar-item.directive.mjs +3 -3
  72. package/esm2022/menubar/src/menubar-radio-group.directive.mjs +3 -3
  73. package/esm2022/menubar/src/menubar-root.directive.mjs +3 -3
  74. package/esm2022/menubar/src/menubar-separator.directive.mjs +3 -3
  75. package/esm2022/menubar/src/menubar-trigger.directive.mjs +3 -3
  76. package/esm2022/progress/index.mjs +4 -4
  77. package/esm2022/progress/src/progress-indicator.directive.mjs +3 -3
  78. package/esm2022/progress/src/progress-root.directive.mjs +3 -3
  79. package/esm2022/radio/src/radio-indicator.directive.mjs +3 -3
  80. package/esm2022/radio/src/radio-item.directive.mjs +3 -3
  81. package/esm2022/radio/src/radio-root.directive.mjs +3 -3
  82. package/esm2022/select/index.mjs +65 -0
  83. package/esm2022/select/radix-ng-primitives-select.mjs +5 -0
  84. package/esm2022/select/src/select-content.directive.mjs +53 -0
  85. package/esm2022/select/src/select-group.directive.mjs +18 -0
  86. package/esm2022/select/src/select-icon.directive.mjs +18 -0
  87. package/esm2022/select/src/select-item-indicator.directive.mjs +23 -0
  88. package/esm2022/select/src/select-item.directive.mjs +116 -0
  89. package/esm2022/select/src/select-label.directive.mjs +15 -0
  90. package/esm2022/select/src/select-separator.directive.mjs +18 -0
  91. package/esm2022/select/src/select-trigger.directive.mjs +38 -0
  92. package/esm2022/select/src/select-value.directive.mjs +21 -0
  93. package/esm2022/select/src/select.component.mjs +234 -0
  94. package/esm2022/separator/src/separator.directive.mjs +3 -3
  95. package/esm2022/slider/index.mjs +28 -0
  96. package/esm2022/slider/radix-ng-primitives-slider.mjs +5 -0
  97. package/esm2022/slider/src/slider-horizontal.component.mjs +117 -0
  98. package/esm2022/slider/src/slider-impl.directive.mjs +89 -0
  99. package/esm2022/slider/src/slider-orientation-context.service.mjs +28 -0
  100. package/esm2022/slider/src/slider-range.component.mjs +41 -0
  101. package/esm2022/slider/src/slider-root.component.mjs +207 -0
  102. package/esm2022/slider/src/slider-thumb-impl.directive.mjs +102 -0
  103. package/esm2022/slider/src/slider-thumb.component.mjs +22 -0
  104. package/esm2022/slider/src/slider-track.component.mjs +27 -0
  105. package/esm2022/slider/src/slider-vertical.component.mjs +117 -0
  106. package/esm2022/slider/src/utils.mjs +94 -0
  107. package/esm2022/switch/index.mjs +4 -4
  108. package/esm2022/switch/src/switch-input.directive.mjs +3 -3
  109. package/esm2022/switch/src/switch-root.directive.mjs +3 -3
  110. package/esm2022/switch/src/switch-thumb.directive.mjs +3 -3
  111. package/esm2022/tabs/index.mjs +4 -4
  112. package/esm2022/tabs/src/tabs-content.directive.mjs +3 -3
  113. package/esm2022/tabs/src/tabs-context.service.mjs +3 -3
  114. package/esm2022/tabs/src/tabs-list.directive.mjs +3 -3
  115. package/esm2022/tabs/src/tabs-root.directive.mjs +3 -3
  116. package/esm2022/tabs/src/tabs-trigger.directive.mjs +3 -3
  117. package/esm2022/toggle/src/toggle-input.directive.mjs +3 -3
  118. package/esm2022/toggle/src/toggle.directive.mjs +3 -3
  119. package/esm2022/toggle-group/src/toggle-group-item.directive.mjs +3 -3
  120. package/esm2022/toggle-group/src/toggle-group-multiple.directive.mjs +3 -3
  121. package/esm2022/toggle-group/src/toggle-group.directive.mjs +3 -3
  122. package/esm2022/tooltip/index.mjs +41 -0
  123. package/esm2022/tooltip/radix-ng-primitives-tooltip.mjs +5 -0
  124. package/esm2022/tooltip/src/get-content-position.mjs +31 -0
  125. package/esm2022/tooltip/src/tooltip-arrow.directive.mjs +92 -0
  126. package/esm2022/tooltip/src/tooltip-arrow.token.mjs +3 -0
  127. package/esm2022/tooltip/src/tooltip-content-attributes.directive.mjs +24 -0
  128. package/esm2022/tooltip/src/tooltip-content.directive.mjs +48 -0
  129. package/esm2022/tooltip/src/tooltip-content.token.mjs +3 -0
  130. package/esm2022/tooltip/src/tooltip-root.directive.mjs +288 -0
  131. package/esm2022/tooltip/src/tooltip-trigger.directive.mjs +70 -0
  132. package/esm2022/tooltip/src/tooltip.config.mjs +18 -0
  133. package/esm2022/tooltip/src/tooltip.constants.mjs +84 -0
  134. package/esm2022/tooltip/src/tooltip.types.mjs +14 -0
  135. package/esm2022/visually-hidden/src/visually-hidden-input-bubble.directive.mjs +3 -3
  136. package/esm2022/visually-hidden/src/visually-hidden-input.directive.mjs +3 -3
  137. package/esm2022/visually-hidden/src/visually-hidden.directive.mjs +3 -3
  138. package/fesm2022/radix-ng-primitives-accordion.mjs +19 -19
  139. package/fesm2022/radix-ng-primitives-alert-dialog.mjs +22 -22
  140. package/fesm2022/radix-ng-primitives-aspect-ratio.mjs +3 -3
  141. package/fesm2022/radix-ng-primitives-avatar.mjs +9 -9
  142. package/fesm2022/radix-ng-primitives-checkbox.mjs +15 -12
  143. package/fesm2022/radix-ng-primitives-checkbox.mjs.map +1 -1
  144. package/fesm2022/radix-ng-primitives-collapsible.mjs +9 -9
  145. package/fesm2022/radix-ng-primitives-context-menu.mjs +34 -34
  146. package/fesm2022/radix-ng-primitives-core.mjs +3 -3
  147. package/fesm2022/radix-ng-primitives-dialog.mjs +25 -25
  148. package/fesm2022/radix-ng-primitives-dropdown-menu.mjs +34 -34
  149. package/fesm2022/radix-ng-primitives-label.mjs +3 -3
  150. package/fesm2022/radix-ng-primitives-menu.mjs +22 -22
  151. package/fesm2022/radix-ng-primitives-menubar.mjs +31 -31
  152. package/fesm2022/radix-ng-primitives-progress.mjs +10 -10
  153. package/fesm2022/radix-ng-primitives-radio.mjs +9 -9
  154. package/fesm2022/radix-ng-primitives-select.mjs +572 -0
  155. package/fesm2022/radix-ng-primitives-select.mjs.map +1 -0
  156. package/fesm2022/radix-ng-primitives-separator.mjs +3 -3
  157. package/fesm2022/radix-ng-primitives-slider.mjs +830 -0
  158. package/fesm2022/radix-ng-primitives-slider.mjs.map +1 -0
  159. package/fesm2022/radix-ng-primitives-switch.mjs +13 -13
  160. package/fesm2022/radix-ng-primitives-tabs.mjs +19 -19
  161. package/fesm2022/radix-ng-primitives-toggle-group.mjs +9 -9
  162. package/fesm2022/radix-ng-primitives-toggle.mjs +6 -6
  163. package/fesm2022/radix-ng-primitives-tooltip.mjs +684 -0
  164. package/fesm2022/radix-ng-primitives-tooltip.mjs.map +1 -0
  165. package/fesm2022/radix-ng-primitives-visually-hidden.mjs +9 -9
  166. package/package.json +19 -1
  167. package/select/README.md +1 -0
  168. package/select/index.d.ts +26 -0
  169. package/select/src/select-content.directive.d.ts +20 -0
  170. package/select/src/select-group.directive.d.ts +5 -0
  171. package/select/src/select-icon.directive.d.ts +5 -0
  172. package/select/src/select-item-indicator.directive.d.ts +7 -0
  173. package/select/src/select-item.directive.d.ts +47 -0
  174. package/select/src/select-label.directive.d.ts +5 -0
  175. package/select/src/select-separator.directive.d.ts +5 -0
  176. package/select/src/select-trigger.directive.d.ts +11 -0
  177. package/select/src/select-value.directive.d.ts +8 -0
  178. package/select/src/select.component.d.ts +81 -0
  179. package/slider/README.md +1 -0
  180. package/slider/index.d.ts +18 -0
  181. package/slider/src/slider-horizontal.component.d.ts +29 -0
  182. package/slider/src/slider-impl.directive.d.ts +18 -0
  183. package/slider/src/slider-orientation-context.service.d.ts +14 -0
  184. package/slider/src/slider-range.component.d.ts +13 -0
  185. package/slider/src/slider-root.component.d.ts +47 -0
  186. package/slider/src/slider-thumb-impl.directive.d.ts +26 -0
  187. package/slider/src/slider-thumb.component.d.ts +6 -0
  188. package/slider/src/slider-track.component.d.ts +7 -0
  189. package/slider/src/slider-vertical.component.d.ts +29 -0
  190. package/slider/src/utils.d.ts +52 -0
  191. package/tooltip/README.md +1 -0
  192. package/tooltip/index.d.ts +17 -0
  193. package/tooltip/src/get-content-position.d.ts +3 -0
  194. package/tooltip/src/tooltip-arrow.directive.d.ts +25 -0
  195. package/tooltip/src/tooltip-arrow.token.d.ts +3 -0
  196. package/tooltip/src/tooltip-content-attributes.directive.d.ts +8 -0
  197. package/tooltip/src/tooltip-content.directive.d.ts +36 -0
  198. package/tooltip/src/tooltip-content.token.d.ts +3 -0
  199. package/tooltip/src/tooltip-root.directive.d.ts +103 -0
  200. package/tooltip/src/tooltip-trigger.directive.d.ts +26 -0
  201. package/tooltip/src/tooltip.config.d.ts +6 -0
  202. package/tooltip/src/tooltip.constants.d.ts +9 -0
  203. package/tooltip/src/tooltip.types.d.ts +18 -0
@@ -0,0 +1,684 @@
1
+ import * as i0 from '@angular/core';
2
+ import { InjectionToken, inject, Renderer2, ElementRef, input, computed, effect, forwardRef, Directive, ViewContainerRef, DestroyRef, PLATFORM_ID, output, signal, contentChild, untracked, TemplateRef, NgModule } from '@angular/core';
3
+ import { Overlay } from '@angular/cdk/overlay';
4
+ import { TemplatePortal } from '@angular/cdk/portal';
5
+ import { DOCUMENT, isPlatformBrowser } from '@angular/common';
6
+ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
7
+ import { filter, take, asyncScheduler } from 'rxjs';
8
+
9
+ const RdxTooltipArrowToken = new InjectionToken('RdxTooltipArrowToken');
10
+
11
+ const RdxTooltipContentToken = new InjectionToken('RdxTooltipContentToken');
12
+
13
+ var RdxTooltipSide;
14
+ (function (RdxTooltipSide) {
15
+ RdxTooltipSide["Top"] = "top";
16
+ RdxTooltipSide["Right"] = "right";
17
+ RdxTooltipSide["Bottom"] = "bottom";
18
+ RdxTooltipSide["Left"] = "left";
19
+ })(RdxTooltipSide || (RdxTooltipSide = {}));
20
+ var RdxTooltipAlign;
21
+ (function (RdxTooltipAlign) {
22
+ RdxTooltipAlign["Start"] = "start";
23
+ RdxTooltipAlign["Center"] = "center";
24
+ RdxTooltipAlign["End"] = "end";
25
+ })(RdxTooltipAlign || (RdxTooltipAlign = {}));
26
+
27
+ class RdxTooltipArrowDirective {
28
+ constructor() {
29
+ /** @ignore */
30
+ this.renderer = inject(Renderer2);
31
+ /** @ignore */
32
+ this.contentDirective = inject(RdxTooltipContentToken);
33
+ /** @ignore */
34
+ this.elementRef = inject(ElementRef);
35
+ /**
36
+ * The width of the arrow in pixels.
37
+ */
38
+ this.width = input(10);
39
+ /**
40
+ * The height of the arrow in pixels.
41
+ */
42
+ this.height = input(5);
43
+ /** @ignore */
44
+ this.arrowSvgElement = computed(() => {
45
+ const width = this.width();
46
+ const height = this.height();
47
+ const svgElement = this.renderer.createElement('svg', 'svg');
48
+ this.renderer.setAttribute(svgElement, 'viewBox', '0 0 30 10');
49
+ this.renderer.setAttribute(svgElement, 'width', String(width));
50
+ this.renderer.setAttribute(svgElement, 'height', String(height));
51
+ const polygonElement = this.renderer.createElement('polygon', 'svg');
52
+ this.renderer.setAttribute(polygonElement, 'points', '0,0 30,0 15,10');
53
+ this.renderer.setAttribute(svgElement, 'preserveAspectRatio', 'none');
54
+ this.renderer.appendChild(svgElement, polygonElement);
55
+ return svgElement;
56
+ });
57
+ /** @ignore */
58
+ this.onArrowSvgElementChangeEffect = effect(() => {
59
+ const arrowElement = this.arrowSvgElement();
60
+ this.renderer.appendChild(this.elementRef.nativeElement, arrowElement);
61
+ });
62
+ /** @ignore */
63
+ this.onSideChangeEffect = effect(() => {
64
+ const side = this.contentDirective.side();
65
+ this.elementRef.nativeElement.parentElement?.setAttribute('style', `position: relative;`);
66
+ this.elementRef.nativeElement.style.position = 'absolute';
67
+ this.elementRef.nativeElement.style.boxSizing = '';
68
+ this.elementRef.nativeElement.style.width = `${this.width()}px`;
69
+ this.elementRef.nativeElement.style.height = `${this.height()}px`;
70
+ this.elementRef.nativeElement.style.fontSize = '0px';
71
+ if ([RdxTooltipSide.Top, RdxTooltipSide.Bottom].includes(side)) {
72
+ this.elementRef.nativeElement.style.left = `calc(50% - ${this.width() / 2}px)`;
73
+ this.elementRef.nativeElement.style.top = '100%';
74
+ if (side === RdxTooltipSide.Bottom) {
75
+ this.elementRef.nativeElement.style.transform = 'rotate(180deg)';
76
+ this.elementRef.nativeElement.style.top = `-${this.height()}px`;
77
+ }
78
+ }
79
+ if ([RdxTooltipSide.Left, RdxTooltipSide.Right].includes(side)) {
80
+ this.elementRef.nativeElement.style.top = `calc(50% - ${this.height() / 2}px)`;
81
+ if (side === RdxTooltipSide.Left) {
82
+ this.elementRef.nativeElement.style.left = `100%`;
83
+ this.elementRef.nativeElement.style.transform = 'rotate(-90deg) translate(0, -50%)';
84
+ }
85
+ if (side === RdxTooltipSide.Right) {
86
+ this.elementRef.nativeElement.style.right = `100%`;
87
+ this.elementRef.nativeElement.style.transform = 'rotate(90deg) translate(0, -50%)';
88
+ }
89
+ }
90
+ });
91
+ }
92
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxTooltipArrowDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
93
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "18.2.11", type: RdxTooltipArrowDirective, isStandalone: true, selector: "[rdxTooltipArrow]", inputs: { width: { classPropertyName: "width", publicName: "width", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null } }, providers: [
94
+ {
95
+ provide: RdxTooltipArrowToken,
96
+ useExisting: forwardRef(() => RdxTooltipArrowDirective)
97
+ }
98
+ ], ngImport: i0 }); }
99
+ }
100
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxTooltipArrowDirective, decorators: [{
101
+ type: Directive,
102
+ args: [{
103
+ selector: '[rdxTooltipArrow]',
104
+ standalone: true,
105
+ providers: [
106
+ {
107
+ provide: RdxTooltipArrowToken,
108
+ useExisting: forwardRef(() => RdxTooltipArrowDirective)
109
+ }
110
+ ]
111
+ }]
112
+ }] });
113
+
114
+ class RdxTooltipTriggerDirective {
115
+ constructor() {
116
+ /** @ignore */
117
+ this.tooltipRoot = injectTooltipRoot();
118
+ /** @ignore */
119
+ this.elementRef = inject((ElementRef));
120
+ /** @ignore */
121
+ this.isPointerDown = false;
122
+ /** @ignore */
123
+ this.isPointerInside = false;
124
+ }
125
+ /** @ignore */
126
+ onPointerMove(event) {
127
+ if (event.pointerType === 'touch') {
128
+ return;
129
+ }
130
+ if (!this.isPointerInside) {
131
+ this.tooltipRoot.onTriggerEnter();
132
+ this.isPointerInside = true;
133
+ }
134
+ }
135
+ /** @ignore */
136
+ onPointerLeave() {
137
+ this.isPointerInside = false;
138
+ this.tooltipRoot.onTriggerLeave();
139
+ }
140
+ /** @ignore */
141
+ onPointerDown() {
142
+ this.isPointerDown = true;
143
+ this.elementRef.nativeElement.addEventListener('pointerup', () => {
144
+ this.isPointerDown = false;
145
+ }, { once: true });
146
+ }
147
+ /** @ignore */
148
+ onFocus() {
149
+ if (!this.isPointerDown) {
150
+ this.tooltipRoot.handleOpen();
151
+ }
152
+ }
153
+ /** @ignore */
154
+ onBlur() {
155
+ this.tooltipRoot.handleClose();
156
+ }
157
+ /** @ignore */
158
+ onClick() {
159
+ this.tooltipRoot.handleClose();
160
+ }
161
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxTooltipTriggerDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
162
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.11", type: RdxTooltipTriggerDirective, isStandalone: true, selector: "[rdxTooltipTrigger]", host: { listeners: { "pointermove": "onPointerMove($event)", "pointerleave": "onPointerLeave()", "pointerdown": "onPointerDown()", "focus": "onFocus()", "blur": "onBlur()", "click": "onClick()" }, properties: { "attr.data-state": "tooltipRoot.state()" } }, ngImport: i0 }); }
163
+ }
164
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxTooltipTriggerDirective, decorators: [{
165
+ type: Directive,
166
+ args: [{
167
+ selector: '[rdxTooltipTrigger]',
168
+ standalone: true,
169
+ host: {
170
+ '[attr.data-state]': 'tooltipRoot.state()',
171
+ '(pointermove)': 'onPointerMove($event)',
172
+ '(pointerleave)': 'onPointerLeave()',
173
+ '(pointerdown)': 'onPointerDown()',
174
+ '(focus)': 'onFocus()',
175
+ '(blur)': 'onBlur()',
176
+ '(click)': 'onClick()'
177
+ }
178
+ }]
179
+ }] });
180
+
181
+ const defaultTooltipConfig = {
182
+ delayDuration: 700,
183
+ skipDelayDuration: 300
184
+ };
185
+ const RdxTooltipConfigToken = new InjectionToken('RdxTooltipConfigToken');
186
+ function provideRdxTooltipConfig(config) {
187
+ return [
188
+ {
189
+ provide: RdxTooltipConfigToken,
190
+ useValue: { ...defaultTooltipConfig, ...config }
191
+ }
192
+ ];
193
+ }
194
+ function injectTooltipConfig() {
195
+ return inject(RdxTooltipConfigToken, { optional: true }) ?? defaultTooltipConfig;
196
+ }
197
+
198
+ const RdxTooltipRootToken = new InjectionToken('RdxTooltipRootToken');
199
+ function injectTooltipRoot() {
200
+ return inject(RdxTooltipRootToken);
201
+ }
202
+ class RdxTooltipRootDirective {
203
+ constructor() {
204
+ /** @ignore */
205
+ this.viewContainerRef = inject(ViewContainerRef);
206
+ /** @ignore */
207
+ this.destroyRef = inject(DestroyRef);
208
+ /** @ignore */
209
+ this.overlay = inject(Overlay);
210
+ /** @ignore */
211
+ this.platformId = inject(PLATFORM_ID);
212
+ /** @ignore */
213
+ this.document = inject(DOCUMENT);
214
+ /** @ignore */
215
+ this.tooltipConfig = injectTooltipConfig();
216
+ /**
217
+ * The open state of the tooltip when it is initially rendered. Use when you do not need to control its open state.
218
+ */
219
+ this.defaultOpen = input(false);
220
+ /**
221
+ * The controlled open state of the tooltip. Must be used in conjunction with onOpenChange.
222
+ */
223
+ this.open = input();
224
+ /**
225
+ * Override the duration given to the configuration to customise the open delay for a specific tooltip.
226
+ */
227
+ this.delayDuration = input(this.tooltipConfig.delayDuration);
228
+ /** @ignore */
229
+ this.disableHoverableContent = input(this.tooltipConfig.disableHoverableContent ?? false);
230
+ /**
231
+ * Event handler called when the open state of the tooltip changes.
232
+ */
233
+ this.onOpenChange = output();
234
+ /** @ignore */
235
+ this.isOpen = signal(this.defaultOpen());
236
+ /** @ignore */
237
+ this.isOpenDelayed = signal(true);
238
+ /** @ignore */
239
+ this.wasOpenDelayed = signal(false);
240
+ /** @ignore */
241
+ this.state = computed(() => {
242
+ const currentIsOpen = this.isOpen();
243
+ const currentWasOpenDelayed = this.wasOpenDelayed();
244
+ if (currentIsOpen) {
245
+ return currentWasOpenDelayed ? 'delayed-open' : 'instant-open';
246
+ }
247
+ return 'closed';
248
+ });
249
+ /** @ignore */
250
+ this.tooltipContentDirective = contentChild.required(RdxTooltipContentToken);
251
+ /** @ignore */
252
+ this.tooltipTriggerElementRef = contentChild.required(RdxTooltipTriggerDirective, { read: ElementRef });
253
+ /** @ignore */
254
+ this.openTimer = 0;
255
+ /** @ignore */
256
+ this.skipDelayTimer = 0;
257
+ /** @ignore */
258
+ this.isControlledExternally = false;
259
+ /** @ignore */
260
+ this.onIsOpenChangeEffect = effect(() => {
261
+ const isOpen = this.isOpen();
262
+ untracked(() => {
263
+ if (isOpen) {
264
+ this.show();
265
+ }
266
+ else {
267
+ this.hide();
268
+ }
269
+ });
270
+ });
271
+ /** @ignore */
272
+ this.onPositionChangeEffect = effect(() => {
273
+ const position = this.tooltipContentDirective().position();
274
+ if (this.overlayRef) {
275
+ const positionStrategy = this.getPositionStrategy(position);
276
+ this.overlayRef.updatePositionStrategy(positionStrategy);
277
+ }
278
+ });
279
+ /** @ignore */
280
+ this.onOpenChangeEffect = effect(() => {
281
+ const currentOpen = this.open();
282
+ this.isControlledExternally = currentOpen !== undefined;
283
+ untracked(() => {
284
+ if (this.isControlledExternally) {
285
+ this.setOpen(currentOpen);
286
+ }
287
+ });
288
+ });
289
+ }
290
+ /** @ignore */
291
+ ngOnInit() {
292
+ if (this.defaultOpen()) {
293
+ this.handleOpen();
294
+ }
295
+ this.isControlledExternally = this.open() !== undefined;
296
+ }
297
+ /** @ignore */
298
+ onTriggerEnter() {
299
+ if (this.isControlledExternally) {
300
+ return;
301
+ }
302
+ if (this.isOpenDelayed()) {
303
+ this.handleDelayedOpen();
304
+ }
305
+ else {
306
+ this.handleOpen();
307
+ }
308
+ }
309
+ /** @ignore */
310
+ onTriggerLeave() {
311
+ this.clearTimeout(this.openTimer);
312
+ this.handleClose();
313
+ }
314
+ /** @ignore */
315
+ onOpen() {
316
+ this.clearTimeout(this.skipDelayTimer);
317
+ this.isOpenDelayed.set(false);
318
+ }
319
+ /** @ignore */
320
+ onClose() {
321
+ this.clearTimeout(this.skipDelayTimer);
322
+ if (isPlatformBrowser(this.platformId)) {
323
+ this.skipDelayTimer = window.setTimeout(() => {
324
+ this.isOpenDelayed.set(true);
325
+ }, this.tooltipConfig.skipDelayDuration);
326
+ }
327
+ }
328
+ /** @ignore */
329
+ handleOpen() {
330
+ if (this.isControlledExternally) {
331
+ return;
332
+ }
333
+ this.wasOpenDelayed.set(false);
334
+ this.setOpen(true);
335
+ }
336
+ /** @ignore */
337
+ handleClose() {
338
+ if (this.isControlledExternally) {
339
+ return;
340
+ }
341
+ this.clearTimeout(this.openTimer);
342
+ this.setOpen(false);
343
+ }
344
+ /** @ignore */
345
+ handleOverlayKeydown() {
346
+ if (!this.overlayRef) {
347
+ return;
348
+ }
349
+ this.overlayRef
350
+ .keydownEvents()
351
+ .pipe(filter((event) => event.key === 'Escape'), takeUntilDestroyed(this.destroyRef))
352
+ .subscribe((event) => {
353
+ this.tooltipContentDirective().onEscapeKeyDown.emit(event);
354
+ if (!event.defaultPrevented) {
355
+ this.handleClose();
356
+ }
357
+ });
358
+ }
359
+ /** @ignore */
360
+ handlePointerDownOutside() {
361
+ if (!this.overlayRef) {
362
+ return;
363
+ }
364
+ this.overlayRef
365
+ .outsidePointerEvents()
366
+ .pipe(takeUntilDestroyed(this.destroyRef))
367
+ .subscribe((event) => this.tooltipContentDirective().onPointerDownOutside.emit(event));
368
+ }
369
+ /** @ignore */
370
+ handleDelayedOpen() {
371
+ this.clearTimeout(this.openTimer);
372
+ if (isPlatformBrowser(this.platformId)) {
373
+ this.openTimer = window.setTimeout(() => {
374
+ this.wasOpenDelayed.set(true);
375
+ this.setOpen(true);
376
+ }, this.delayDuration());
377
+ }
378
+ }
379
+ /** @ignore */
380
+ setOpen(open = false) {
381
+ if (open) {
382
+ this.onOpen();
383
+ this.document.dispatchEvent(new CustomEvent('tooltip.open'));
384
+ }
385
+ else {
386
+ this.onClose();
387
+ }
388
+ this.isOpen.set(open);
389
+ this.onOpenChange.emit(open);
390
+ }
391
+ /** @ignore */
392
+ createOverlayRef() {
393
+ if (this.overlayRef) {
394
+ return this.overlayRef;
395
+ }
396
+ this.overlayRef = this.overlay.create({
397
+ direction: undefined,
398
+ positionStrategy: this.getPositionStrategy(this.tooltipContentDirective().position()),
399
+ scrollStrategy: this.overlay.scrollStrategies.close()
400
+ });
401
+ this.overlayRef
402
+ .detachments()
403
+ .pipe(take(1), takeUntilDestroyed(this.destroyRef))
404
+ .subscribe(() => this.detach());
405
+ this.handleOverlayKeydown();
406
+ this.handlePointerDownOutside();
407
+ return this.overlayRef;
408
+ }
409
+ /** @ignore */
410
+ show() {
411
+ this.overlayRef = this.createOverlayRef();
412
+ this.detach();
413
+ this.portal =
414
+ this.portal ||
415
+ new TemplatePortal(this.tooltipContentDirective().templateRef, this.viewContainerRef, {
416
+ state: this.state,
417
+ side: this.tooltipContentDirective().side
418
+ });
419
+ this.instance = this.overlayRef.attach(this.portal);
420
+ }
421
+ /** @ignore */
422
+ detach() {
423
+ if (this.overlayRef?.hasAttached()) {
424
+ this.overlayRef.detach();
425
+ }
426
+ }
427
+ /** @ignore */
428
+ hide() {
429
+ if (this.isControlledExternally && this.open()) {
430
+ return;
431
+ }
432
+ asyncScheduler.schedule(() => {
433
+ this.instance?.destroy();
434
+ }, this.tooltipConfig.hideDelayDuration ?? 0);
435
+ }
436
+ /** @ignore */
437
+ getPositionStrategy(connectedPosition) {
438
+ return this.overlay
439
+ .position()
440
+ .flexibleConnectedTo(this.tooltipTriggerElementRef())
441
+ .withFlexibleDimensions(false)
442
+ .withPositions([
443
+ connectedPosition
444
+ ])
445
+ .withLockedPosition();
446
+ }
447
+ /** @ignore */
448
+ clearTimeout(timeoutId) {
449
+ if (isPlatformBrowser(this.platformId)) {
450
+ window.clearTimeout(timeoutId);
451
+ }
452
+ }
453
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxTooltipRootDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
454
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "18.2.11", type: RdxTooltipRootDirective, isStandalone: true, selector: "[rdxTooltipRoot]", inputs: { defaultOpen: { classPropertyName: "defaultOpen", publicName: "defaultOpen", isSignal: true, isRequired: false, transformFunction: null }, open: { classPropertyName: "open", publicName: "open", isSignal: true, isRequired: false, transformFunction: null }, delayDuration: { classPropertyName: "delayDuration", publicName: "delayDuration", isSignal: true, isRequired: false, transformFunction: null }, disableHoverableContent: { classPropertyName: "disableHoverableContent", publicName: "disableHoverableContent", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { onOpenChange: "onOpenChange" }, providers: [
455
+ {
456
+ provide: RdxTooltipRootToken,
457
+ useExisting: forwardRef(() => RdxTooltipRootDirective)
458
+ }
459
+ ], queries: [{ propertyName: "tooltipContentDirective", first: true, predicate: RdxTooltipContentToken, descendants: true, isSignal: true }, { propertyName: "tooltipTriggerElementRef", first: true, predicate: RdxTooltipTriggerDirective, descendants: true, read: ElementRef, isSignal: true }], exportAs: ["rdxTooltipRoot"], ngImport: i0 }); }
460
+ }
461
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxTooltipRootDirective, decorators: [{
462
+ type: Directive,
463
+ args: [{
464
+ selector: '[rdxTooltipRoot]',
465
+ standalone: true,
466
+ providers: [
467
+ {
468
+ provide: RdxTooltipRootToken,
469
+ useExisting: forwardRef(() => RdxTooltipRootDirective)
470
+ }
471
+ ],
472
+ exportAs: 'rdxTooltipRoot'
473
+ }]
474
+ }] });
475
+
476
+ class RdxTooltipContentAttributesDirective {
477
+ constructor() {
478
+ this.tooltipRoot = inject(RdxTooltipRootDirective);
479
+ this.tooltipContent = inject(RdxTooltipContentToken);
480
+ }
481
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxTooltipContentAttributesDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
482
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.11", type: RdxTooltipContentAttributesDirective, isStandalone: true, selector: "[rdxTooltipContentAttributes]", host: { properties: { "attr.data-state": "tooltipRoot.state()", "attr.data-side": "tooltipContent.side()" } }, ngImport: i0 }); }
483
+ }
484
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxTooltipContentAttributesDirective, decorators: [{
485
+ type: Directive,
486
+ args: [{
487
+ selector: '[rdxTooltipContentAttributes]',
488
+ standalone: true,
489
+ host: {
490
+ '[attr.data-state]': 'tooltipRoot.state()',
491
+ '[attr.data-side]': 'tooltipContent.side()'
492
+ }
493
+ }]
494
+ }] });
495
+
496
+ const TOOLTIP_POSITIONS = {
497
+ [RdxTooltipSide.Top]: {
498
+ [RdxTooltipAlign.Center]: {
499
+ originX: 'center',
500
+ originY: 'top',
501
+ overlayX: 'center',
502
+ overlayY: 'bottom'
503
+ },
504
+ [RdxTooltipAlign.Start]: {
505
+ originX: 'start',
506
+ originY: 'top',
507
+ overlayX: 'start',
508
+ overlayY: 'bottom'
509
+ },
510
+ [RdxTooltipAlign.End]: {
511
+ originX: 'end',
512
+ originY: 'top',
513
+ overlayX: 'end',
514
+ overlayY: 'bottom'
515
+ }
516
+ },
517
+ [RdxTooltipSide.Right]: {
518
+ [RdxTooltipAlign.Center]: {
519
+ originX: 'end',
520
+ originY: 'center',
521
+ overlayX: 'start',
522
+ overlayY: 'center'
523
+ },
524
+ [RdxTooltipAlign.Start]: {
525
+ originX: 'end',
526
+ originY: 'top',
527
+ overlayX: 'start',
528
+ overlayY: 'top'
529
+ },
530
+ [RdxTooltipAlign.End]: {
531
+ originX: 'end',
532
+ originY: 'bottom',
533
+ overlayX: 'start',
534
+ overlayY: 'bottom'
535
+ }
536
+ },
537
+ [RdxTooltipSide.Bottom]: {
538
+ [RdxTooltipAlign.Center]: {
539
+ originX: 'center',
540
+ originY: 'bottom',
541
+ overlayX: 'center',
542
+ overlayY: 'top'
543
+ },
544
+ [RdxTooltipAlign.Start]: {
545
+ originX: 'start',
546
+ originY: 'bottom',
547
+ overlayX: 'start',
548
+ overlayY: 'top'
549
+ },
550
+ [RdxTooltipAlign.End]: {
551
+ originX: 'end',
552
+ originY: 'bottom',
553
+ overlayX: 'end',
554
+ overlayY: 'top'
555
+ }
556
+ },
557
+ [RdxTooltipSide.Left]: {
558
+ [RdxTooltipAlign.Center]: {
559
+ originX: 'start',
560
+ originY: 'center',
561
+ overlayX: 'end',
562
+ overlayY: 'center'
563
+ },
564
+ [RdxTooltipAlign.Start]: {
565
+ originX: 'start',
566
+ originY: 'top',
567
+ overlayX: 'end',
568
+ overlayY: 'top'
569
+ },
570
+ [RdxTooltipAlign.End]: {
571
+ originX: 'start',
572
+ originY: 'bottom',
573
+ overlayX: 'end',
574
+ overlayY: 'bottom'
575
+ }
576
+ }
577
+ };
578
+
579
+ function getContentPosition(side, align, sideOffset, alignOffset) {
580
+ const position = TOOLTIP_POSITIONS[side][align] ?? TOOLTIP_POSITIONS[RdxTooltipSide.Top][RdxTooltipAlign.Center];
581
+ if (sideOffset > 0) {
582
+ let xFactor = 0;
583
+ let yFactor = 0;
584
+ switch (side) {
585
+ case RdxTooltipSide.Top:
586
+ yFactor = -1;
587
+ break;
588
+ case RdxTooltipSide.Bottom:
589
+ yFactor = 1;
590
+ break;
591
+ case RdxTooltipSide.Left:
592
+ xFactor = -1;
593
+ break;
594
+ case RdxTooltipSide.Right:
595
+ xFactor = 1;
596
+ break;
597
+ }
598
+ position.offsetX = xFactor * sideOffset;
599
+ position.offsetY = yFactor * sideOffset;
600
+ }
601
+ if ([RdxTooltipAlign.Start, RdxTooltipAlign.End].includes(align) && alignOffset) {
602
+ const alignOffsetFactor = align === RdxTooltipAlign.End ? -1 : 1;
603
+ position.offsetX = alignOffsetFactor * alignOffset;
604
+ }
605
+ return position;
606
+ }
607
+
608
+ class RdxTooltipContentDirective {
609
+ constructor() {
610
+ /** @ignore */
611
+ this.templateRef = inject(TemplateRef);
612
+ /**
613
+ * The preferred side of the trigger to render against when open. Will be reversed when collisions occur and avoidCollisions is enabled.
614
+ */
615
+ this.side = input(RdxTooltipSide.Top);
616
+ /**
617
+ * The distance in pixels from the trigger.
618
+ */
619
+ this.sideOffset = input(0);
620
+ /**
621
+ * The preferred alignment against the trigger. May change when collisions occur.
622
+ */
623
+ this.align = input(RdxTooltipAlign.Center);
624
+ /**
625
+ * An offset in pixels from the "start" or "end" alignment options.
626
+ */
627
+ this.alignOffset = input(0);
628
+ /** @ingore */
629
+ this.position = computed(() => getContentPosition(this.side(), this.align(), this.sideOffset(), this.alignOffset()));
630
+ /**
631
+ * Event handler called when the escape key is down. It can be prevented by calling event.preventDefault.
632
+ */
633
+ this.onEscapeKeyDown = output();
634
+ /**
635
+ * Event handler called when a pointer event occurs outside the bounds of the component. It can be prevented by calling event.preventDefault.
636
+ */
637
+ this.onPointerDownOutside = output();
638
+ }
639
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxTooltipContentDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
640
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "18.2.11", type: RdxTooltipContentDirective, isStandalone: true, selector: "[rdxTooltipContent]", inputs: { side: { classPropertyName: "side", publicName: "side", isSignal: true, isRequired: false, transformFunction: null }, sideOffset: { classPropertyName: "sideOffset", publicName: "sideOffset", isSignal: true, isRequired: false, transformFunction: null }, align: { classPropertyName: "align", publicName: "align", isSignal: true, isRequired: false, transformFunction: null }, alignOffset: { classPropertyName: "alignOffset", publicName: "alignOffset", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { onEscapeKeyDown: "onEscapeKeyDown", onPointerDownOutside: "onPointerDownOutside" }, providers: [{ provide: RdxTooltipContentToken, useExisting: forwardRef(() => RdxTooltipContentDirective) }], ngImport: i0 }); }
641
+ }
642
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxTooltipContentDirective, decorators: [{
643
+ type: Directive,
644
+ args: [{
645
+ selector: '[rdxTooltipContent]',
646
+ standalone: true,
647
+ providers: [{ provide: RdxTooltipContentToken, useExisting: forwardRef(() => RdxTooltipContentDirective) }]
648
+ }]
649
+ }] });
650
+
651
+ const _imports = [
652
+ RdxTooltipArrowDirective,
653
+ RdxTooltipContentDirective,
654
+ RdxTooltipTriggerDirective,
655
+ RdxTooltipContentAttributesDirective,
656
+ RdxTooltipRootDirective
657
+ ];
658
+ class RdxTooltipModule {
659
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxTooltipModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
660
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.11", ngImport: i0, type: RdxTooltipModule, imports: [RdxTooltipArrowDirective,
661
+ RdxTooltipContentDirective,
662
+ RdxTooltipTriggerDirective,
663
+ RdxTooltipContentAttributesDirective,
664
+ RdxTooltipRootDirective], exports: [RdxTooltipArrowDirective,
665
+ RdxTooltipContentDirective,
666
+ RdxTooltipTriggerDirective,
667
+ RdxTooltipContentAttributesDirective,
668
+ RdxTooltipRootDirective] }); }
669
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxTooltipModule }); }
670
+ }
671
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxTooltipModule, decorators: [{
672
+ type: NgModule,
673
+ args: [{
674
+ imports: [..._imports],
675
+ exports: [..._imports]
676
+ }]
677
+ }] });
678
+
679
+ /**
680
+ * Generated bundle index. Do not edit.
681
+ */
682
+
683
+ export { RdxTooltipAlign, RdxTooltipArrowDirective, RdxTooltipContentAttributesDirective, RdxTooltipContentDirective, RdxTooltipModule, RdxTooltipRootDirective, RdxTooltipRootToken, RdxTooltipSide, RdxTooltipTriggerDirective, injectTooltipRoot };
684
+ //# sourceMappingURL=radix-ng-primitives-tooltip.mjs.map