@radix-ng/primitives 0.17.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 (61) hide show
  1. package/compodoc/documentation.json +5303 -1426
  2. package/esm2022/select/src/select-trigger.directive.mjs +3 -3
  3. package/esm2022/select/src/select-value.directive.mjs +4 -9
  4. package/esm2022/select/src/select.component.mjs +6 -5
  5. package/esm2022/slider/index.mjs +28 -0
  6. package/esm2022/slider/radix-ng-primitives-slider.mjs +5 -0
  7. package/esm2022/slider/src/slider-horizontal.component.mjs +117 -0
  8. package/esm2022/slider/src/slider-impl.directive.mjs +89 -0
  9. package/esm2022/slider/src/slider-orientation-context.service.mjs +28 -0
  10. package/esm2022/slider/src/slider-range.component.mjs +41 -0
  11. package/esm2022/slider/src/slider-root.component.mjs +207 -0
  12. package/esm2022/slider/src/slider-thumb-impl.directive.mjs +102 -0
  13. package/esm2022/slider/src/slider-thumb.component.mjs +22 -0
  14. package/esm2022/slider/src/slider-track.component.mjs +27 -0
  15. package/esm2022/slider/src/slider-vertical.component.mjs +117 -0
  16. package/esm2022/slider/src/utils.mjs +94 -0
  17. package/esm2022/tooltip/index.mjs +41 -0
  18. package/esm2022/tooltip/radix-ng-primitives-tooltip.mjs +5 -0
  19. package/esm2022/tooltip/src/get-content-position.mjs +31 -0
  20. package/esm2022/tooltip/src/tooltip-arrow.directive.mjs +92 -0
  21. package/esm2022/tooltip/src/tooltip-arrow.token.mjs +3 -0
  22. package/esm2022/tooltip/src/tooltip-content-attributes.directive.mjs +24 -0
  23. package/esm2022/tooltip/src/tooltip-content.directive.mjs +48 -0
  24. package/esm2022/tooltip/src/tooltip-content.token.mjs +3 -0
  25. package/esm2022/tooltip/src/tooltip-root.directive.mjs +288 -0
  26. package/esm2022/tooltip/src/tooltip-trigger.directive.mjs +70 -0
  27. package/esm2022/tooltip/src/tooltip.config.mjs +18 -0
  28. package/esm2022/tooltip/src/tooltip.constants.mjs +84 -0
  29. package/esm2022/tooltip/src/tooltip.types.mjs +14 -0
  30. package/fesm2022/radix-ng-primitives-select.mjs +10 -14
  31. package/fesm2022/radix-ng-primitives-select.mjs.map +1 -1
  32. package/fesm2022/radix-ng-primitives-slider.mjs +830 -0
  33. package/fesm2022/radix-ng-primitives-slider.mjs.map +1 -0
  34. package/fesm2022/radix-ng-primitives-tooltip.mjs +684 -0
  35. package/fesm2022/radix-ng-primitives-tooltip.mjs.map +1 -0
  36. package/package.json +13 -1
  37. package/slider/README.md +1 -0
  38. package/slider/index.d.ts +18 -0
  39. package/slider/src/slider-horizontal.component.d.ts +29 -0
  40. package/slider/src/slider-impl.directive.d.ts +18 -0
  41. package/slider/src/slider-orientation-context.service.d.ts +14 -0
  42. package/slider/src/slider-range.component.d.ts +13 -0
  43. package/slider/src/slider-root.component.d.ts +47 -0
  44. package/slider/src/slider-thumb-impl.directive.d.ts +26 -0
  45. package/slider/src/slider-thumb.component.d.ts +6 -0
  46. package/slider/src/slider-track.component.d.ts +7 -0
  47. package/slider/src/slider-vertical.component.d.ts +29 -0
  48. package/slider/src/utils.d.ts +52 -0
  49. package/tooltip/README.md +1 -0
  50. package/tooltip/index.d.ts +17 -0
  51. package/tooltip/src/get-content-position.d.ts +3 -0
  52. package/tooltip/src/tooltip-arrow.directive.d.ts +25 -0
  53. package/tooltip/src/tooltip-arrow.token.d.ts +3 -0
  54. package/tooltip/src/tooltip-content-attributes.directive.d.ts +8 -0
  55. package/tooltip/src/tooltip-content.directive.d.ts +36 -0
  56. package/tooltip/src/tooltip-content.token.d.ts +3 -0
  57. package/tooltip/src/tooltip-root.directive.d.ts +103 -0
  58. package/tooltip/src/tooltip-trigger.directive.d.ts +26 -0
  59. package/tooltip/src/tooltip.config.d.ts +6 -0
  60. package/tooltip/src/tooltip.constants.d.ts +9 -0
  61. 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