@shival99/z-ui 2.2.5 → 2.3.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.
- package/assets/css/base.css +4 -0
- package/assets/css/overlay.css +82 -0
- package/assets/css/tailwind.css +1 -0
- package/assets/css/themes/hospital.css +28 -2
- package/fesm2022/shival99-z-ui-components-z-button-group.mjs +15 -13
- package/fesm2022/shival99-z-ui-components-z-button-group.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-button.mjs +2 -2
- package/fesm2022/shival99-z-ui-components-z-button.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-calendar.mjs +23 -17
- package/fesm2022/shival99-z-ui-components-z-calendar.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-command.mjs +10 -24
- package/fesm2022/shival99-z-ui-components-z-command.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-drawer.mjs +61 -70
- package/fesm2022/shival99-z-ui-components-z-drawer.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-gallery.mjs +6 -8
- package/fesm2022/shival99-z-ui-components-z-gallery.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-icon.mjs +227 -11
- package/fesm2022/shival99-z-ui-components-z-icon.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-marquee.mjs +19 -4
- package/fesm2022/shival99-z-ui-components-z-marquee.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-menu.mjs +7 -7
- package/fesm2022/shival99-z-ui-components-z-menu.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-modal.mjs +45 -62
- package/fesm2022/shival99-z-ui-components-z-modal.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-overlay.mjs +363 -0
- package/fesm2022/shival99-z-ui-components-z-overlay.mjs.map +1 -0
- package/fesm2022/shival99-z-ui-components-z-popover.mjs +94 -378
- package/fesm2022/shival99-z-ui-components-z-popover.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-skeleton.mjs +14 -3
- package/fesm2022/shival99-z-ui-components-z-skeleton.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-table.mjs +42 -16
- package/fesm2022/shival99-z-ui-components-z-table.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-tabs.mjs +85 -7
- package/fesm2022/shival99-z-ui-components-z-tabs.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-toast.mjs +32 -25
- package/fesm2022/shival99-z-ui-components-z-toast.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-tooltip.mjs +52 -222
- package/fesm2022/shival99-z-ui-components-z-tooltip.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-providers.mjs +9 -2
- package/fesm2022/shival99-z-ui-providers.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-services.mjs +203 -98
- package/fesm2022/shival99-z-ui-services.mjs.map +1 -1
- package/package.json +9 -1
- package/types/shival99-z-ui-components-z-autocomplete.d.ts +1 -1
- package/types/shival99-z-ui-components-z-button-group.d.ts +12 -11
- package/types/shival99-z-ui-components-z-button.d.ts +2 -1
- package/types/shival99-z-ui-components-z-calendar.d.ts +4 -4
- package/types/shival99-z-ui-components-z-command.d.ts +2 -4
- package/types/shival99-z-ui-components-z-drawer.d.ts +22 -16
- package/types/shival99-z-ui-components-z-editor.d.ts +1 -1
- package/types/shival99-z-ui-components-z-gallery.d.ts +3 -3
- package/types/shival99-z-ui-components-z-icon.d.ts +38 -6
- package/types/shival99-z-ui-components-z-marquee.d.ts +7 -1
- package/types/shival99-z-ui-components-z-modal.d.ts +53 -53
- package/types/shival99-z-ui-components-z-overlay.d.ts +145 -0
- package/types/shival99-z-ui-components-z-popover.d.ts +7 -15
- package/types/shival99-z-ui-components-z-qrcode.d.ts +1 -1
- package/types/shival99-z-ui-components-z-select.d.ts +1 -1
- package/types/shival99-z-ui-components-z-skeleton.d.ts +2 -0
- package/types/shival99-z-ui-components-z-table.d.ts +7 -3
- package/types/shival99-z-ui-components-z-tabs.d.ts +13 -3
- package/types/shival99-z-ui-components-z-toast.d.ts +7 -1
- package/types/shival99-z-ui-components-z-tooltip.d.ts +9 -7
- package/types/shival99-z-ui-components-z-upload.d.ts +3 -3
- package/types/shival99-z-ui-providers.d.ts +3 -1
- package/types/shival99-z-ui-services.d.ts +73 -37
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { Overlay, OverlayPositionBuilder } from '@angular/cdk/overlay';
|
|
2
|
-
import { ComponentPortal } from '@angular/cdk/portal';
|
|
3
1
|
import { NgTemplateOutlet, DOCUMENT, isPlatformBrowser } from '@angular/common';
|
|
4
2
|
import * as i0 from '@angular/core';
|
|
5
3
|
import { signal, computed, ChangeDetectionStrategy, Component, input, output, inject, ElementRef, Renderer2, DestroyRef, PLATFORM_ID, effect, Directive } from '@angular/core';
|
|
6
4
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
5
|
+
import { Z_OVERLAY_PREFERRED_SIDE_ORDER, Z_OVERLAY_FALLBACK_ORDER, ZOverlayService, startZOverlayAutoUpdate, computeZOverlayPlacement, computeZOverlayArrowOffset } from '@shival99/z-ui/components/z-overlay';
|
|
7
6
|
import { zMergeClasses, zTransform } from '@shival99/z-ui/utils';
|
|
8
7
|
import { Subject, switchMap, of, timer, map, filter } from 'rxjs';
|
|
9
8
|
import { TranslatePipe } from '@ngx-translate/core';
|
|
@@ -275,133 +274,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.2", ngImpor
|
|
|
275
274
|
}]
|
|
276
275
|
}] });
|
|
277
276
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
offsetY: -offset,
|
|
286
|
-
},
|
|
287
|
-
'top-left': {
|
|
288
|
-
originX: 'start',
|
|
289
|
-
originY: 'top',
|
|
290
|
-
overlayX: 'start',
|
|
291
|
-
overlayY: 'bottom',
|
|
292
|
-
offsetY: -offset,
|
|
293
|
-
},
|
|
294
|
-
'top-right': {
|
|
295
|
-
originX: 'end',
|
|
296
|
-
originY: 'top',
|
|
297
|
-
overlayX: 'end',
|
|
298
|
-
overlayY: 'bottom',
|
|
299
|
-
offsetY: -offset,
|
|
300
|
-
},
|
|
301
|
-
bottom: {
|
|
302
|
-
originX: 'center',
|
|
303
|
-
originY: 'bottom',
|
|
304
|
-
overlayX: 'center',
|
|
305
|
-
overlayY: 'top',
|
|
306
|
-
offsetY: offset,
|
|
307
|
-
},
|
|
308
|
-
'bottom-left': {
|
|
309
|
-
originX: 'start',
|
|
310
|
-
originY: 'bottom',
|
|
311
|
-
overlayX: 'start',
|
|
312
|
-
overlayY: 'top',
|
|
313
|
-
offsetY: offset,
|
|
314
|
-
},
|
|
315
|
-
'bottom-right': {
|
|
316
|
-
originX: 'end',
|
|
317
|
-
originY: 'bottom',
|
|
318
|
-
overlayX: 'end',
|
|
319
|
-
overlayY: 'top',
|
|
320
|
-
offsetY: offset,
|
|
321
|
-
},
|
|
322
|
-
left: {
|
|
323
|
-
originX: 'start',
|
|
324
|
-
originY: 'center',
|
|
325
|
-
overlayX: 'end',
|
|
326
|
-
overlayY: 'center',
|
|
327
|
-
offsetX: -offset,
|
|
328
|
-
},
|
|
329
|
-
'left-top': {
|
|
330
|
-
originX: 'start',
|
|
331
|
-
originY: 'top',
|
|
332
|
-
overlayX: 'end',
|
|
333
|
-
overlayY: 'top',
|
|
334
|
-
offsetX: -offset,
|
|
335
|
-
},
|
|
336
|
-
'left-bottom': {
|
|
337
|
-
originX: 'start',
|
|
338
|
-
originY: 'bottom',
|
|
339
|
-
overlayX: 'end',
|
|
340
|
-
overlayY: 'bottom',
|
|
341
|
-
offsetX: -offset,
|
|
342
|
-
},
|
|
343
|
-
right: {
|
|
344
|
-
originX: 'end',
|
|
345
|
-
originY: 'center',
|
|
346
|
-
overlayX: 'start',
|
|
347
|
-
overlayY: 'center',
|
|
348
|
-
offsetX: offset,
|
|
349
|
-
},
|
|
350
|
-
'right-top': {
|
|
351
|
-
originX: 'end',
|
|
352
|
-
originY: 'top',
|
|
353
|
-
overlayX: 'start',
|
|
354
|
-
overlayY: 'top',
|
|
355
|
-
offsetX: offset,
|
|
356
|
-
},
|
|
357
|
-
'right-bottom': {
|
|
358
|
-
originX: 'end',
|
|
359
|
-
originY: 'bottom',
|
|
360
|
-
overlayX: 'start',
|
|
361
|
-
overlayY: 'bottom',
|
|
362
|
-
offsetX: offset,
|
|
363
|
-
},
|
|
364
|
-
};
|
|
365
|
-
return positions[position];
|
|
366
|
-
}
|
|
367
|
-
function getTooltipFallbackPositions(position, offset) {
|
|
368
|
-
const fallbackOrder = {
|
|
369
|
-
top: ['top', 'bottom', 'top-left', 'top-right', 'bottom-left', 'bottom-right'],
|
|
370
|
-
'top-left': ['top-left', 'bottom-left', 'top', 'bottom', 'top-right', 'bottom-right'],
|
|
371
|
-
'top-right': ['top-right', 'bottom-right', 'top', 'bottom', 'top-left', 'bottom-left'],
|
|
372
|
-
bottom: ['bottom', 'top', 'bottom-left', 'bottom-right', 'top-left', 'top-right'],
|
|
373
|
-
'bottom-left': ['bottom-left', 'top-left', 'bottom', 'top', 'bottom-right', 'top-right'],
|
|
374
|
-
'bottom-right': ['bottom-right', 'top-right', 'bottom', 'top', 'bottom-left', 'top-left'],
|
|
375
|
-
left: ['left', 'right', 'left-top', 'left-bottom', 'right-top', 'right-bottom'],
|
|
376
|
-
'left-top': ['left-top', 'right-top', 'left', 'right', 'left-bottom', 'right-bottom'],
|
|
377
|
-
'left-bottom': ['left-bottom', 'right-bottom', 'left', 'right', 'left-top', 'right-top'],
|
|
378
|
-
right: ['right', 'left', 'right-top', 'right-bottom', 'left-top', 'left-bottom'],
|
|
379
|
-
'right-top': ['right-top', 'left-top', 'right', 'left', 'right-bottom', 'left-bottom'],
|
|
380
|
-
'right-bottom': ['right-bottom', 'left-bottom', 'right', 'left', 'right-top', 'left-top'],
|
|
381
|
-
};
|
|
382
|
-
const orderedPositions = fallbackOrder[position] ?? [position];
|
|
383
|
-
return orderedPositions.map(pos => createTooltipPosition(pos, offset));
|
|
384
|
-
}
|
|
385
|
-
function getTooltipPreferredSidePositions(position, offset) {
|
|
386
|
-
const preferredOrder = {
|
|
387
|
-
top: ['top', 'top-left', 'top-right'],
|
|
388
|
-
'top-left': ['top-left', 'top', 'top-right'],
|
|
389
|
-
'top-right': ['top-right', 'top', 'top-left'],
|
|
390
|
-
bottom: ['bottom', 'bottom-left', 'bottom-right'],
|
|
391
|
-
'bottom-left': ['bottom-left', 'bottom', 'bottom-right'],
|
|
392
|
-
'bottom-right': ['bottom-right', 'bottom', 'bottom-left'],
|
|
393
|
-
left: ['left', 'left-top', 'left-bottom'],
|
|
394
|
-
'left-top': ['left-top', 'left', 'left-bottom'],
|
|
395
|
-
'left-bottom': ['left-bottom', 'left', 'left-top'],
|
|
396
|
-
right: ['right', 'right-top', 'right-bottom'],
|
|
397
|
-
'right-top': ['right-top', 'right', 'right-bottom'],
|
|
398
|
-
'right-bottom': ['right-bottom', 'right', 'right-top'],
|
|
399
|
-
};
|
|
400
|
-
return preferredOrder[position].map(pos => createTooltipPosition(pos, offset));
|
|
401
|
-
}
|
|
402
|
-
function getTooltipStrategyPositions(origin, position, offset) {
|
|
403
|
-
const originElement = 'nativeElement' in origin ? origin.nativeElement : origin;
|
|
404
|
-
const rect = originElement.getBoundingClientRect();
|
|
277
|
+
/**
|
|
278
|
+
* Chọn danh sách fallback (không gồm vị trí chính — Floating UI tự thử vị trí chính trước):
|
|
279
|
+
* nếu cạnh đang hướng tới còn đủ chỗ, chỉ đổi qua các biến thể cùng cạnh (không bao giờ lật
|
|
280
|
+
* sang cạnh đối diện); nếu không đủ, cho phép lật cạnh đối diện.
|
|
281
|
+
*/
|
|
282
|
+
function getTooltipFallbackPlacements(origin, position, offset) {
|
|
283
|
+
const rect = origin.getBoundingClientRect();
|
|
405
284
|
const viewportWidth = globalThis.visualViewport?.width ?? globalThis.innerWidth;
|
|
406
285
|
const viewportHeight = globalThis.visualViewport?.height ?? globalThis.innerHeight;
|
|
407
286
|
const availableSpace = {
|
|
@@ -413,57 +292,9 @@ function getTooltipStrategyPositions(origin, position, offset) {
|
|
|
413
292
|
const side = position.split('-')[0];
|
|
414
293
|
const minimumSideSpace = Math.max(40, offset + 32);
|
|
415
294
|
if (availableSpace[side] >= minimumSideSpace) {
|
|
416
|
-
return
|
|
295
|
+
return Z_OVERLAY_PREFERRED_SIDE_ORDER[position];
|
|
417
296
|
}
|
|
418
|
-
return
|
|
419
|
-
}
|
|
420
|
-
function createTooltipPositionStrategy(overlayPositionBuilder, origin, position, offset) {
|
|
421
|
-
return overlayPositionBuilder
|
|
422
|
-
.flexibleConnectedTo(origin)
|
|
423
|
-
.withPositions(getTooltipStrategyPositions(origin, position, offset))
|
|
424
|
-
.withFlexibleDimensions(true)
|
|
425
|
-
.withPush(true)
|
|
426
|
-
.withViewportMargin(8);
|
|
427
|
-
}
|
|
428
|
-
function getActualPosition(change) {
|
|
429
|
-
const { originX, originY, overlayX, overlayY } = change.connectionPair;
|
|
430
|
-
if (overlayY === 'bottom' && originY === 'top') {
|
|
431
|
-
if (originX === 'start' && overlayX === 'start') {
|
|
432
|
-
return 'top-left';
|
|
433
|
-
}
|
|
434
|
-
if (originX === 'end' && overlayX === 'end') {
|
|
435
|
-
return 'top-right';
|
|
436
|
-
}
|
|
437
|
-
return 'top';
|
|
438
|
-
}
|
|
439
|
-
if (overlayY === 'top' && originY === 'bottom') {
|
|
440
|
-
if (originX === 'start' && overlayX === 'start') {
|
|
441
|
-
return 'bottom-left';
|
|
442
|
-
}
|
|
443
|
-
if (originX === 'end' && overlayX === 'end') {
|
|
444
|
-
return 'bottom-right';
|
|
445
|
-
}
|
|
446
|
-
return 'bottom';
|
|
447
|
-
}
|
|
448
|
-
if (overlayX === 'end' && originX === 'start') {
|
|
449
|
-
if (originY === 'top' && overlayY === 'top') {
|
|
450
|
-
return 'left-top';
|
|
451
|
-
}
|
|
452
|
-
if (originY === 'bottom' && overlayY === 'bottom') {
|
|
453
|
-
return 'left-bottom';
|
|
454
|
-
}
|
|
455
|
-
return 'left';
|
|
456
|
-
}
|
|
457
|
-
if (overlayX === 'start' && originX === 'end') {
|
|
458
|
-
if (originY === 'top' && overlayY === 'top') {
|
|
459
|
-
return 'right-top';
|
|
460
|
-
}
|
|
461
|
-
if (originY === 'bottom' && overlayY === 'bottom') {
|
|
462
|
-
return 'right-bottom';
|
|
463
|
-
}
|
|
464
|
-
return 'right';
|
|
465
|
-
}
|
|
466
|
-
return 'top';
|
|
297
|
+
return Z_OVERLAY_FALLBACK_ORDER[position];
|
|
467
298
|
}
|
|
468
299
|
|
|
469
300
|
const Z_TOOLTIP_ANIMATION_DURATION = 150;
|
|
@@ -527,8 +358,7 @@ class ZTooltipDirective {
|
|
|
527
358
|
...(ngDevMode ? [{ debugName: "_offset" }] : /* istanbul ignore next */ []));
|
|
528
359
|
zShow = output();
|
|
529
360
|
zHide = output();
|
|
530
|
-
|
|
531
|
-
_overlayPositionBuilder = inject(OverlayPositionBuilder);
|
|
361
|
+
_overlayService = inject(ZOverlayService);
|
|
532
362
|
_elementRef = inject((ElementRef));
|
|
533
363
|
_renderer = inject(Renderer2);
|
|
534
364
|
_destroyRef = inject(DestroyRef);
|
|
@@ -538,7 +368,7 @@ class ZTooltipDirective {
|
|
|
538
368
|
_componentRef = null;
|
|
539
369
|
_delaySubject = new Subject();
|
|
540
370
|
_listenerCleanups = [];
|
|
541
|
-
|
|
371
|
+
_autoUpdateCleanup = null;
|
|
542
372
|
_hideTimeout = null;
|
|
543
373
|
_isVisible = signal(false, /* @ts-ignore */
|
|
544
374
|
...(ngDevMode ? [{ debugName: "_isVisible" }] : /* istanbul ignore next */ []));
|
|
@@ -672,17 +502,12 @@ class ZTooltipDirective {
|
|
|
672
502
|
}
|
|
673
503
|
this.show();
|
|
674
504
|
}
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
const positionStrategy = createTooltipPositionStrategy(this._overlayPositionBuilder, anchorElement, this._position(), this._offset());
|
|
678
|
-
return this._overlay.create({
|
|
679
|
-
positionStrategy,
|
|
680
|
-
scrollStrategy: this._overlay.scrollStrategies.reposition(),
|
|
681
|
-
});
|
|
505
|
+
_getAnchorElement() {
|
|
506
|
+
return this.zTriggerElement() ?? this._elementRef.nativeElement;
|
|
682
507
|
}
|
|
683
508
|
_disposeOverlay() {
|
|
684
|
-
this.
|
|
685
|
-
this.
|
|
509
|
+
this._autoUpdateCleanup?.();
|
|
510
|
+
this._autoUpdateCleanup = null;
|
|
686
511
|
this._overlayRef?.dispose();
|
|
687
512
|
this._overlayRef = null;
|
|
688
513
|
this._componentRef = null;
|
|
@@ -692,7 +517,7 @@ class ZTooltipDirective {
|
|
|
692
517
|
.pipe(switchMap(config => (config.delay <= 0 ? of(config) : timer(config.delay).pipe(map(() => config)))), takeUntilDestroyed(this._destroyRef))
|
|
693
518
|
.subscribe(config => {
|
|
694
519
|
if (config.show) {
|
|
695
|
-
this._showTooltip();
|
|
520
|
+
void this._showTooltip();
|
|
696
521
|
return;
|
|
697
522
|
}
|
|
698
523
|
this._hideTooltip();
|
|
@@ -734,7 +559,7 @@ class ZTooltipDirective {
|
|
|
734
559
|
_delay(show, delay) {
|
|
735
560
|
this._delaySubject.next({ show, delay });
|
|
736
561
|
}
|
|
737
|
-
_showTooltip() {
|
|
562
|
+
async _showTooltip() {
|
|
738
563
|
const content = this.zContent();
|
|
739
564
|
if (!content || this._disabled()) {
|
|
740
565
|
return;
|
|
@@ -746,14 +571,10 @@ class ZTooltipDirective {
|
|
|
746
571
|
return;
|
|
747
572
|
}
|
|
748
573
|
if (!this._overlayRef) {
|
|
749
|
-
this._overlayRef = this.
|
|
574
|
+
this._overlayRef = this._overlayService.createAnchored();
|
|
750
575
|
this._setupOutsideClick();
|
|
751
576
|
}
|
|
752
|
-
|
|
753
|
-
const positionStrategy = createTooltipPositionStrategy(this._overlayPositionBuilder, anchorElement, this._position(), this._offset());
|
|
754
|
-
this._overlayRef.updatePositionStrategy(positionStrategy);
|
|
755
|
-
const portal = new ComponentPortal(ZTooltipContentComponent);
|
|
756
|
-
this._componentRef = this._overlayRef.attach(portal);
|
|
577
|
+
this._componentRef = this._overlayRef.attach(ZTooltipContentComponent);
|
|
757
578
|
this._componentRef.instance.setProps({
|
|
758
579
|
content,
|
|
759
580
|
position: this._position(),
|
|
@@ -763,10 +584,12 @@ class ZTooltipDirective {
|
|
|
763
584
|
arrow: this._arrow(),
|
|
764
585
|
maxWidth: this.zMaxWidth(),
|
|
765
586
|
});
|
|
766
|
-
this.
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
587
|
+
await this._applyPosition();
|
|
588
|
+
if (!this._overlayRef || !this._componentRef) {
|
|
589
|
+
return; // đã bị dispose (hide/destroy) trong lúc chờ computePosition
|
|
590
|
+
}
|
|
591
|
+
this._autoUpdateCleanup = startZOverlayAutoUpdate(this._getAnchorElement(), this._overlayRef.overlayElement, () => {
|
|
592
|
+
void this._applyPosition();
|
|
770
593
|
});
|
|
771
594
|
if (this._trigger() === 'hover') {
|
|
772
595
|
this._setupTooltipHover();
|
|
@@ -774,6 +597,29 @@ class ZTooltipDirective {
|
|
|
774
597
|
this._isVisible.set(true);
|
|
775
598
|
this.zShow.emit();
|
|
776
599
|
}
|
|
600
|
+
async _applyPosition() {
|
|
601
|
+
if (!this._overlayRef || !this._componentRef) {
|
|
602
|
+
return;
|
|
603
|
+
}
|
|
604
|
+
const anchorElement = this._getAnchorElement();
|
|
605
|
+
const floatingElement = this._overlayRef.overlayElement;
|
|
606
|
+
const fallbackPlacements = getTooltipFallbackPlacements(anchorElement, this._position(), this._offset());
|
|
607
|
+
const result = await computeZOverlayPlacement({
|
|
608
|
+
reference: anchorElement,
|
|
609
|
+
floating: floatingElement,
|
|
610
|
+
placement: this._position(),
|
|
611
|
+
fallbackPlacements,
|
|
612
|
+
offset: this._offset(),
|
|
613
|
+
flexibleDimensions: true,
|
|
614
|
+
});
|
|
615
|
+
if (!this._componentRef) {
|
|
616
|
+
return;
|
|
617
|
+
}
|
|
618
|
+
floatingElement.style.left = `${result.x}px`;
|
|
619
|
+
floatingElement.style.top = `${result.y}px`;
|
|
620
|
+
this._componentRef.instance.position.set(result.placement);
|
|
621
|
+
this._calculateArrowOffset(result.placement);
|
|
622
|
+
}
|
|
777
623
|
_setupTooltipHover() {
|
|
778
624
|
const overlayElement = this._overlayRef?.overlayElement;
|
|
779
625
|
if (!overlayElement) {
|
|
@@ -815,27 +661,11 @@ class ZTooltipDirective {
|
|
|
815
661
|
if (!this._overlayRef || !this._componentRef) {
|
|
816
662
|
return;
|
|
817
663
|
}
|
|
818
|
-
const triggerElement = this.
|
|
664
|
+
const triggerElement = this._getAnchorElement();
|
|
819
665
|
const triggerRect = triggerElement.getBoundingClientRect();
|
|
820
666
|
const tooltipRect = this._overlayRef.overlayElement.getBoundingClientRect();
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
const triggerCenterX = triggerRect.left + triggerRect.width / 2;
|
|
824
|
-
const tooltipCenterX = tooltipRect.left + tooltipRect.width / 2;
|
|
825
|
-
offset = triggerCenterX - tooltipCenterX;
|
|
826
|
-
}
|
|
827
|
-
if (position === 'left' || position === 'right') {
|
|
828
|
-
const triggerCenterY = triggerRect.top + triggerRect.height / 2;
|
|
829
|
-
const tooltipCenterY = tooltipRect.top + tooltipRect.height / 2;
|
|
830
|
-
offset = triggerCenterY - tooltipCenterY;
|
|
831
|
-
}
|
|
832
|
-
const maxOffset = position === 'top' || position === 'bottom' ? tooltipRect.width / 2 - 12 : tooltipRect.height / 2 - 12;
|
|
833
|
-
offset = Math.max(-maxOffset, Math.min(maxOffset, offset));
|
|
834
|
-
if (Math.abs(offset) > 1) {
|
|
835
|
-
this._componentRef.instance.arrowOffset.set(offset);
|
|
836
|
-
return;
|
|
837
|
-
}
|
|
838
|
-
this._componentRef.instance.arrowOffset.set(0);
|
|
667
|
+
const offset = computeZOverlayArrowOffset({ triggerRect, overlayRect: tooltipRect, placement: position });
|
|
668
|
+
this._componentRef.instance.arrowOffset.set(offset);
|
|
839
669
|
}
|
|
840
670
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.2", ngImport: i0, type: ZTooltipDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
841
671
|
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.1.2", type: ZTooltipDirective, isStandalone: true, selector: "[z-tooltip], [zTooltip]", inputs: { zContent: { classPropertyName: "zContent", publicName: "zContent", isSignal: true, isRequired: false, transformFunction: null }, zPosition: { classPropertyName: "zPosition", publicName: "zPosition", isSignal: true, isRequired: false, transformFunction: null }, zTooltipPosition: { classPropertyName: "zTooltipPosition", publicName: "zTooltipPosition", isSignal: true, isRequired: false, transformFunction: null }, zTrigger: { classPropertyName: "zTrigger", publicName: "zTrigger", isSignal: true, isRequired: false, transformFunction: null }, zTooltipTrigger: { classPropertyName: "zTooltipTrigger", publicName: "zTooltipTrigger", isSignal: true, isRequired: false, transformFunction: null }, zType: { classPropertyName: "zType", publicName: "zTooltipType", isSignal: true, isRequired: false, transformFunction: null }, zSize: { classPropertyName: "zSize", publicName: "zTooltipSize", isSignal: true, isRequired: false, transformFunction: null }, zClass: { classPropertyName: "zClass", publicName: "zClass", isSignal: true, isRequired: false, transformFunction: null }, zTooltipClass: { classPropertyName: "zTooltipClass", publicName: "zTooltipClass", isSignal: true, isRequired: false, transformFunction: null }, zShowDelay: { classPropertyName: "zShowDelay", publicName: "zShowDelay", isSignal: true, isRequired: false, transformFunction: null }, zTooltipShowDelay: { classPropertyName: "zTooltipShowDelay", publicName: "zTooltipShowDelay", isSignal: true, isRequired: false, transformFunction: null }, zHideDelay: { classPropertyName: "zHideDelay", publicName: "zHideDelay", isSignal: true, isRequired: false, transformFunction: null }, zTooltipHideDelay: { classPropertyName: "zTooltipHideDelay", publicName: "zTooltipHideDelay", isSignal: true, isRequired: false, transformFunction: null }, zArrow: { classPropertyName: "zArrow", publicName: "zArrow", isSignal: true, isRequired: false, transformFunction: null }, zTooltipArrow: { classPropertyName: "zTooltipArrow", publicName: "zTooltipArrow", isSignal: true, isRequired: false, transformFunction: null }, zDisabled: { classPropertyName: "zDisabled", publicName: "zDisabled", isSignal: true, isRequired: false, transformFunction: null }, zTooltipDisabled: { classPropertyName: "zTooltipDisabled", publicName: "zTooltipDisabled", isSignal: true, isRequired: false, transformFunction: null }, zOffset: { classPropertyName: "zOffset", publicName: "zOffset", isSignal: true, isRequired: false, transformFunction: null }, zTooltipOffset: { classPropertyName: "zTooltipOffset", publicName: "zTooltipOffset", isSignal: true, isRequired: false, transformFunction: null }, zAutoDetect: { classPropertyName: "zAutoDetect", publicName: "zAutoDetect", isSignal: true, isRequired: false, transformFunction: null }, zTriggerElement: { classPropertyName: "zTriggerElement", publicName: "zTriggerElement", isSignal: true, isRequired: false, transformFunction: null }, zAlwaysShow: { classPropertyName: "zAlwaysShow", publicName: "zAlwaysShow", isSignal: true, isRequired: false, transformFunction: null }, zMaxWidth: { classPropertyName: "zMaxWidth", publicName: "zMaxWidth", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { zShow: "zShow", zHide: "zHide" }, exportAs: ["zTooltip"], ngImport: i0 });
|