@ngbase/adk 0.1.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/README.md +57 -0
- package/a11y/accessibility-group.d.ts +49 -0
- package/a11y/accessibility-item.d.ts +49 -0
- package/a11y/accessibility.service.d.ts +17 -0
- package/a11y/autofocus.d.ts +12 -0
- package/a11y/focus-trap.d.ts +15 -0
- package/a11y/index.d.ts +5 -0
- package/a11y/public-api.d.ts +4 -0
- package/accordion/accordion-content.d.ts +8 -0
- package/accordion/accordion-group.d.ts +10 -0
- package/accordion/accordion-header.d.ts +7 -0
- package/accordion/accordion-item.d.ts +10 -0
- package/accordion/index.d.ts +5 -0
- package/accordion/public-api.d.ts +4 -0
- package/autocomplete/autocomplete-input.d.ts +21 -0
- package/autocomplete/autocomplete.d.ts +25 -0
- package/autocomplete/index.d.ts +5 -0
- package/autocomplete/public-api.d.ts +2 -0
- package/avatar/avatar.d.ts +22 -0
- package/avatar/index.d.ts +5 -0
- package/avatar/public-api.d.ts +1 -0
- package/bidi/direction.service.d.ts +14 -0
- package/bidi/index.d.ts +5 -0
- package/bidi/public-api.d.ts +1 -0
- package/breadcrumb/breadcrumb-link.d.ts +7 -0
- package/breadcrumb/breadcrumb-separator.d.ts +10 -0
- package/breadcrumb/breadcrumb.d.ts +12 -0
- package/breadcrumb/breadcrumbs.d.ts +7 -0
- package/breadcrumb/index.d.ts +5 -0
- package/breadcrumb/public-api.d.ts +4 -0
- package/cache/cache-config.d.ts +22 -0
- package/cache/cache.d.ts +17 -0
- package/cache/cache.interecptor.d.ts +2 -0
- package/cache/index.d.ts +5 -0
- package/cache/public-api.d.ts +3 -0
- package/carousel/carousel-item.d.ts +7 -0
- package/carousel/carousel-next.d.ts +8 -0
- package/carousel/carousel.d.ts +61 -0
- package/carousel/index.d.ts +5 -0
- package/carousel/public-api.d.ts +3 -0
- package/checkbox/checkbox.d.ts +22 -0
- package/checkbox/index.d.ts +5 -0
- package/checkbox/public-api.d.ts +1 -0
- package/chip/chip-group.d.ts +7 -0
- package/chip/chip.d.ts +19 -0
- package/chip/index.d.ts +5 -0
- package/chip/public-api.d.ts +2 -0
- package/clipboard/clipboard.d.ts +7 -0
- package/clipboard/index.d.ts +5 -0
- package/clipboard/public-api.d.ts +1 -0
- package/collections/SelectionModel.d.ts +14 -0
- package/collections/index.d.ts +5 -0
- package/collections/public-api.d.ts +1 -0
- package/color-picker/color-input.d.ts +16 -0
- package/color-picker/color-picker-trigger.d.ts +30 -0
- package/color-picker/color-picker.d.ts +72 -0
- package/color-picker/index.d.ts +5 -0
- package/color-picker/public-api.d.ts +3 -0
- package/color-picker/utils.d.ts +21 -0
- package/cookies/cookie.service.d.ts +32 -0
- package/cookies/index.d.ts +5 -0
- package/cookies/public-api.d.ts +1 -0
- package/datepicker/calendar.d.ts +121 -0
- package/datepicker/datepicker-trigger.d.ts +49 -0
- package/datepicker/datepicker.d.ts +54 -0
- package/datepicker/index.d.ts +5 -0
- package/datepicker/native-date-adapter.d.ts +33 -0
- package/datepicker/public-api.d.ts +5 -0
- package/datepicker/time.d.ts +42 -0
- package/dialog/dialog.animation.d.ts +3 -0
- package/dialog/dialog.d.ts +49 -0
- package/dialog/dialog.service.d.ts +7 -0
- package/dialog/index.d.ts +5 -0
- package/dialog/public-api.d.ts +3 -0
- package/drag/drag-drop.d.ts +37 -0
- package/drag/drag-move.d.ts +17 -0
- package/drag/drag.d.ts +53 -0
- package/drag/index.d.ts +5 -0
- package/drag/public-api.d.ts +3 -0
- package/fesm2022/ngbase-adk-a11y.mjs +617 -0
- package/fesm2022/ngbase-adk-a11y.mjs.map +1 -0
- package/fesm2022/ngbase-adk-accordion.mjs +117 -0
- package/fesm2022/ngbase-adk-accordion.mjs.map +1 -0
- package/fesm2022/ngbase-adk-autocomplete.mjs +150 -0
- package/fesm2022/ngbase-adk-autocomplete.mjs.map +1 -0
- package/fesm2022/ngbase-adk-avatar.mjs +69 -0
- package/fesm2022/ngbase-adk-avatar.mjs.map +1 -0
- package/fesm2022/ngbase-adk-bidi.mjs +42 -0
- package/fesm2022/ngbase-adk-bidi.mjs.map +1 -0
- package/fesm2022/ngbase-adk-breadcrumb.mjs +103 -0
- package/fesm2022/ngbase-adk-breadcrumb.mjs.map +1 -0
- package/fesm2022/ngbase-adk-cache.mjs +127 -0
- package/fesm2022/ngbase-adk-cache.mjs.map +1 -0
- package/fesm2022/ngbase-adk-carousel.mjs +337 -0
- package/fesm2022/ngbase-adk-carousel.mjs.map +1 -0
- package/fesm2022/ngbase-adk-checkbox.mjs +78 -0
- package/fesm2022/ngbase-adk-checkbox.mjs.map +1 -0
- package/fesm2022/ngbase-adk-chip.mjs +60 -0
- package/fesm2022/ngbase-adk-chip.mjs.map +1 -0
- package/fesm2022/ngbase-adk-clipboard.mjs +41 -0
- package/fesm2022/ngbase-adk-clipboard.mjs.map +1 -0
- package/fesm2022/ngbase-adk-collections.mjs +39 -0
- package/fesm2022/ngbase-adk-collections.mjs.map +1 -0
- package/fesm2022/ngbase-adk-color-picker.mjs +580 -0
- package/fesm2022/ngbase-adk-color-picker.mjs.map +1 -0
- package/fesm2022/ngbase-adk-cookies.mjs +81 -0
- package/fesm2022/ngbase-adk-cookies.mjs.map +1 -0
- package/fesm2022/ngbase-adk-datepicker.mjs +1130 -0
- package/fesm2022/ngbase-adk-datepicker.mjs.map +1 -0
- package/fesm2022/ngbase-adk-dialog.mjs +223 -0
- package/fesm2022/ngbase-adk-dialog.mjs.map +1 -0
- package/fesm2022/ngbase-adk-drag.mjs +406 -0
- package/fesm2022/ngbase-adk-drag.mjs.map +1 -0
- package/fesm2022/ngbase-adk-form-field.mjs +364 -0
- package/fesm2022/ngbase-adk-form-field.mjs.map +1 -0
- package/fesm2022/ngbase-adk-hover-card.mjs +79 -0
- package/fesm2022/ngbase-adk-hover-card.mjs.map +1 -0
- package/fesm2022/ngbase-adk-icon.mjs +90 -0
- package/fesm2022/ngbase-adk-icon.mjs.map +1 -0
- package/fesm2022/ngbase-adk-inline-edit.mjs +127 -0
- package/fesm2022/ngbase-adk-inline-edit.mjs.map +1 -0
- package/fesm2022/ngbase-adk-jwt.mjs +90 -0
- package/fesm2022/ngbase-adk-jwt.mjs.map +1 -0
- package/fesm2022/ngbase-adk-keys.mjs +219 -0
- package/fesm2022/ngbase-adk-keys.mjs.map +1 -0
- package/fesm2022/ngbase-adk-layout.mjs +100 -0
- package/fesm2022/ngbase-adk-layout.mjs.map +1 -0
- package/fesm2022/ngbase-adk-list.mjs +110 -0
- package/fesm2022/ngbase-adk-list.mjs.map +1 -0
- package/fesm2022/ngbase-adk-mask.mjs +234 -0
- package/fesm2022/ngbase-adk-mask.mjs.map +1 -0
- package/fesm2022/ngbase-adk-menu.mjs +546 -0
- package/fesm2022/ngbase-adk-menu.mjs.map +1 -0
- package/fesm2022/ngbase-adk-network.mjs +90 -0
- package/fesm2022/ngbase-adk-network.mjs.map +1 -0
- package/fesm2022/ngbase-adk-pagination.mjs +187 -0
- package/fesm2022/ngbase-adk-pagination.mjs.map +1 -0
- package/fesm2022/ngbase-adk-popover.mjs +953 -0
- package/fesm2022/ngbase-adk-popover.mjs.map +1 -0
- package/fesm2022/ngbase-adk-portal.mjs +279 -0
- package/fesm2022/ngbase-adk-portal.mjs.map +1 -0
- package/fesm2022/ngbase-adk-progress.mjs +57 -0
- package/fesm2022/ngbase-adk-progress.mjs.map +1 -0
- package/fesm2022/ngbase-adk-radio.mjs +129 -0
- package/fesm2022/ngbase-adk-radio.mjs.map +1 -0
- package/fesm2022/ngbase-adk-resizable.mjs +367 -0
- package/fesm2022/ngbase-adk-resizable.mjs.map +1 -0
- package/fesm2022/ngbase-adk-scroll-area.mjs +232 -0
- package/fesm2022/ngbase-adk-scroll-area.mjs.map +1 -0
- package/fesm2022/ngbase-adk-select.mjs +599 -0
- package/fesm2022/ngbase-adk-select.mjs.map +1 -0
- package/fesm2022/ngbase-adk-selectable.mjs +79 -0
- package/fesm2022/ngbase-adk-selectable.mjs.map +1 -0
- package/fesm2022/ngbase-adk-sidenav.mjs +209 -0
- package/fesm2022/ngbase-adk-sidenav.mjs.map +1 -0
- package/fesm2022/ngbase-adk-slider.mjs +337 -0
- package/fesm2022/ngbase-adk-slider.mjs.map +1 -0
- package/fesm2022/ngbase-adk-sonner.mjs +176 -0
- package/fesm2022/ngbase-adk-sonner.mjs.map +1 -0
- package/fesm2022/ngbase-adk-stepper.mjs +211 -0
- package/fesm2022/ngbase-adk-stepper.mjs.map +1 -0
- package/fesm2022/ngbase-adk-switch.mjs +115 -0
- package/fesm2022/ngbase-adk-switch.mjs.map +1 -0
- package/fesm2022/ngbase-adk-table.mjs +348 -0
- package/fesm2022/ngbase-adk-table.mjs.map +1 -0
- package/fesm2022/ngbase-adk-tabs.mjs +386 -0
- package/fesm2022/ngbase-adk-tabs.mjs.map +1 -0
- package/fesm2022/ngbase-adk-test.mjs +267 -0
- package/fesm2022/ngbase-adk-test.mjs.map +1 -0
- package/fesm2022/ngbase-adk-toggle-group.mjs +114 -0
- package/fesm2022/ngbase-adk-toggle-group.mjs.map +1 -0
- package/fesm2022/ngbase-adk-toggle.mjs +48 -0
- package/fesm2022/ngbase-adk-toggle.mjs.map +1 -0
- package/fesm2022/ngbase-adk-tooltip.mjs +237 -0
- package/fesm2022/ngbase-adk-tooltip.mjs.map +1 -0
- package/fesm2022/ngbase-adk-tour.mjs +312 -0
- package/fesm2022/ngbase-adk-tour.mjs.map +1 -0
- package/fesm2022/ngbase-adk-translate.mjs +162 -0
- package/fesm2022/ngbase-adk-translate.mjs.map +1 -0
- package/fesm2022/ngbase-adk-tree.mjs +301 -0
- package/fesm2022/ngbase-adk-tree.mjs.map +1 -0
- package/fesm2022/ngbase-adk-utils.mjs +228 -0
- package/fesm2022/ngbase-adk-utils.mjs.map +1 -0
- package/fesm2022/ngbase-adk-virtualizer.mjs +198 -0
- package/fesm2022/ngbase-adk-virtualizer.mjs.map +1 -0
- package/fesm2022/ngbase-adk.mjs +6 -0
- package/fesm2022/ngbase-adk.mjs.map +1 -0
- package/form-field/auto-height.d.ts +9 -0
- package/form-field/error.d.ts +18 -0
- package/form-field/form-field.d.ts +14 -0
- package/form-field/index.d.ts +5 -0
- package/form-field/input.d.ts +16 -0
- package/form-field/label.d.ts +7 -0
- package/form-field/otp.d.ts +48 -0
- package/form-field/public-api.d.ts +6 -0
- package/hover-card/hover-card.d.ts +18 -0
- package/hover-card/index.d.ts +5 -0
- package/hover-card/public-api.d.ts +1 -0
- package/icon/icon.d.ts +12 -0
- package/icon/icon.service.d.ts +12 -0
- package/icon/index.d.ts +5 -0
- package/icon/public-api.d.ts +2 -0
- package/index.d.ts +5 -0
- package/inline-edit/index.d.ts +5 -0
- package/inline-edit/inline-edit.d.ts +47 -0
- package/inline-edit/public-api.d.ts +1 -0
- package/jwt/index.d.ts +5 -0
- package/jwt/jwt.service.d.ts +27 -0
- package/jwt/public-api.d.ts +1 -0
- package/keys/index.d.ts +5 -0
- package/keys/keys.service.d.ts +13 -0
- package/keys/public-api.d.ts +2 -0
- package/keys/shortcuts.service.d.ts +38 -0
- package/layout/index.d.ts +5 -0
- package/layout/layout.d.ts +16 -0
- package/layout/public-api.d.ts +1 -0
- package/list/index.d.ts +5 -0
- package/list/list.d.ts +20 -0
- package/list/list.directive.d.ts +12 -0
- package/list/public-api.d.ts +2 -0
- package/mask/index.d.ts +5 -0
- package/mask/mask-pipe.d.ts +7 -0
- package/mask/mask.d.ts +25 -0
- package/mask/public-api.d.ts +2 -0
- package/menu/context-menu.d.ts +21 -0
- package/menu/index.d.ts +5 -0
- package/menu/mention.d.ts +18 -0
- package/menu/menu-trigger.d.ts +34 -0
- package/menu/menu.d.ts +52 -0
- package/menu/navigation-menu.d.ts +19 -0
- package/menu/public-api.d.ts +5 -0
- package/network/index.d.ts +5 -0
- package/network/network.interceptor.d.ts +6 -0
- package/network/network.service.d.ts +18 -0
- package/network/public-api.d.ts +2 -0
- package/package.json +247 -0
- package/pagination/index.d.ts +5 -0
- package/pagination/pagination.d.ts +28 -0
- package/pagination/public-api.d.ts +1 -0
- package/popover/base-popover.service.d.ts +16 -0
- package/popover/index.d.ts +5 -0
- package/popover/popover-trigger.d.ts +21 -0
- package/popover/popover.d.ts +50 -0
- package/popover/popover.service.d.ts +42 -0
- package/popover/public-api.d.ts +5 -0
- package/popover/utils.d.ts +85 -0
- package/portal/dialog-ref.d.ts +71 -0
- package/portal/index.d.ts +5 -0
- package/portal/portal-base.service.d.ts +19 -0
- package/portal/portal-close.directive.d.ts +8 -0
- package/portal/portal.component.d.ts +7 -0
- package/portal/portal.service.d.ts +16 -0
- package/portal/public-api.d.ts +5 -0
- package/progress/index.d.ts +5 -0
- package/progress/progress.d.ts +13 -0
- package/progress/public-api.d.ts +1 -0
- package/public-api.d.ts +2 -0
- package/radio/index.d.ts +5 -0
- package/radio/public-api.d.ts +2 -0
- package/radio/radio-group.d.ts +19 -0
- package/radio/radio.d.ts +22 -0
- package/resizable/index.d.ts +5 -0
- package/resizable/public-api.d.ts +2 -0
- package/resizable/resizable-group.d.ts +22 -0
- package/resizable/resizable.d.ts +50 -0
- package/scroll-area/index.d.ts +5 -0
- package/scroll-area/public-api.d.ts +1 -0
- package/scroll-area/scroll-area.d.ts +56 -0
- package/select/index.d.ts +5 -0
- package/select/list-selection.d.ts +7 -0
- package/select/option-group.d.ts +7 -0
- package/select/option.d.ts +25 -0
- package/select/public-api.d.ts +6 -0
- package/select/select-base.d.ts +64 -0
- package/select/select-input.d.ts +23 -0
- package/select/select.d.ts +50 -0
- package/selectable/index.d.ts +5 -0
- package/selectable/public-api.d.ts +2 -0
- package/selectable/selectable-item.d.ts +12 -0
- package/selectable/selectable.d.ts +19 -0
- package/sidenav/index.d.ts +5 -0
- package/sidenav/public-api.d.ts +3 -0
- package/sidenav/sidenav-header.d.ts +31 -0
- package/sidenav/sidenav.d.ts +23 -0
- package/sidenav/sidenav.service.d.ts +18 -0
- package/slider/index.d.ts +5 -0
- package/slider/public-api.d.ts +1 -0
- package/slider/slider.d.ts +73 -0
- package/sonner/index.d.ts +5 -0
- package/sonner/public-api.d.ts +2 -0
- package/sonner/sonner.d.ts +24 -0
- package/sonner/sonner.service.d.ts +21 -0
- package/stepper/animation.d.ts +1 -0
- package/stepper/index.d.ts +5 -0
- package/stepper/public-api.d.ts +3 -0
- package/stepper/step.d.ts +24 -0
- package/stepper/stepper.d.ts +26 -0
- package/switch/index.d.ts +5 -0
- package/switch/public-api.d.ts +1 -0
- package/switch/switch.d.ts +44 -0
- package/table/body-cell.d.ts +11 -0
- package/table/body-row.d.ts +21 -0
- package/table/column.d.ts +10 -0
- package/table/head-cell.d.ts +12 -0
- package/table/head-row.d.ts +21 -0
- package/table/index.d.ts +5 -0
- package/table/public-api.d.ts +8 -0
- package/table/table.d.ts +32 -0
- package/tabs/index.d.ts +5 -0
- package/tabs/public-api.d.ts +2 -0
- package/tabs/tab-group.d.ts +52 -0
- package/tabs/tab.d.ts +31 -0
- package/test/index.d.ts +5 -0
- package/test/public-api.d.ts +1 -0
- package/test/utils.d.ts +62 -0
- package/toggle/index.d.ts +5 -0
- package/toggle/public-api.d.ts +1 -0
- package/toggle/toggle.d.ts +13 -0
- package/toggle-group/index.d.ts +5 -0
- package/toggle-group/public-api.d.ts +2 -0
- package/toggle-group/toggle-group.d.ts +25 -0
- package/toggle-group/toggle-item.d.ts +14 -0
- package/tooltip/index.d.ts +5 -0
- package/tooltip/public-api.d.ts +2 -0
- package/tooltip/tooltip.d.ts +20 -0
- package/tooltip/tooltip.directive.d.ts +34 -0
- package/tooltip/tooltip.service.d.ts +26 -0
- package/tour/animation.d.ts +2 -0
- package/tour/index.d.ts +5 -0
- package/tour/public-api.d.ts +5 -0
- package/tour/tour-base.d.ts +21 -0
- package/tour/tour-step.d.ts +11 -0
- package/tour/tour.d.ts +9 -0
- package/tour/tour.service.d.ts +30 -0
- package/translate/config.d.ts +16 -0
- package/translate/index.d.ts +5 -0
- package/translate/public-api.d.ts +3 -0
- package/translate/translate.d.ts +11 -0
- package/translate/translate.service.d.ts +31 -0
- package/tree/index.d.ts +5 -0
- package/tree/public-api.d.ts +3 -0
- package/tree/tree-node.d.ts +28 -0
- package/tree/tree-toggle.d.ts +16 -0
- package/tree/tree.d.ts +55 -0
- package/utils/animation.d.ts +3 -0
- package/utils/disposals.d.ts +7 -0
- package/utils/index.d.ts +5 -0
- package/utils/number-only.d.ts +22 -0
- package/utils/public-api.d.ts +6 -0
- package/utils/range.pipe.d.ts +7 -0
- package/utils/ssr.d.ts +2 -0
- package/utils/utils.d.ts +27 -0
- package/virtualizer/index.d.ts +5 -0
- package/virtualizer/public-api.d.ts +1 -0
- package/virtualizer/virtualizer.d.ts +42 -0
|
@@ -0,0 +1,953 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { inject, linkedSignal, Directive, viewChild, ViewContainerRef, ElementRef, signal, effect, Component, ChangeDetectionStrategy, InjectionToken, input } from '@angular/core';
|
|
3
|
+
import * as i2 from '@ngbase/adk/portal';
|
|
4
|
+
import { basePortal, BaseDialog, NgbPortalClose, DialogOptions } from '@ngbase/adk/portal';
|
|
5
|
+
import { trigger, state, style, transition, animate } from '@angular/animations';
|
|
6
|
+
import * as i1 from '@ngbase/adk/a11y';
|
|
7
|
+
import { FocusTrap } from '@ngbase/adk/a11y';
|
|
8
|
+
import { disposals, createHostAnimation } from '@ngbase/adk/utils';
|
|
9
|
+
import { switchMap, fromEvent, map, startWith, EMPTY } from 'rxjs';
|
|
10
|
+
|
|
11
|
+
function basePopoverPortal(component) {
|
|
12
|
+
const NAME = 'popover';
|
|
13
|
+
const base = basePortal(NAME, component);
|
|
14
|
+
function open(component, options) {
|
|
15
|
+
const { diaRef, parent, replace, childSignal } = base.open(component, (comp, opt) => {
|
|
16
|
+
const compInst = comp.instance;
|
|
17
|
+
compInst.setOptions(opt);
|
|
18
|
+
}, options);
|
|
19
|
+
return {
|
|
20
|
+
diaRef,
|
|
21
|
+
events: parent.instance.events,
|
|
22
|
+
parent: parent.instance,
|
|
23
|
+
replace,
|
|
24
|
+
childSignal,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function closeAll() {
|
|
28
|
+
base.closeAll();
|
|
29
|
+
}
|
|
30
|
+
return { open, closeAll };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const positionSwap = {
|
|
34
|
+
top: 'bottom',
|
|
35
|
+
bottom: 'top',
|
|
36
|
+
left: 'right',
|
|
37
|
+
right: 'left',
|
|
38
|
+
tl: 'bl',
|
|
39
|
+
tr: 'br',
|
|
40
|
+
bl: 'tl',
|
|
41
|
+
br: 'tr',
|
|
42
|
+
};
|
|
43
|
+
var Position;
|
|
44
|
+
(function (Position) {
|
|
45
|
+
Position["Top"] = "top";
|
|
46
|
+
Position["Bottom"] = "bottom";
|
|
47
|
+
Position["Left"] = "left";
|
|
48
|
+
Position["Right"] = "right";
|
|
49
|
+
Position["TopLeft"] = "tl";
|
|
50
|
+
Position["TopRight"] = "tr";
|
|
51
|
+
Position["BottomLeft"] = "bl";
|
|
52
|
+
Position["BottomRight"] = "br";
|
|
53
|
+
})(Position || (Position = {}));
|
|
54
|
+
class PopoverPositioner {
|
|
55
|
+
constructor(config, windowDimensions, scrollWidth) {
|
|
56
|
+
this.config = config;
|
|
57
|
+
this.windowDimensions = windowDimensions;
|
|
58
|
+
this.scrollWidth = scrollWidth;
|
|
59
|
+
this.offset = this.config.offset || 5;
|
|
60
|
+
}
|
|
61
|
+
calculatePosition() {
|
|
62
|
+
const targetRect = this.getTargetRect();
|
|
63
|
+
const elRect = this.getElementRect();
|
|
64
|
+
this.elRect = elRect;
|
|
65
|
+
const initialPosition = this.getInitialPosition(targetRect, elRect, this.config.position || Position.Bottom);
|
|
66
|
+
const adjustedPosition = this.adjustForOverflow(initialPosition, targetRect, elRect);
|
|
67
|
+
return this.finalizePosition(adjustedPosition, elRect);
|
|
68
|
+
}
|
|
69
|
+
getTargetRect() {
|
|
70
|
+
if (this.config.client) {
|
|
71
|
+
const { x, y, w, h } = this.config.client;
|
|
72
|
+
return { top: y, left: x, width: w, height: h };
|
|
73
|
+
}
|
|
74
|
+
const { top, left, width, height } = this.config.target.getBoundingClientRect();
|
|
75
|
+
// return { top, left, width, height: Math.min(height, this.windowDimensions.height - top) };
|
|
76
|
+
return { top, left, width, height };
|
|
77
|
+
}
|
|
78
|
+
getElementRect() {
|
|
79
|
+
const el = this.config.el;
|
|
80
|
+
return {
|
|
81
|
+
top: 0,
|
|
82
|
+
left: 0,
|
|
83
|
+
width: el.clientWidth,
|
|
84
|
+
height: el.clientHeight,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
getInitialPosition(targetRect, elRect, position) {
|
|
88
|
+
const coords = this.getCoordinatesForPosition(position, targetRect, elRect, this.offset);
|
|
89
|
+
// coords.left = Math.max(0, coords.left);
|
|
90
|
+
// coords.top = Math.max(0, coords.top);
|
|
91
|
+
return { ...coords, position };
|
|
92
|
+
}
|
|
93
|
+
getCoordinatesForPosition(position, targetRect, elRect, offset) {
|
|
94
|
+
switch (position) {
|
|
95
|
+
case Position.Top:
|
|
96
|
+
return {
|
|
97
|
+
top: targetRect.top - elRect.height - offset,
|
|
98
|
+
left: targetRect.left + (targetRect.width - elRect.width) / 2,
|
|
99
|
+
};
|
|
100
|
+
case Position.Bottom:
|
|
101
|
+
return {
|
|
102
|
+
top: targetRect.top + targetRect.height + offset,
|
|
103
|
+
left: targetRect.left + (targetRect.width - elRect.width) / 2,
|
|
104
|
+
};
|
|
105
|
+
case Position.Left:
|
|
106
|
+
return { top: targetRect.top, left: targetRect.left - elRect.width - offset };
|
|
107
|
+
case Position.Right:
|
|
108
|
+
return { top: targetRect.top, left: targetRect.left + targetRect.width + offset };
|
|
109
|
+
case Position.TopLeft:
|
|
110
|
+
return { top: targetRect.top - elRect.height - offset, left: targetRect.left };
|
|
111
|
+
case Position.TopRight:
|
|
112
|
+
return {
|
|
113
|
+
top: targetRect.top - elRect.height - offset,
|
|
114
|
+
left: targetRect.left - (elRect.width - targetRect.width),
|
|
115
|
+
};
|
|
116
|
+
case Position.BottomLeft:
|
|
117
|
+
return { top: targetRect.top + targetRect.height + offset, left: targetRect.left };
|
|
118
|
+
case Position.BottomRight:
|
|
119
|
+
return {
|
|
120
|
+
top: targetRect.top + targetRect.height + offset,
|
|
121
|
+
left: targetRect.left - (elRect.width - targetRect.width),
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
adjustForOverflow(position, targetRect, elRect) {
|
|
126
|
+
const overflow = this.checkOverflow(position, elRect, targetRect);
|
|
127
|
+
this.overflow = overflow;
|
|
128
|
+
if (overflow.any) {
|
|
129
|
+
const newPosition = this.getAlternativePosition(position.position, overflow);
|
|
130
|
+
return this.getInitialPosition(targetRect, elRect, newPosition);
|
|
131
|
+
}
|
|
132
|
+
return position;
|
|
133
|
+
}
|
|
134
|
+
checkOverflow(position, elRect, targetRect) {
|
|
135
|
+
// Calculate available space on all sides
|
|
136
|
+
const topSpace = position.top;
|
|
137
|
+
const bottomSpace = this.windowDimensions.height - position.top;
|
|
138
|
+
const leftSpace = position.left;
|
|
139
|
+
const rightSpace = this.windowDimensions.width - position.left;
|
|
140
|
+
// Calculate overflow amounts (negative means no overflow)
|
|
141
|
+
const topOverflow = -(targetRect.top - elRect.height);
|
|
142
|
+
const bottomOverflow = targetRect.top + targetRect.height + elRect.height - this.windowDimensions.height;
|
|
143
|
+
// const leftOverflow = -(position.left - (elRect.width - targetRect.width));
|
|
144
|
+
const leftOverflow = -(targetRect.left + targetRect.width - elRect.width);
|
|
145
|
+
const leftSideOverflow = -(targetRect.left - elRect.width);
|
|
146
|
+
const rightOverflow = targetRect.left + elRect.width - this.windowDimensions.width;
|
|
147
|
+
const rightSideOverflow = -(targetRect.left + targetRect.width - elRect.width);
|
|
148
|
+
const isTop = topOverflow > 0;
|
|
149
|
+
const isBottom = bottomOverflow > 0;
|
|
150
|
+
const isLeft = leftOverflow > 0;
|
|
151
|
+
const isRight = rightOverflow > 0;
|
|
152
|
+
const isLeftSide = leftSideOverflow > 0;
|
|
153
|
+
const isRightSide = rightSideOverflow > 0;
|
|
154
|
+
let preferredHorizontal;
|
|
155
|
+
let preferredVertical;
|
|
156
|
+
// If both left and right overflow, determine which side has more space
|
|
157
|
+
if (isLeft || isRight) {
|
|
158
|
+
preferredHorizontal = leftOverflow > rightOverflow ? 'right' : 'left';
|
|
159
|
+
}
|
|
160
|
+
else if (isLeftSide || isRightSide) {
|
|
161
|
+
preferredHorizontal = leftSideOverflow > rightSideOverflow ? 'right' : 'left';
|
|
162
|
+
}
|
|
163
|
+
// If both top and bottom overflow, determine which side has more space
|
|
164
|
+
if (isTop || isBottom) {
|
|
165
|
+
preferredVertical = topOverflow > bottomOverflow ? 'bottom' : 'top';
|
|
166
|
+
}
|
|
167
|
+
return {
|
|
168
|
+
top: isTop,
|
|
169
|
+
bottom: isBottom,
|
|
170
|
+
left: isLeft,
|
|
171
|
+
right: isRight,
|
|
172
|
+
leftSide: isLeftSide,
|
|
173
|
+
rightSide: isRightSide,
|
|
174
|
+
any: isTop || isBottom || isLeft || isRight || isLeftSide || isRightSide,
|
|
175
|
+
preferredHorizontal,
|
|
176
|
+
preferredVertical,
|
|
177
|
+
overflowAmount: {
|
|
178
|
+
top: topOverflow,
|
|
179
|
+
bottom: bottomOverflow,
|
|
180
|
+
left: leftOverflow,
|
|
181
|
+
right: rightOverflow,
|
|
182
|
+
leftSide: leftSideOverflow,
|
|
183
|
+
rightSide: rightSideOverflow,
|
|
184
|
+
},
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
getAlternativePosition(position, overflow) {
|
|
188
|
+
// if (overflow.top) {
|
|
189
|
+
// if (position === Position.Top) {
|
|
190
|
+
// return Position.Bottom;
|
|
191
|
+
// }
|
|
192
|
+
// }
|
|
193
|
+
// if (
|
|
194
|
+
// (overflow.preferredVertical === 'top' || !overflow.bottom) &&
|
|
195
|
+
// (overflow.preferredHorizontal === 'left' || !overflow.right)
|
|
196
|
+
// ) {
|
|
197
|
+
// return Position.BottomRight;
|
|
198
|
+
// }
|
|
199
|
+
// if (
|
|
200
|
+
// (overflow.preferredVertical === 'top' || !overflow.bottom) &&
|
|
201
|
+
// (overflow.preferredHorizontal === 'right' || !overflow.left)
|
|
202
|
+
// ) {
|
|
203
|
+
// return Position.BottomLeft;
|
|
204
|
+
// }
|
|
205
|
+
// if (
|
|
206
|
+
// (overflow.preferredVertical === 'bottom' || !overflow.top) &&
|
|
207
|
+
// (overflow.preferredHorizontal === 'left' || !overflow.right)
|
|
208
|
+
// ) {
|
|
209
|
+
// return Position.TopRight;
|
|
210
|
+
// }
|
|
211
|
+
// if (
|
|
212
|
+
// (overflow.preferredVertical === 'bottom' || !overflow.top) &&
|
|
213
|
+
// (overflow.preferredHorizontal === 'right' || !overflow.left)
|
|
214
|
+
// ) {
|
|
215
|
+
// return Position.TopLeft;
|
|
216
|
+
// }
|
|
217
|
+
// if (overflow.bottom) {
|
|
218
|
+
// if (position.includes('bottom')) {
|
|
219
|
+
// return positionSwap[position] as Position;
|
|
220
|
+
// } else if (position.includes('bl') && overflow.preferredVertical === 'top') {
|
|
221
|
+
// return overflow.right && overflow.preferredHorizontal !== 'right'
|
|
222
|
+
// ? Position.TopRight
|
|
223
|
+
// : Position.TopLeft;
|
|
224
|
+
// } else if (position.includes('bl') && overflow.preferredVertical === 'bottom') {
|
|
225
|
+
// return overflow.right && overflow.preferredHorizontal !== 'right'
|
|
226
|
+
// ? Position.BottomRight
|
|
227
|
+
// : Position.BottomLeft;
|
|
228
|
+
// }
|
|
229
|
+
// }
|
|
230
|
+
// if (overflow.left) {
|
|
231
|
+
// if (position === Position.Left) {
|
|
232
|
+
// return Position.Right;
|
|
233
|
+
// }
|
|
234
|
+
// if (overflow.preferredHorizontal === 'left' || !overflow.right) {
|
|
235
|
+
// return overflow.bottom ? Position.TopLeft : Position.BottomLeft;
|
|
236
|
+
// }
|
|
237
|
+
// if (overflow.preferredHorizontal === 'right') {
|
|
238
|
+
// return overflow.bottom ? Position.TopRight : Position.BottomRight;
|
|
239
|
+
// }
|
|
240
|
+
// }
|
|
241
|
+
// if (overflow.right) {
|
|
242
|
+
// if (position.includes('right')) {
|
|
243
|
+
// return !overflow.left
|
|
244
|
+
// ? Position.Left
|
|
245
|
+
// : overflow.bottom && !overflow.left
|
|
246
|
+
// ? (positionSwap[position] as Position)
|
|
247
|
+
// : overflow.left && overflow.bottom
|
|
248
|
+
// ? Position.Top
|
|
249
|
+
// : Position.BottomRight;
|
|
250
|
+
// } else if (position.includes('bl')) {
|
|
251
|
+
// return overflow.bottom ? Position.TopRight : Position.BottomRight;
|
|
252
|
+
// }
|
|
253
|
+
// }
|
|
254
|
+
// return position;
|
|
255
|
+
if (!overflow.any) {
|
|
256
|
+
return position;
|
|
257
|
+
}
|
|
258
|
+
// Simple mapping for opposite positions
|
|
259
|
+
const opposites = {
|
|
260
|
+
[Position.Top]: Position.Bottom,
|
|
261
|
+
[Position.Bottom]: Position.Top,
|
|
262
|
+
[Position.Left]: Position.Right,
|
|
263
|
+
[Position.Right]: Position.Left,
|
|
264
|
+
[Position.TopLeft]: Position.BottomRight,
|
|
265
|
+
[Position.TopRight]: Position.BottomLeft,
|
|
266
|
+
[Position.BottomLeft]: Position.TopRight,
|
|
267
|
+
[Position.BottomRight]: Position.TopLeft,
|
|
268
|
+
};
|
|
269
|
+
// For cardinal positions (Top, Bottom, Left, Right)
|
|
270
|
+
if ([Position.Top, Position.Bottom].includes(position)) {
|
|
271
|
+
return overflow.preferredVertical || opposites[position];
|
|
272
|
+
}
|
|
273
|
+
if ([Position.Left, Position.Right].includes(position)) {
|
|
274
|
+
return overflow.preferredHorizontal || opposites[position];
|
|
275
|
+
}
|
|
276
|
+
// For corner positions
|
|
277
|
+
const isTop = position.includes('t');
|
|
278
|
+
const isLeft = position.includes('l');
|
|
279
|
+
const vertical = overflow.preferredVertical === 'top' ? 't' : 'b';
|
|
280
|
+
const horizontal = overflow.preferredHorizontal === 'left' ? 'r' : 'l';
|
|
281
|
+
// If current position overflows, use the preferred directions
|
|
282
|
+
if ((isTop && overflow.top) ||
|
|
283
|
+
(!isTop && overflow.bottom) ||
|
|
284
|
+
(isLeft && overflow.left) ||
|
|
285
|
+
(!isLeft && overflow.right) ||
|
|
286
|
+
(horizontal === 'r' && overflow.right) ||
|
|
287
|
+
(horizontal === 'l' && overflow.left)) {
|
|
288
|
+
switch (vertical + horizontal) {
|
|
289
|
+
case 'tl':
|
|
290
|
+
return Position.TopLeft;
|
|
291
|
+
case 'tr':
|
|
292
|
+
return Position.TopRight;
|
|
293
|
+
case 'bl':
|
|
294
|
+
return Position.BottomLeft;
|
|
295
|
+
case 'br':
|
|
296
|
+
return Position.BottomRight;
|
|
297
|
+
default:
|
|
298
|
+
return opposites[position];
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
return position;
|
|
302
|
+
}
|
|
303
|
+
finalizePosition(position, elRect) {
|
|
304
|
+
const { top, left } = position;
|
|
305
|
+
const bottom = position.position.startsWith('t')
|
|
306
|
+
? this.windowDimensions.height - (top + elRect.height)
|
|
307
|
+
: undefined;
|
|
308
|
+
// this is required if tooltip is going outside of the screen horizontally
|
|
309
|
+
// this has to be done only if the position is top or bottom
|
|
310
|
+
let right;
|
|
311
|
+
right =
|
|
312
|
+
left + elRect.width > this.windowDimensions.width
|
|
313
|
+
? 0
|
|
314
|
+
: position.position.endsWith('r')
|
|
315
|
+
? this.windowDimensions.width - (left + elRect.width) - this.scrollWidth
|
|
316
|
+
: undefined;
|
|
317
|
+
let overallOffset = this.getOverallOffset(position);
|
|
318
|
+
let maxHeight;
|
|
319
|
+
if (position.position.startsWith('t') &&
|
|
320
|
+
this.overflow.overflowAmount.top > -overallOffset.vertical) {
|
|
321
|
+
maxHeight = this.elRect.height - this.overflow.overflowAmount.top - overallOffset.vertical;
|
|
322
|
+
}
|
|
323
|
+
else if (position.position.startsWith('b') &&
|
|
324
|
+
this.overflow.overflowAmount.bottom > -overallOffset.vertical) {
|
|
325
|
+
maxHeight = this.elRect.height - this.overflow.overflowAmount.bottom - overallOffset.vertical;
|
|
326
|
+
}
|
|
327
|
+
let maxWidth;
|
|
328
|
+
if (position.position.endsWith('l') &&
|
|
329
|
+
this.overflow.overflowAmount.right > -overallOffset.horizontal) {
|
|
330
|
+
maxWidth = this.elRect.width - this.overflow.overflowAmount.right - overallOffset.horizontal;
|
|
331
|
+
}
|
|
332
|
+
else if (position.position.endsWith('r') &&
|
|
333
|
+
this.overflow.overflowAmount.left > -overallOffset.horizontal) {
|
|
334
|
+
maxWidth = this.elRect.width - this.overflow.overflowAmount.left - overallOffset.horizontal;
|
|
335
|
+
}
|
|
336
|
+
return {
|
|
337
|
+
// top: Math.max(0, Math.min(top, this.windowDimensions.height - (maxHeight || elRect.height))),
|
|
338
|
+
top: Math.max(0, top),
|
|
339
|
+
bottom,
|
|
340
|
+
left: right ? 0 : Math.max(overallOffset.horizontal, left),
|
|
341
|
+
right: right ? Math.max(overallOffset.horizontal, right) : undefined,
|
|
342
|
+
position: position.position,
|
|
343
|
+
maxHeight,
|
|
344
|
+
maxWidth,
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
getOverallOffset(position) {
|
|
348
|
+
const overallOffset = this.config.sideOffset ?? 0;
|
|
349
|
+
const isHorizontal = position.position === 'left' || position.position === 'right';
|
|
350
|
+
return {
|
|
351
|
+
horizontal: overallOffset + (isHorizontal ? this.offset : 0),
|
|
352
|
+
vertical: overallOffset + (isHorizontal ? 0 : this.offset),
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
// Main function to use the class
|
|
357
|
+
function tooltipPosition(config, windowDimensions = {
|
|
358
|
+
width: window.innerWidth,
|
|
359
|
+
height: window.innerHeight,
|
|
360
|
+
}, scrollWidth = window.innerWidth - document.documentElement.clientWidth) {
|
|
361
|
+
const positioner = new PopoverPositioner(config, windowDimensions, scrollWidth);
|
|
362
|
+
return positioner.calculatePosition();
|
|
363
|
+
}
|
|
364
|
+
// export function tooltipPosition(config: OverlayConfig): {
|
|
365
|
+
// top: number;
|
|
366
|
+
// left: number;
|
|
367
|
+
// bottom?: number;
|
|
368
|
+
// right?: number;
|
|
369
|
+
// position: DialogPosition;
|
|
370
|
+
// } {
|
|
371
|
+
// const { target, el, position: priority = 'bottom', offset = 5, client: clientXY = null } = config;
|
|
372
|
+
// let position: DialogPosition = priority;
|
|
373
|
+
// let { top, left, width, height } = target.getBoundingClientRect();
|
|
374
|
+
// if (clientXY) {
|
|
375
|
+
// top = clientXY.y;
|
|
376
|
+
// left = clientXY.x;
|
|
377
|
+
// width = clientXY.w;
|
|
378
|
+
// height = clientXY.h;
|
|
379
|
+
// }
|
|
380
|
+
// const { clientWidth: elWidth, clientHeight: elHeight } = el!;
|
|
381
|
+
// // we need to check whether the height of the target element is greater than the height then we need to adjust the height
|
|
382
|
+
// if (height > window.innerHeight) {
|
|
383
|
+
// height = window.innerHeight - top;
|
|
384
|
+
// }
|
|
385
|
+
// return tooltipPositionInternal({
|
|
386
|
+
// top,
|
|
387
|
+
// left,
|
|
388
|
+
// width,
|
|
389
|
+
// height,
|
|
390
|
+
// elWidth,
|
|
391
|
+
// elHeight,
|
|
392
|
+
// offset,
|
|
393
|
+
// priority,
|
|
394
|
+
// position,
|
|
395
|
+
// windowWidth: window.innerWidth,
|
|
396
|
+
// windowHeight: window.innerHeight,
|
|
397
|
+
// scrollWidth: window.innerWidth - document.documentElement.clientWidth,
|
|
398
|
+
// });
|
|
399
|
+
// }
|
|
400
|
+
// export function tooltipPositionInternal(data: ConfigObj): {
|
|
401
|
+
// top: number;
|
|
402
|
+
// bottom?: number;
|
|
403
|
+
// left: number;
|
|
404
|
+
// right?: number;
|
|
405
|
+
// position: DialogPosition;
|
|
406
|
+
// } {
|
|
407
|
+
// let { elHeight, position, windowHeight, windowWidth, offset, elWidth, scrollWidth } = data;
|
|
408
|
+
// position = positionSwapBasedOnOverflow(data);
|
|
409
|
+
// let { top: topPos, left: leftPos } = getTooltipCoordinates(position, data);
|
|
410
|
+
// if (topPos <= 0) {
|
|
411
|
+
// topPos = offset;
|
|
412
|
+
// } else if (topPos + elHeight > windowHeight) {
|
|
413
|
+
// topPos = windowHeight - elHeight - offset;
|
|
414
|
+
// } else if (leftPos < 0) {
|
|
415
|
+
// leftPos = 0;
|
|
416
|
+
// }
|
|
417
|
+
// const bottomPos = position.startsWith('t') ? windowHeight - (topPos + elHeight) : undefined;
|
|
418
|
+
// const rightPos =
|
|
419
|
+
// leftPos + elWidth > windowWidth
|
|
420
|
+
// ? 0
|
|
421
|
+
// : position.endsWith('r')
|
|
422
|
+
// ? windowWidth - (leftPos + elWidth) - scrollWidth
|
|
423
|
+
// : undefined;
|
|
424
|
+
// return {
|
|
425
|
+
// top: topPos,
|
|
426
|
+
// bottom: bottomPos,
|
|
427
|
+
// left: rightPos ? 0 : leftPos,
|
|
428
|
+
// position,
|
|
429
|
+
// right: rightPos,
|
|
430
|
+
// };
|
|
431
|
+
// }
|
|
432
|
+
// function getTooltipCoordinates(
|
|
433
|
+
// position: DialogPosition,
|
|
434
|
+
// data: ConfigObj,
|
|
435
|
+
// ): { top: number; left: number } {
|
|
436
|
+
// const { top, left, width, height, elWidth, elHeight, offset } = data;
|
|
437
|
+
// switch (position) {
|
|
438
|
+
// case 'top':
|
|
439
|
+
// return {
|
|
440
|
+
// top: top - elHeight - offset,
|
|
441
|
+
// left: left + (width - elWidth) / 2,
|
|
442
|
+
// };
|
|
443
|
+
// case 'bottom':
|
|
444
|
+
// return { top: top + height + offset, left: left + (width - elWidth) / 2 };
|
|
445
|
+
// case 'left':
|
|
446
|
+
// return { top, left: left - elWidth - offset };
|
|
447
|
+
// case 'right':
|
|
448
|
+
// return { top, left: left + width + offset };
|
|
449
|
+
// case 'tl':
|
|
450
|
+
// return { top: top - elHeight - offset, left };
|
|
451
|
+
// case 'tr':
|
|
452
|
+
// return { top: top - elHeight - offset, left: left - (elWidth - width) };
|
|
453
|
+
// case 'bl':
|
|
454
|
+
// return { top: top + height + offset, left };
|
|
455
|
+
// case 'br':
|
|
456
|
+
// return { top: top + height + offset, left: left - (elWidth - width) };
|
|
457
|
+
// default:
|
|
458
|
+
// return {
|
|
459
|
+
// top: top - elHeight - offset,
|
|
460
|
+
// left: left + (width - elWidth) / 2,
|
|
461
|
+
// };
|
|
462
|
+
// }
|
|
463
|
+
// }
|
|
464
|
+
// // function to check the overflow sides for target and element
|
|
465
|
+
// export function checkOverflow(data: ConfigObj) {
|
|
466
|
+
// const isTop = data.top - data.elHeight < 0;
|
|
467
|
+
// const isBottom = data.top + data.height + data.elHeight > data.windowHeight;
|
|
468
|
+
// const isLeft = data.left - data.elWidth < 0;
|
|
469
|
+
// const isRight = data.left + data.width + data.elWidth > data.windowWidth;
|
|
470
|
+
// return { top: isTop, bottom: isBottom, left: isLeft, right: isRight };
|
|
471
|
+
// }
|
|
472
|
+
// // position swap based on the overflow and priority
|
|
473
|
+
// function positionSwapBasedOnOverflow(data: ConfigObj): DialogPosition {
|
|
474
|
+
// const {
|
|
475
|
+
// bottom: bottomOverflow,
|
|
476
|
+
// left: leftOverflow,
|
|
477
|
+
// right: rightOverflow,
|
|
478
|
+
// top: topOverflow,
|
|
479
|
+
// } = checkOverflow(data);
|
|
480
|
+
// const { priority } = data;
|
|
481
|
+
// let position = priority;
|
|
482
|
+
// if (topOverflow) {
|
|
483
|
+
// if (position.includes('top')) {
|
|
484
|
+
// position = positionSwap[position];
|
|
485
|
+
// }
|
|
486
|
+
// }
|
|
487
|
+
// if (bottomOverflow) {
|
|
488
|
+
// if (position.includes('bottom')) {
|
|
489
|
+
// position = positionSwap[position];
|
|
490
|
+
// } else if (position.includes('bl')) {
|
|
491
|
+
// position = rightOverflow ? 'tr' : 'tl';
|
|
492
|
+
// }
|
|
493
|
+
// }
|
|
494
|
+
// if (leftOverflow) {
|
|
495
|
+
// if (position.includes('left')) {
|
|
496
|
+
// position = positionSwap[position];
|
|
497
|
+
// }
|
|
498
|
+
// }
|
|
499
|
+
// if (rightOverflow) {
|
|
500
|
+
// if (position.includes('right')) {
|
|
501
|
+
// position = !leftOverflow
|
|
502
|
+
// ? 'left'
|
|
503
|
+
// : bottomOverflow && !leftOverflow
|
|
504
|
+
// ? positionSwap[position]
|
|
505
|
+
// : leftOverflow && bottomOverflow
|
|
506
|
+
// ? 'top'
|
|
507
|
+
// : 'br';
|
|
508
|
+
// } else if (position.includes('bl')) {
|
|
509
|
+
// position = bottomOverflow ? 'tr' : 'br';
|
|
510
|
+
// }
|
|
511
|
+
// }
|
|
512
|
+
// return position;
|
|
513
|
+
// }
|
|
514
|
+
|
|
515
|
+
class NgbPopoverBackdrop {
|
|
516
|
+
constructor() {
|
|
517
|
+
this.popover = inject(NgbPopover);
|
|
518
|
+
this.focusTrap = inject(FocusTrap);
|
|
519
|
+
this.focusTrap._focusTrap = linkedSignal(() => this.popover.options().focusTrap ?? true);
|
|
520
|
+
}
|
|
521
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgbPopoverBackdrop, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
522
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.0.0", type: NgbPopoverBackdrop, isStandalone: true, selector: "[ngbPopoverBackdrop]", host: { listeners: { "click": "!popover.options().disableClose && popover.close()" }, properties: { "style.clipPath": "popover.options().clipPath?.()", "class": "popover.options().backdropClassName" } }, hostDirectives: [{ directive: i1.FocusTrap }], ngImport: i0 }); }
|
|
523
|
+
}
|
|
524
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgbPopoverBackdrop, decorators: [{
|
|
525
|
+
type: Directive,
|
|
526
|
+
args: [{
|
|
527
|
+
selector: '[ngbPopoverBackdrop]',
|
|
528
|
+
hostDirectives: [FocusTrap],
|
|
529
|
+
host: {
|
|
530
|
+
'[style.clipPath]': 'popover.options().clipPath?.()',
|
|
531
|
+
'[class]': 'popover.options().backdropClassName',
|
|
532
|
+
'(click)': '!popover.options().disableClose && popover.close()',
|
|
533
|
+
},
|
|
534
|
+
}]
|
|
535
|
+
}], ctorParameters: () => [] });
|
|
536
|
+
class NgbPopoverMain {
|
|
537
|
+
constructor() {
|
|
538
|
+
this.popover = inject(NgbPopover);
|
|
539
|
+
}
|
|
540
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgbPopoverMain, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
541
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.0.0", type: NgbPopoverMain, isStandalone: true, selector: "[ngbPopoverMain]", host: { properties: { "class": "popover.options().className" } }, ngImport: i0 }); }
|
|
542
|
+
}
|
|
543
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgbPopoverMain, decorators: [{
|
|
544
|
+
type: Directive,
|
|
545
|
+
args: [{
|
|
546
|
+
selector: '[ngbPopoverMain]',
|
|
547
|
+
host: {
|
|
548
|
+
'[class]': 'popover.options().className',
|
|
549
|
+
},
|
|
550
|
+
}]
|
|
551
|
+
}] });
|
|
552
|
+
class NgbPopover extends BaseDialog {
|
|
553
|
+
constructor() {
|
|
554
|
+
super();
|
|
555
|
+
this.disposals = disposals();
|
|
556
|
+
this.myDialog = viewChild.required('myDialog', { read: ViewContainerRef });
|
|
557
|
+
this.container = viewChild.required(NgbPopoverMain, {
|
|
558
|
+
read: ElementRef,
|
|
559
|
+
});
|
|
560
|
+
this.backdropElement = viewChild(NgbPopoverBackdrop, { read: ElementRef });
|
|
561
|
+
this.options = signal({});
|
|
562
|
+
this.lastPosition = 'top';
|
|
563
|
+
this.scrolled = signal(0);
|
|
564
|
+
this.events = this._afterViewSource.pipe(switchMap(e => {
|
|
565
|
+
const el = this.container().nativeElement;
|
|
566
|
+
const mouseenter = fromEvent(el, 'mouseenter');
|
|
567
|
+
const mouseleave = fromEvent(el, 'mouseleave');
|
|
568
|
+
const event = mouseenter.pipe(switchMap(e => mouseleave.pipe(map(x => ({ type: 'mouseleave', value: x })), startWith({ type: 'mouseenter', value: e }))));
|
|
569
|
+
return e ? event : EMPTY;
|
|
570
|
+
}));
|
|
571
|
+
this.scheduleUpdateDimension = () => {
|
|
572
|
+
this.disposals.afterNextRender(() => this.updateDimension());
|
|
573
|
+
};
|
|
574
|
+
const dialog = effect(() => {
|
|
575
|
+
this._afterViewSource.next(this.myDialog());
|
|
576
|
+
dialog.destroy();
|
|
577
|
+
});
|
|
578
|
+
effect(cleanup => {
|
|
579
|
+
const el = this.container().nativeElement;
|
|
580
|
+
const options = this.options();
|
|
581
|
+
const target = this.getTarget();
|
|
582
|
+
if (options.anchor) {
|
|
583
|
+
options.offset = 16;
|
|
584
|
+
}
|
|
585
|
+
this.lastPosition = options.position || 'bottom';
|
|
586
|
+
// this.schedulePopoverUpdate(target, el);
|
|
587
|
+
if (options.smoothScroll) {
|
|
588
|
+
// target.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
|
|
589
|
+
// fromEvent(window, 'scroll')
|
|
590
|
+
// .pipe(
|
|
591
|
+
// startWith(1),
|
|
592
|
+
// tap((x) => console.count('scroll 50')),
|
|
593
|
+
// debounceTime(50),
|
|
594
|
+
// take(1),
|
|
595
|
+
// )
|
|
596
|
+
// .subscribe(() => {});
|
|
597
|
+
// fromEvent(window, 'scroll')
|
|
598
|
+
// .pipe(
|
|
599
|
+
// startWith(1),
|
|
600
|
+
// tap((x) => console.count('scroll 10')),
|
|
601
|
+
// debounceTime(10),
|
|
602
|
+
// take(1),
|
|
603
|
+
// )
|
|
604
|
+
// .subscribe(() => {
|
|
605
|
+
// this.scrolled.update((x) => x + 1);
|
|
606
|
+
// this.schedulePopoverUpdate(target, el);
|
|
607
|
+
// });
|
|
608
|
+
scrollToElement(target).then(() => {
|
|
609
|
+
this.scrolled.update(x => x + 1);
|
|
610
|
+
this.schedulePopoverUpdate(target, el, options);
|
|
611
|
+
});
|
|
612
|
+
}
|
|
613
|
+
else {
|
|
614
|
+
this.schedulePopoverUpdate(target, el, options);
|
|
615
|
+
}
|
|
616
|
+
// TODO: remove this once we have multi cleanup support
|
|
617
|
+
if (!options.backdrop) {
|
|
618
|
+
window.addEventListener('scroll', this.scheduleUpdateDimension);
|
|
619
|
+
cleanup(() => window.removeEventListener('scroll', this.scheduleUpdateDimension));
|
|
620
|
+
}
|
|
621
|
+
// observe the target element position change
|
|
622
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
623
|
+
// console.log('resizeObserver');
|
|
624
|
+
this.schedulePopoverUpdate(target, el, options);
|
|
625
|
+
});
|
|
626
|
+
resizeObserver.observe(target);
|
|
627
|
+
cleanup(() => resizeObserver.disconnect());
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
getTarget() {
|
|
631
|
+
return this.target() || this.options().target;
|
|
632
|
+
}
|
|
633
|
+
schedulePopoverUpdate(target, el, options) {
|
|
634
|
+
// this.options().target = target;
|
|
635
|
+
// if (options.backdrop) {
|
|
636
|
+
// this.onOpen();
|
|
637
|
+
// }
|
|
638
|
+
if (options.width === 'target') {
|
|
639
|
+
// update the width of the container to be the same as the target
|
|
640
|
+
el.style.width = `${target.offsetWidth}px`;
|
|
641
|
+
}
|
|
642
|
+
else if (options.width === 'free') {
|
|
643
|
+
el.style.minWidth = `${target.offsetWidth}px`;
|
|
644
|
+
}
|
|
645
|
+
else if (options.width) {
|
|
646
|
+
el.style.width = options.width;
|
|
647
|
+
}
|
|
648
|
+
if (options.height) {
|
|
649
|
+
el.style.height = options.height;
|
|
650
|
+
}
|
|
651
|
+
if (options.maxHeight) {
|
|
652
|
+
el.style.maxHeight = options.maxHeight;
|
|
653
|
+
}
|
|
654
|
+
this.scheduleUpdateDimension();
|
|
655
|
+
}
|
|
656
|
+
updateDimension() {
|
|
657
|
+
const el = this.container().nativeElement;
|
|
658
|
+
const target = this.getTarget();
|
|
659
|
+
if (!target) {
|
|
660
|
+
return;
|
|
661
|
+
}
|
|
662
|
+
const { top, bottom, left, right, position, maxHeight, maxWidth } = tooltipPosition({
|
|
663
|
+
target,
|
|
664
|
+
el,
|
|
665
|
+
position: this.lastPosition,
|
|
666
|
+
client: this.options().client,
|
|
667
|
+
offset: this.options().offset,
|
|
668
|
+
sideOffset: this.options().sideOffset,
|
|
669
|
+
});
|
|
670
|
+
// change the anchor position
|
|
671
|
+
if (this.options().anchor) {
|
|
672
|
+
this.updateAnchorPosition(position, el, target);
|
|
673
|
+
}
|
|
674
|
+
this.lastPosition = position;
|
|
675
|
+
// we need to update the values directly instead of signal to avoid too many CD checks
|
|
676
|
+
if (bottom) {
|
|
677
|
+
el.style.bottom = `${bottom}px`;
|
|
678
|
+
el.style.top = '';
|
|
679
|
+
}
|
|
680
|
+
else if (top) {
|
|
681
|
+
el.style.top = `${top}px`;
|
|
682
|
+
el.style.bottom = '';
|
|
683
|
+
}
|
|
684
|
+
if (right != undefined) {
|
|
685
|
+
el.style.right = `${right}px`;
|
|
686
|
+
el.style.left = '';
|
|
687
|
+
}
|
|
688
|
+
else {
|
|
689
|
+
el.style.left = `${left}px`;
|
|
690
|
+
el.style.right = '';
|
|
691
|
+
}
|
|
692
|
+
if (maxHeight) {
|
|
693
|
+
el.style.maxHeight = `${maxHeight}px`;
|
|
694
|
+
}
|
|
695
|
+
if (maxWidth) {
|
|
696
|
+
el.style.maxWidth = `${maxWidth}px`;
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
updateAnchorPosition(position, el, target) {
|
|
700
|
+
let deg = '0deg';
|
|
701
|
+
let anchorTop = '50%';
|
|
702
|
+
let anchorLeft = '50%';
|
|
703
|
+
const anchorWidth = 12.8;
|
|
704
|
+
const thHeight = target.offsetHeight / 2;
|
|
705
|
+
const thWidth = target.offsetWidth / 2;
|
|
706
|
+
switch (position) {
|
|
707
|
+
case 'top':
|
|
708
|
+
case 'tl':
|
|
709
|
+
case 'tr':
|
|
710
|
+
anchorTop = '100%';
|
|
711
|
+
break;
|
|
712
|
+
case 'left':
|
|
713
|
+
deg = '270deg';
|
|
714
|
+
anchorLeft = `calc(100% + ${anchorWidth / 2}px)`;
|
|
715
|
+
anchorTop = thHeight > el.clientHeight ? '50%' : `calc(${thHeight}px)`;
|
|
716
|
+
break;
|
|
717
|
+
case 'right':
|
|
718
|
+
deg = '90deg';
|
|
719
|
+
anchorLeft = `-${anchorWidth / 2}px`;
|
|
720
|
+
anchorTop = thHeight > el.clientHeight ? '50%' : `calc(${thHeight}px)`;
|
|
721
|
+
break;
|
|
722
|
+
case 'bottom':
|
|
723
|
+
case 'bl':
|
|
724
|
+
case 'br':
|
|
725
|
+
deg = '180deg';
|
|
726
|
+
anchorTop = '-1rem';
|
|
727
|
+
anchorLeft = thWidth > el.clientWidth ? '50%' : `calc(100% - ${thWidth}px)`;
|
|
728
|
+
break;
|
|
729
|
+
}
|
|
730
|
+
el.style.setProperty('--action-angle', deg);
|
|
731
|
+
el.style.setProperty('--action-left', anchorLeft);
|
|
732
|
+
el.style.setProperty('--action-top', anchorTop);
|
|
733
|
+
// console.log('updateAnchorPosition', position, deg);
|
|
734
|
+
}
|
|
735
|
+
setOptions(options) {
|
|
736
|
+
// console.log('setOptions', options);
|
|
737
|
+
this.options.set(options);
|
|
738
|
+
}
|
|
739
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgbPopover, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
740
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.0", type: NgbPopover, isStandalone: true, selector: "ngb-popover", host: { listeners: { "@parentAnimation.done": "animationDone()" }, properties: { "@parentAnimation": "" }, classAttribute: "fixed top-0 left-0 w-full h-full pointer-events-none z-p flex items-center justify-center" }, viewQueries: [{ propertyName: "myDialog", first: true, predicate: ["myDialog"], descendants: true, read: ViewContainerRef, isSignal: true }, { propertyName: "container", first: true, predicate: NgbPopoverMain, descendants: true, read: ElementRef, isSignal: true }, { propertyName: "backdropElement", first: true, predicate: NgbPopoverBackdrop, descendants: true, read: ElementRef, isSignal: true }], usesInheritance: true, ngImport: i0, template: ` <style>
|
|
741
|
+
.popover-anchor {
|
|
742
|
+
--action-angle: 180deg;
|
|
743
|
+
--action-left: 50%;
|
|
744
|
+
--action-top: -1rem;
|
|
745
|
+
}
|
|
746
|
+
.popover-anchor::before {
|
|
747
|
+
content: '';
|
|
748
|
+
position: absolute;
|
|
749
|
+
width: 0;
|
|
750
|
+
height: 0;
|
|
751
|
+
border-style: solid;
|
|
752
|
+
border-top: 0.8rem solid;
|
|
753
|
+
@apply border-foreground;
|
|
754
|
+
border-left: 0.5rem solid transparent;
|
|
755
|
+
border-right: 0.5rem solid transparent;
|
|
756
|
+
top: var(--action-top);
|
|
757
|
+
left: var(--action-left);
|
|
758
|
+
transform: translateX(-50%) rotate(var(--action-angle, 180deg));
|
|
759
|
+
}
|
|
760
|
+
</style>
|
|
761
|
+
<div
|
|
762
|
+
ngbPopoverMain
|
|
763
|
+
[@slideInOutAnimation]
|
|
764
|
+
class="{{
|
|
765
|
+
'menu-container pointer-events-auto fixed z-10 flex flex-col rounded-base border bg-foreground shadow-md ' +
|
|
766
|
+
(options().anchor ? 'popover-anchor ' : 'overflow-auto ')
|
|
767
|
+
}}"
|
|
768
|
+
>
|
|
769
|
+
<div class="flex flex-1 flex-col overflow-auto">
|
|
770
|
+
<ng-container #myDialog />
|
|
771
|
+
</div>
|
|
772
|
+
</div>
|
|
773
|
+
@if (options().backdrop) {
|
|
774
|
+
<div
|
|
775
|
+
ngbPopoverBackdrop
|
|
776
|
+
class="popover-backdrop pointer-events-auto fixed top-0 h-full w-full"
|
|
777
|
+
></div>
|
|
778
|
+
}`, isInline: true, styles: [".popover-anchor{--action-angle: 180deg;--action-left: 50%;--action-top: -1rem}.popover-anchor:before{content:\"\";position:absolute;width:0;height:0;border-style:solid;border-top:.8rem solid;@apply border-foreground;border-left:.5rem solid transparent;border-right:.5rem solid transparent;top:var(--action-top);left:var(--action-left);transform:translate(-50%) rotate(var(--action-angle, 180deg))}\n"], dependencies: [{ kind: "directive", type: NgbPopoverBackdrop, selector: "[ngbPopoverBackdrop]" }, { kind: "directive", type: NgbPopoverMain, selector: "[ngbPopoverMain]" }], animations: [
|
|
779
|
+
createHostAnimation(['@slideInOutAnimation']),
|
|
780
|
+
trigger('slideInOutAnimation', [
|
|
781
|
+
state('1', style({ transform: 'none', opacity: 1 })),
|
|
782
|
+
state('void', style({ transform: 'translateY(-10px) scale(0.95)', opacity: 0 })),
|
|
783
|
+
state('0', style({ transform: 'translateY(-10px) scale(0.95)', opacity: 0 })),
|
|
784
|
+
transition('* => *', animate('100ms ease-out')),
|
|
785
|
+
]),
|
|
786
|
+
], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
787
|
+
}
|
|
788
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgbPopover, decorators: [{
|
|
789
|
+
type: Component,
|
|
790
|
+
args: [{
|
|
791
|
+
selector: 'ngb-popover',
|
|
792
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
793
|
+
imports: [NgbPopoverBackdrop, NgbPopoverMain],
|
|
794
|
+
template: ` <style>
|
|
795
|
+
.popover-anchor {
|
|
796
|
+
--action-angle: 180deg;
|
|
797
|
+
--action-left: 50%;
|
|
798
|
+
--action-top: -1rem;
|
|
799
|
+
}
|
|
800
|
+
.popover-anchor::before {
|
|
801
|
+
content: '';
|
|
802
|
+
position: absolute;
|
|
803
|
+
width: 0;
|
|
804
|
+
height: 0;
|
|
805
|
+
border-style: solid;
|
|
806
|
+
border-top: 0.8rem solid;
|
|
807
|
+
@apply border-foreground;
|
|
808
|
+
border-left: 0.5rem solid transparent;
|
|
809
|
+
border-right: 0.5rem solid transparent;
|
|
810
|
+
top: var(--action-top);
|
|
811
|
+
left: var(--action-left);
|
|
812
|
+
transform: translateX(-50%) rotate(var(--action-angle, 180deg));
|
|
813
|
+
}
|
|
814
|
+
</style>
|
|
815
|
+
<div
|
|
816
|
+
ngbPopoverMain
|
|
817
|
+
[@slideInOutAnimation]
|
|
818
|
+
class="{{
|
|
819
|
+
'menu-container pointer-events-auto fixed z-10 flex flex-col rounded-base border bg-foreground shadow-md ' +
|
|
820
|
+
(options().anchor ? 'popover-anchor ' : 'overflow-auto ')
|
|
821
|
+
}}"
|
|
822
|
+
>
|
|
823
|
+
<div class="flex flex-1 flex-col overflow-auto">
|
|
824
|
+
<ng-container #myDialog />
|
|
825
|
+
</div>
|
|
826
|
+
</div>
|
|
827
|
+
@if (options().backdrop) {
|
|
828
|
+
<div
|
|
829
|
+
ngbPopoverBackdrop
|
|
830
|
+
class="popover-backdrop pointer-events-auto fixed top-0 h-full w-full"
|
|
831
|
+
></div>
|
|
832
|
+
}`,
|
|
833
|
+
host: {
|
|
834
|
+
class: 'fixed top-0 left-0 w-full h-full pointer-events-none z-p flex items-center justify-center',
|
|
835
|
+
'[@parentAnimation]': '',
|
|
836
|
+
'(@parentAnimation.done)': 'animationDone()',
|
|
837
|
+
},
|
|
838
|
+
animations: [
|
|
839
|
+
createHostAnimation(['@slideInOutAnimation']),
|
|
840
|
+
trigger('slideInOutAnimation', [
|
|
841
|
+
state('1', style({ transform: 'none', opacity: 1 })),
|
|
842
|
+
state('void', style({ transform: 'translateY(-10px) scale(0.95)', opacity: 0 })),
|
|
843
|
+
state('0', style({ transform: 'translateY(-10px) scale(0.95)', opacity: 0 })),
|
|
844
|
+
transition('* => *', animate('100ms ease-out')),
|
|
845
|
+
]),
|
|
846
|
+
],
|
|
847
|
+
}]
|
|
848
|
+
}], ctorParameters: () => [] });
|
|
849
|
+
function scrollToElement(target) {
|
|
850
|
+
return new Promise(resolve => {
|
|
851
|
+
let lastPos;
|
|
852
|
+
let currentPos = null;
|
|
853
|
+
let samePosCount = 0;
|
|
854
|
+
const checkIfScrollComplete = () => {
|
|
855
|
+
currentPos = window.pageYOffset || document.documentElement.scrollTop;
|
|
856
|
+
if (lastPos !== null && currentPos === lastPos) {
|
|
857
|
+
samePosCount++;
|
|
858
|
+
if (samePosCount > 2) {
|
|
859
|
+
resolve(true);
|
|
860
|
+
return;
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
else {
|
|
864
|
+
samePosCount = 0;
|
|
865
|
+
lastPos = currentPos;
|
|
866
|
+
}
|
|
867
|
+
requestAnimationFrame(checkIfScrollComplete);
|
|
868
|
+
};
|
|
869
|
+
// scroll only if the target is not in the view
|
|
870
|
+
// window.scrollTo({
|
|
871
|
+
// top: target.offsetTop - 50,
|
|
872
|
+
// behavior: 'smooth',
|
|
873
|
+
// });
|
|
874
|
+
target.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
|
|
875
|
+
requestAnimationFrame(checkIfScrollComplete);
|
|
876
|
+
});
|
|
877
|
+
}
|
|
878
|
+
class NgbPopoverClose {
|
|
879
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgbPopoverClose, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
880
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.0.0", type: NgbPopoverClose, isStandalone: true, selector: "[ngbPopoverClose]", hostDirectives: [{ directive: i2.NgbPortalClose, inputs: ["ngbPortalClose", "ngbPopoverClose"] }], ngImport: i0 }); }
|
|
881
|
+
}
|
|
882
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgbPopoverClose, decorators: [{
|
|
883
|
+
type: Directive,
|
|
884
|
+
args: [{
|
|
885
|
+
selector: '[ngbPopoverClose]',
|
|
886
|
+
hostDirectives: [{ directive: NgbPortalClose, inputs: ['ngbPortalClose: ngbPopoverClose'] }],
|
|
887
|
+
}]
|
|
888
|
+
}] });
|
|
889
|
+
function providePopover(popover) {
|
|
890
|
+
return { provide: NgbPopover, useExisting: popover };
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
class PopoverOptions extends DialogOptions {
|
|
894
|
+
}
|
|
895
|
+
const POPOVER_TOKEN = new InjectionToken('POPOVER_TOKEN');
|
|
896
|
+
function ngbPopoverPortal() {
|
|
897
|
+
const popover = inject(POPOVER_TOKEN, { optional: true }) ?? NgbPopover;
|
|
898
|
+
const base = basePopoverPortal(popover);
|
|
899
|
+
function open(component, options) {
|
|
900
|
+
return base.open(component, options);
|
|
901
|
+
}
|
|
902
|
+
return { open, closeAll: base.closeAll };
|
|
903
|
+
}
|
|
904
|
+
const registerNgbPopover = (popover) => {
|
|
905
|
+
return { provide: POPOVER_TOKEN, useValue: popover };
|
|
906
|
+
};
|
|
907
|
+
|
|
908
|
+
class NgbPopoverTrigger {
|
|
909
|
+
constructor() {
|
|
910
|
+
this.popoverPortal = ngbPopoverPortal();
|
|
911
|
+
this.el = inject(ElementRef);
|
|
912
|
+
this.ngbPopoverTrigger = input.required();
|
|
913
|
+
this.ngbPopoverTriggerData = input();
|
|
914
|
+
this.options = input();
|
|
915
|
+
this.closeFn = () => { };
|
|
916
|
+
}
|
|
917
|
+
open() {
|
|
918
|
+
const options = this.options();
|
|
919
|
+
const { diaRef } = this.popoverPortal.open(this.ngbPopoverTrigger(), {
|
|
920
|
+
target: this.el.nativeElement,
|
|
921
|
+
anchor: options?.anchor,
|
|
922
|
+
position: options?.position || 'top',
|
|
923
|
+
data: this.ngbPopoverTriggerData(),
|
|
924
|
+
});
|
|
925
|
+
this.closeFn = diaRef.close;
|
|
926
|
+
}
|
|
927
|
+
close() {
|
|
928
|
+
this.closeFn();
|
|
929
|
+
}
|
|
930
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgbPopoverTrigger, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
931
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.0.0", type: NgbPopoverTrigger, isStandalone: true, selector: "[ngbPopoverTrigger]", inputs: { ngbPopoverTrigger: { classPropertyName: "ngbPopoverTrigger", publicName: "ngbPopoverTrigger", isSignal: true, isRequired: true, transformFunction: null }, ngbPopoverTriggerData: { classPropertyName: "ngbPopoverTriggerData", publicName: "ngbPopoverTriggerData", isSignal: true, isRequired: false, transformFunction: null }, options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "click": "open()" } }, exportAs: ["ngbPopoverTrigger"], ngImport: i0 }); }
|
|
932
|
+
}
|
|
933
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgbPopoverTrigger, decorators: [{
|
|
934
|
+
type: Directive,
|
|
935
|
+
args: [{
|
|
936
|
+
selector: '[ngbPopoverTrigger]',
|
|
937
|
+
exportAs: 'ngbPopoverTrigger',
|
|
938
|
+
host: {
|
|
939
|
+
'(click)': 'open()',
|
|
940
|
+
},
|
|
941
|
+
}]
|
|
942
|
+
}] });
|
|
943
|
+
|
|
944
|
+
/*
|
|
945
|
+
* Public API Surface of popover
|
|
946
|
+
*/
|
|
947
|
+
|
|
948
|
+
/**
|
|
949
|
+
* Generated bundle index. Do not edit.
|
|
950
|
+
*/
|
|
951
|
+
|
|
952
|
+
export { NgbPopover, NgbPopoverBackdrop, NgbPopoverClose, NgbPopoverMain, NgbPopoverTrigger, PopoverOptions, basePopoverPortal, ngbPopoverPortal, providePopover, registerNgbPopover, tooltipPosition };
|
|
953
|
+
//# sourceMappingURL=ngbase-adk-popover.mjs.map
|