ngx-bootstrap 18.0.2 → 18.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 +1 -1
- package/accordion/accordion-group.component.d.ts +1 -1
- package/accordion/accordion.component.d.ts +1 -1
- package/accordion/accordion.module.d.ts +2 -5
- package/accordion/esm2022/accordion-group.component.mjs +8 -7
- package/accordion/esm2022/accordion.component.mjs +4 -3
- package/accordion/esm2022/accordion.module.mjs +6 -8
- package/accordion/fesm2022/ngx-bootstrap-accordion.mjs +12 -12
- package/accordion/fesm2022/ngx-bootstrap-accordion.mjs.map +1 -1
- package/alert/alert.component.d.ts +1 -1
- package/alert/alert.module.d.ts +2 -4
- package/alert/esm2022/alert.component.mjs +4 -4
- package/alert/esm2022/alert.module.mjs +6 -7
- package/alert/fesm2022/ngx-bootstrap-alert.mjs +8 -9
- package/alert/fesm2022/ngx-bootstrap-alert.mjs.map +1 -1
- package/buttons/button-checkbox.directive.d.ts +1 -1
- package/buttons/button-radio-group.directive.d.ts +1 -1
- package/buttons/button-radio.directive.d.ts +1 -1
- package/buttons/buttons.module.d.ts +2 -3
- package/buttons/esm2022/button-checkbox.directive.mjs +4 -3
- package/buttons/esm2022/button-radio-group.directive.mjs +4 -3
- package/buttons/esm2022/button-radio.directive.mjs +4 -3
- package/buttons/esm2022/buttons.module.mjs +5 -4
- package/buttons/fesm2022/ngx-bootstrap-buttons.mjs +13 -9
- package/buttons/fesm2022/ngx-bootstrap-buttons.mjs.map +1 -1
- package/carousel/carousel.component.d.ts +1 -1
- package/carousel/carousel.module.d.ts +2 -4
- package/carousel/esm2022/carousel.component.mjs +4 -5
- package/carousel/esm2022/carousel.module.mjs +6 -7
- package/carousel/esm2022/slide.component.mjs +3 -3
- package/carousel/fesm2022/ngx-bootstrap-carousel.mjs +10 -11
- package/carousel/fesm2022/ngx-bootstrap-carousel.mjs.map +1 -1
- package/carousel/slide.component.d.ts +1 -1
- package/chronos/esm2022/i18n/fr-ca.mjs +69 -0
- package/chronos/esm2022/public_api.mjs +2 -1
- package/chronos/fesm2022/ngx-bootstrap-chronos.mjs +70 -1
- package/chronos/fesm2022/ngx-bootstrap-chronos.mjs.map +1 -1
- package/chronos/i18n/fr-ca.d.ts +2 -0
- package/chronos/public_api.d.ts +1 -0
- package/collapse/collapse.directive.d.ts +1 -1
- package/collapse/collapse.module.d.ts +2 -3
- package/collapse/esm2022/collapse.directive.mjs +4 -3
- package/collapse/esm2022/collapse.module.mjs +5 -4
- package/collapse/fesm2022/ngx-bootstrap-collapse.mjs +7 -5
- package/collapse/fesm2022/ngx-bootstrap-collapse.mjs.map +1 -1
- package/datepicker/bs-datepicker-inline.component.d.ts +1 -1
- package/datepicker/bs-datepicker-input.directive.d.ts +1 -1
- package/datepicker/bs-datepicker.component.d.ts +1 -1
- package/datepicker/bs-datepicker.module.d.ts +24 -25
- package/datepicker/bs-daterangepicker-inline.component.d.ts +1 -1
- package/datepicker/bs-daterangepicker-input.directive.d.ts +1 -1
- package/datepicker/bs-daterangepicker.component.d.ts +1 -1
- package/datepicker/esm2022/bs-datepicker-inline.component.mjs +5 -3
- package/datepicker/esm2022/bs-datepicker-input.directive.mjs +12 -3
- package/datepicker/esm2022/bs-datepicker.component.mjs +5 -3
- package/datepicker/esm2022/bs-datepicker.module.mjs +14 -28
- package/datepicker/esm2022/bs-daterangepicker-inline.component.mjs +9 -3
- package/datepicker/esm2022/bs-daterangepicker-input.directive.mjs +12 -3
- package/datepicker/esm2022/bs-daterangepicker.component.mjs +9 -3
- package/datepicker/esm2022/themes/bs/bs-calendar-layout.component.mjs +9 -7
- package/datepicker/esm2022/themes/bs/bs-current-date-view.component.mjs +4 -3
- package/datepicker/esm2022/themes/bs/bs-custom-dates-view.component.mjs +7 -5
- package/datepicker/esm2022/themes/bs/bs-datepicker-container.component.mjs +13 -10
- package/datepicker/esm2022/themes/bs/bs-datepicker-day-decorator.directive.mjs +4 -3
- package/datepicker/esm2022/themes/bs/bs-datepicker-inline-container.component.mjs +11 -10
- package/datepicker/esm2022/themes/bs/bs-datepicker-navigation-view.component.mjs +7 -5
- package/datepicker/esm2022/themes/bs/bs-daterangepicker-container.component.mjs +23 -10
- package/datepicker/esm2022/themes/bs/bs-daterangepicker-inline-container.component.mjs +11 -10
- package/datepicker/esm2022/themes/bs/bs-days-calendar-view.component.mjs +12 -9
- package/datepicker/esm2022/themes/bs/bs-months-calendar-view.component.mjs +9 -7
- package/datepicker/esm2022/themes/bs/bs-timepicker-view.component.mjs +4 -3
- package/datepicker/esm2022/themes/bs/bs-years-calendar-view.component.mjs +9 -7
- package/datepicker/fesm2022/ngx-bootstrap-datepicker.mjs +436 -382
- package/datepicker/fesm2022/ngx-bootstrap-datepicker.mjs.map +1 -1
- package/datepicker/themes/bs/bs-calendar-layout.component.d.ts +1 -1
- package/datepicker/themes/bs/bs-current-date-view.component.d.ts +1 -1
- package/datepicker/themes/bs/bs-custom-dates-view.component.d.ts +1 -1
- package/datepicker/themes/bs/bs-datepicker-container.component.d.ts +1 -1
- package/datepicker/themes/bs/bs-datepicker-day-decorator.directive.d.ts +1 -1
- package/datepicker/themes/bs/bs-datepicker-inline-container.component.d.ts +1 -1
- package/datepicker/themes/bs/bs-datepicker-navigation-view.component.d.ts +1 -1
- package/datepicker/themes/bs/bs-daterangepicker-container.component.d.ts +1 -1
- package/datepicker/themes/bs/bs-daterangepicker-inline-container.component.d.ts +1 -1
- package/datepicker/themes/bs/bs-days-calendar-view.component.d.ts +1 -1
- package/datepicker/themes/bs/bs-months-calendar-view.component.d.ts +1 -1
- package/datepicker/themes/bs/bs-timepicker-view.component.d.ts +1 -1
- package/datepicker/themes/bs/bs-years-calendar-view.component.d.ts +1 -1
- package/dropdown/bs-dropdown-container.component.d.ts +1 -1
- package/dropdown/bs-dropdown-menu.directive.d.ts +1 -1
- package/dropdown/bs-dropdown-toggle.directive.d.ts +1 -1
- package/dropdown/bs-dropdown.directive.d.ts +1 -1
- package/dropdown/bs-dropdown.module.d.ts +6 -8
- package/dropdown/esm2022/bs-dropdown-container.component.mjs +8 -5
- package/dropdown/esm2022/bs-dropdown-menu.directive.mjs +4 -3
- package/dropdown/esm2022/bs-dropdown-toggle.directive.mjs +4 -3
- package/dropdown/esm2022/bs-dropdown.directive.mjs +4 -3
- package/dropdown/esm2022/bs-dropdown.module.mjs +11 -22
- package/dropdown/fesm2022/ngx-bootstrap-dropdown.mjs +26 -29
- package/dropdown/fesm2022/ngx-bootstrap-dropdown.mjs.map +1 -1
- package/focus-trap/esm2022/focus-trap.mjs +15 -3
- package/focus-trap/esm2022/focus-trap.module.mjs +5 -15
- package/focus-trap/fesm2022/ngx-bootstrap-focus-trap.mjs +63 -60
- package/focus-trap/fesm2022/ngx-bootstrap-focus-trap.mjs.map +1 -1
- package/focus-trap/focus-trap.d.ts +1 -1
- package/focus-trap/focus-trap.module.d.ts +4 -5
- package/locale/esm2022/public_api.mjs +2 -1
- package/locale/fesm2022/ngx-bootstrap-locale.mjs +1 -1
- package/locale/public_api.d.ts +1 -0
- package/modal/bs-modal.service.d.ts +1 -0
- package/modal/esm2022/bs-modal.service.mjs +6 -1
- package/modal/esm2022/modal-backdrop.component.mjs +4 -3
- package/modal/esm2022/modal-container.component.mjs +9 -5
- package/modal/esm2022/modal.directive.mjs +4 -3
- package/modal/esm2022/modal.module.mjs +10 -8
- package/modal/fesm2022/ngx-bootstrap-modal.mjs +323 -312
- package/modal/fesm2022/ngx-bootstrap-modal.mjs.map +1 -1
- package/modal/modal-backdrop.component.d.ts +1 -1
- package/modal/modal-container.component.d.ts +1 -1
- package/modal/modal.directive.d.ts +1 -1
- package/modal/modal.module.d.ts +5 -7
- package/package.json +1 -1
- package/pagination/esm2022/pager.component.mjs +4 -4
- package/pagination/esm2022/pagination.component.mjs +4 -4
- package/pagination/esm2022/pagination.module.mjs +5 -5
- package/pagination/fesm2022/ngx-bootstrap-pagination.mjs +9 -10
- package/pagination/fesm2022/ngx-bootstrap-pagination.mjs.map +1 -1
- package/pagination/pager.component.d.ts +1 -1
- package/pagination/pagination.component.d.ts +1 -1
- package/pagination/pagination.module.d.ts +5 -6
- package/popover/esm2022/popover-container.component.mjs +4 -4
- package/popover/esm2022/popover.directive.mjs +8 -3
- package/popover/esm2022/popover.module.mjs +5 -10
- package/popover/fesm2022/ngx-bootstrap-popover.mjs +17 -16
- package/popover/fesm2022/ngx-bootstrap-popover.mjs.map +1 -1
- package/popover/popover-container.component.d.ts +1 -1
- package/popover/popover.directive.d.ts +1 -1
- package/popover/popover.module.d.ts +5 -6
- package/progressbar/bar.component.d.ts +1 -1
- package/progressbar/esm2022/bar.component.mjs +3 -3
- package/progressbar/esm2022/progressbar.component.mjs +5 -5
- package/progressbar/esm2022/progressbar.module.mjs +6 -7
- package/progressbar/fesm2022/ngx-bootstrap-progressbar.mjs +10 -11
- package/progressbar/fesm2022/ngx-bootstrap-progressbar.mjs.map +1 -1
- package/progressbar/progressbar.component.d.ts +1 -1
- package/progressbar/progressbar.module.d.ts +2 -4
- package/rating/esm2022/rating.component.mjs +4 -4
- package/rating/esm2022/rating.module.mjs +6 -10
- package/rating/fesm2022/ngx-bootstrap-rating.mjs +8 -12
- package/rating/fesm2022/ngx-bootstrap-rating.mjs.map +1 -1
- package/rating/rating.component.d.ts +1 -1
- package/rating/rating.module.d.ts +2 -4
- package/schematics/ng-add/index.js +5 -0
- package/schematics/ng-add/index.js.map +1 -1
- package/schematics/utils/current_dependency_versions.json +1 -1
- package/schematics/utils/index.js +4 -4
- package/schematics/utils/index.js.map +1 -1
- package/sortable/esm2022/sortable.component.mjs +11 -7
- package/sortable/esm2022/sortable.module.mjs +6 -8
- package/sortable/fesm2022/ngx-bootstrap-sortable.mjs +15 -12
- package/sortable/fesm2022/ngx-bootstrap-sortable.mjs.map +1 -1
- package/sortable/sortable.component.d.ts +1 -1
- package/sortable/sortable.module.d.ts +2 -4
- package/tabs/esm2022/ng-transclude.directive.mjs +4 -3
- package/tabs/esm2022/tab-heading.directive.mjs +6 -3
- package/tabs/esm2022/tab.directive.mjs +6 -3
- package/tabs/esm2022/tabs.module.mjs +7 -12
- package/tabs/esm2022/tabset.component.mjs +5 -5
- package/tabs/fesm2022/ngx-bootstrap-tabs.mjs +22 -21
- package/tabs/fesm2022/ngx-bootstrap-tabs.mjs.map +1 -1
- package/tabs/ng-transclude.directive.d.ts +1 -1
- package/tabs/tab-heading.directive.d.ts +1 -1
- package/tabs/tab.directive.d.ts +1 -1
- package/tabs/tabs.module.d.ts +7 -8
- package/tabs/tabset.component.d.ts +1 -1
- package/timepicker/esm2022/timepicker.component.mjs +4 -4
- package/timepicker/esm2022/timepicker.module.mjs +6 -13
- package/timepicker/fesm2022/ngx-bootstrap-timepicker.mjs +8 -13
- package/timepicker/fesm2022/ngx-bootstrap-timepicker.mjs.map +1 -1
- package/timepicker/timepicker.component.d.ts +1 -1
- package/timepicker/timepicker.module.d.ts +2 -4
- package/tooltip/esm2022/tooltip-container.component.mjs +3 -3
- package/tooltip/esm2022/tooltip.directive.mjs +9 -3
- package/tooltip/esm2022/tooltip.module.mjs +5 -10
- package/tooltip/fesm2022/ngx-bootstrap-tooltip.mjs +14 -11
- package/tooltip/fesm2022/ngx-bootstrap-tooltip.mjs.map +1 -1
- package/tooltip/tooltip-container.component.d.ts +1 -1
- package/tooltip/tooltip.directive.d.ts +1 -1
- package/tooltip/tooltip.module.d.ts +5 -6
- package/typeahead/esm2022/typeahead-container.component.mjs +4 -4
- package/typeahead/esm2022/typeahead.directive.mjs +6 -3
- package/typeahead/esm2022/typeahead.module.mjs +5 -10
- package/typeahead/fesm2022/ngx-bootstrap-typeahead.mjs +11 -13
- package/typeahead/fesm2022/ngx-bootstrap-typeahead.mjs.map +1 -1
- package/typeahead/typeahead-container.component.d.ts +1 -1
- package/typeahead/typeahead.directive.d.ts +1 -1
- package/typeahead/typeahead.module.d.ts +5 -6
@@ -1,10 +1,9 @@
|
|
1
1
|
import * as i0 from '@angular/core';
|
2
|
-
import { Injectable, InjectionToken, Component,
|
3
|
-
import { document, Utils, window as window$1 } from 'ngx-bootstrap/utils';
|
4
|
-
import * as i2 from 'ngx-bootstrap/focus-trap';
|
5
|
-
import { FocusTrapModule } from 'ngx-bootstrap/focus-trap';
|
2
|
+
import { Injectable, InjectionToken, Component, EventEmitter, Optional, Inject, HostListener, Directive, Input, Output, NgModule } from '@angular/core';
|
6
3
|
import * as i1 from 'ngx-bootstrap/component-loader';
|
7
4
|
import { ComponentLoaderFactory } from 'ngx-bootstrap/component-loader';
|
5
|
+
import { Utils, document, window as window$1 } from 'ngx-bootstrap/utils';
|
6
|
+
import { FocusTrapDirective, FocusTrapModule } from 'ngx-bootstrap/focus-trap';
|
8
7
|
import { PositioningService } from 'ngx-bootstrap/positioning';
|
9
8
|
|
10
9
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
@@ -78,6 +77,273 @@ const DISMISS_REASONS = {
|
|
78
77
|
BACK: 'browser-back-navigation-clicked'
|
79
78
|
};
|
80
79
|
|
80
|
+
/** This component will be added as background layout for modals if enabled */
|
81
|
+
class ModalBackdropComponent {
|
82
|
+
get isAnimated() {
|
83
|
+
return this._isAnimated;
|
84
|
+
}
|
85
|
+
set isAnimated(value) {
|
86
|
+
this._isAnimated = value;
|
87
|
+
}
|
88
|
+
get isShown() {
|
89
|
+
return this._isShown;
|
90
|
+
}
|
91
|
+
set isShown(value) {
|
92
|
+
this._isShown = value;
|
93
|
+
if (value) {
|
94
|
+
this.renderer.addClass(this.element.nativeElement, `${CLASS_NAME.SHOW}`);
|
95
|
+
}
|
96
|
+
else {
|
97
|
+
this.renderer.removeClass(this.element.nativeElement, `${CLASS_NAME.SHOW}`);
|
98
|
+
}
|
99
|
+
}
|
100
|
+
constructor(element, renderer) {
|
101
|
+
this._isAnimated = false;
|
102
|
+
this._isShown = false;
|
103
|
+
this.element = element;
|
104
|
+
this.renderer = renderer;
|
105
|
+
}
|
106
|
+
ngOnInit() {
|
107
|
+
if (this.isAnimated) {
|
108
|
+
this.renderer.addClass(this.element.nativeElement, `${CLASS_NAME.FADE}`);
|
109
|
+
Utils.reflow(this.element.nativeElement);
|
110
|
+
}
|
111
|
+
this.isShown = true;
|
112
|
+
}
|
113
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: ModalBackdropComponent, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Component }); }
|
114
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.0.1", type: ModalBackdropComponent, isStandalone: true, selector: "bs-modal-backdrop", host: { classAttribute: "modal-backdrop" }, ngImport: i0, template: ' ', isInline: true }); }
|
115
|
+
}
|
116
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: ModalBackdropComponent, decorators: [{
|
117
|
+
type: Component,
|
118
|
+
args: [{
|
119
|
+
selector: 'bs-modal-backdrop',
|
120
|
+
template: ' ',
|
121
|
+
// eslint-disable-next-line @angular-eslint/no-host-metadata-property
|
122
|
+
host: { class: CLASS_NAME.BACKDROP },
|
123
|
+
standalone: true
|
124
|
+
}]
|
125
|
+
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }] });
|
126
|
+
|
127
|
+
let currentId = 1;
|
128
|
+
class BsModalService {
|
129
|
+
constructor(rendererFactory, clf, modalDefaultOption) {
|
130
|
+
this.clf = clf;
|
131
|
+
this.modalDefaultOption = modalDefaultOption;
|
132
|
+
this.onShow = new EventEmitter();
|
133
|
+
this.onShown = new EventEmitter();
|
134
|
+
this.onHide = new EventEmitter();
|
135
|
+
this.onHidden = new EventEmitter();
|
136
|
+
this.isBodyOverflowing = false;
|
137
|
+
this.originalBodyPadding = 0;
|
138
|
+
this.scrollbarWidth = 0;
|
139
|
+
this.modalsCount = 0;
|
140
|
+
this.lastHiddenId = 0;
|
141
|
+
this.loaders = [];
|
142
|
+
this._focusEl = null;
|
143
|
+
this._backdropLoader = this.clf.createLoader();
|
144
|
+
this._renderer = rendererFactory.createRenderer(null, null);
|
145
|
+
this.config = modalDefaultOption ?
|
146
|
+
(Object.assign({}, modalConfigDefaults, modalDefaultOption)) :
|
147
|
+
modalConfigDefaults;
|
148
|
+
}
|
149
|
+
/** Shows a modal */
|
150
|
+
show(
|
151
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
152
|
+
content, config) {
|
153
|
+
this._focusEl = document.activeElement;
|
154
|
+
this.modalsCount++;
|
155
|
+
this._createLoaders();
|
156
|
+
// must be different per every show() call
|
157
|
+
const id = config?.id || currentId++;
|
158
|
+
this.config = this.modalDefaultOption ?
|
159
|
+
Object.assign({}, modalConfigDefaults, this.modalDefaultOption, config) :
|
160
|
+
Object.assign({}, modalConfigDefaults, config);
|
161
|
+
this.config.id = id;
|
162
|
+
this._showBackdrop();
|
163
|
+
this.lastDismissReason = void 0;
|
164
|
+
return this._showModal(content);
|
165
|
+
}
|
166
|
+
hide(id) {
|
167
|
+
if (this.lastHiddenId === id) {
|
168
|
+
return;
|
169
|
+
}
|
170
|
+
this.lastHiddenId = id;
|
171
|
+
if (this.modalsCount === 1 || id == null) {
|
172
|
+
this._hideBackdrop();
|
173
|
+
this.resetScrollbar();
|
174
|
+
}
|
175
|
+
this.modalsCount = this.modalsCount >= 1 && id != null ? this.modalsCount - 1 : 0;
|
176
|
+
setTimeout(() => {
|
177
|
+
this._hideModal(id);
|
178
|
+
this.removeLoaders(id);
|
179
|
+
}, this.config.animated ? TRANSITION_DURATIONS.BACKDROP : 0);
|
180
|
+
if (this._focusEl) {
|
181
|
+
this._focusEl.focus();
|
182
|
+
}
|
183
|
+
}
|
184
|
+
_showBackdrop() {
|
185
|
+
const isBackdropEnabled = this.config.backdrop === true || this.config.backdrop === 'static';
|
186
|
+
const isBackdropInDOM = !this.backdropRef || !this.backdropRef.instance.isShown;
|
187
|
+
if (this.modalsCount === 1) {
|
188
|
+
this.removeBackdrop();
|
189
|
+
if (isBackdropEnabled && isBackdropInDOM) {
|
190
|
+
this._backdropLoader
|
191
|
+
.attach(ModalBackdropComponent)
|
192
|
+
.to('body')
|
193
|
+
.show({ isAnimated: this.config.animated });
|
194
|
+
this.backdropRef = this._backdropLoader._componentRef;
|
195
|
+
}
|
196
|
+
}
|
197
|
+
}
|
198
|
+
_hideBackdrop() {
|
199
|
+
if (!this.backdropRef) {
|
200
|
+
return;
|
201
|
+
}
|
202
|
+
this.backdropRef.instance.isShown = false;
|
203
|
+
const duration = this.config.animated ? TRANSITION_DURATIONS.BACKDROP : 0;
|
204
|
+
setTimeout(() => this.removeBackdrop(), duration);
|
205
|
+
}
|
206
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
207
|
+
_showModal(content) {
|
208
|
+
const modalLoader = this.loaders[this.loaders.length - 1];
|
209
|
+
if (this.config && this.config.providers) {
|
210
|
+
for (const provider of this.config.providers) {
|
211
|
+
modalLoader.provide(provider);
|
212
|
+
}
|
213
|
+
}
|
214
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
215
|
+
const bsModalRef = new BsModalRef();
|
216
|
+
const modalContainerRef = modalLoader
|
217
|
+
.provide({ provide: ModalOptions, useValue: this.config })
|
218
|
+
.provide({ provide: BsModalRef, useValue: bsModalRef })
|
219
|
+
.attach(ModalContainerComponent)
|
220
|
+
.to('body');
|
221
|
+
bsModalRef.hide = () => this.hide(bsModalRef.id);
|
222
|
+
bsModalRef.setClass = (newClass) => {
|
223
|
+
if (modalContainerRef.instance) {
|
224
|
+
modalContainerRef.instance.config.class = newClass;
|
225
|
+
}
|
226
|
+
};
|
227
|
+
bsModalRef.onHidden = new EventEmitter();
|
228
|
+
bsModalRef.onHide = new EventEmitter();
|
229
|
+
this.copyEvent(modalLoader.onBeforeHide, bsModalRef.onHide);
|
230
|
+
this.copyEvent(modalLoader.onHidden, bsModalRef.onHidden);
|
231
|
+
// call 'show' method after assign setClass in bsModalRef.
|
232
|
+
// it makes modal component's bsModalRef available to call setClass method
|
233
|
+
modalContainerRef.show({
|
234
|
+
content,
|
235
|
+
isAnimated: this.config.animated,
|
236
|
+
initialState: this.config.initialState,
|
237
|
+
bsModalService: this,
|
238
|
+
id: this.config.id
|
239
|
+
});
|
240
|
+
if (modalContainerRef.instance) {
|
241
|
+
modalContainerRef.instance.level = this.getModalsCount();
|
242
|
+
bsModalRef.content = modalLoader.getInnerComponent();
|
243
|
+
bsModalRef.id = modalContainerRef.instance.config?.id;
|
244
|
+
}
|
245
|
+
return bsModalRef;
|
246
|
+
}
|
247
|
+
_hideModal(id) {
|
248
|
+
if (id != null) {
|
249
|
+
const indexToRemove = this.loaders.findIndex(loader => loader.instance?.config.id === id);
|
250
|
+
const modalLoader = this.loaders[indexToRemove];
|
251
|
+
if (modalLoader) {
|
252
|
+
modalLoader.hide(id);
|
253
|
+
}
|
254
|
+
}
|
255
|
+
else {
|
256
|
+
this.loaders.forEach((loader) => {
|
257
|
+
if (loader.instance) {
|
258
|
+
loader.hide(loader.instance.config.id);
|
259
|
+
}
|
260
|
+
});
|
261
|
+
}
|
262
|
+
}
|
263
|
+
getModalsCount() {
|
264
|
+
return this.modalsCount;
|
265
|
+
}
|
266
|
+
setDismissReason(reason) {
|
267
|
+
this.lastDismissReason = reason;
|
268
|
+
}
|
269
|
+
removeBackdrop() {
|
270
|
+
this._renderer.removeClass(document.body, CLASS_NAME.OPEN);
|
271
|
+
this._renderer.setStyle(document.body, 'overflow-y', '');
|
272
|
+
this._backdropLoader.hide();
|
273
|
+
this.backdropRef = void 0;
|
274
|
+
}
|
275
|
+
/** Checks if the body is overflowing and sets scrollbar width */
|
276
|
+
/** @internal */
|
277
|
+
checkScrollbar() {
|
278
|
+
this.isBodyOverflowing = document.body.clientWidth < window.innerWidth;
|
279
|
+
this.scrollbarWidth = this.getScrollbarWidth();
|
280
|
+
}
|
281
|
+
setScrollbar() {
|
282
|
+
if (!document) {
|
283
|
+
return;
|
284
|
+
}
|
285
|
+
this.originalBodyPadding = parseInt(window
|
286
|
+
.getComputedStyle(document.body)
|
287
|
+
.getPropertyValue('padding-right') || '0', 10);
|
288
|
+
if (this.isBodyOverflowing) {
|
289
|
+
document.body.style.paddingRight = `${this.originalBodyPadding +
|
290
|
+
this.scrollbarWidth}px`;
|
291
|
+
}
|
292
|
+
}
|
293
|
+
resetScrollbar() {
|
294
|
+
document.body.style.paddingRight = `${this.originalBodyPadding}px`;
|
295
|
+
}
|
296
|
+
// thx d.walsh
|
297
|
+
getScrollbarWidth() {
|
298
|
+
const scrollDiv = this._renderer.createElement('div');
|
299
|
+
this._renderer.addClass(scrollDiv, CLASS_NAME.SCROLLBAR_MEASURER);
|
300
|
+
this._renderer.appendChild(document.body, scrollDiv);
|
301
|
+
const scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
|
302
|
+
this._renderer.removeChild(document.body, scrollDiv);
|
303
|
+
return scrollbarWidth;
|
304
|
+
}
|
305
|
+
_createLoaders() {
|
306
|
+
const loader = this.clf.createLoader();
|
307
|
+
this.copyEvent(loader.onBeforeShow, this.onShow);
|
308
|
+
this.copyEvent(loader.onShown, this.onShown);
|
309
|
+
this.copyEvent(loader.onBeforeHide, this.onHide);
|
310
|
+
this.copyEvent(loader.onHidden, this.onHidden);
|
311
|
+
this.loaders.push(loader);
|
312
|
+
}
|
313
|
+
removeLoaders(id) {
|
314
|
+
if (id != null) {
|
315
|
+
const indexToRemove = this.loaders.findIndex(loader => loader.instance?.config.id === id);
|
316
|
+
if (indexToRemove >= 0) {
|
317
|
+
this.loaders.splice(indexToRemove, 1);
|
318
|
+
this.loaders.forEach((loader, i) => {
|
319
|
+
if (loader.instance) {
|
320
|
+
loader.instance.level = i + 1;
|
321
|
+
}
|
322
|
+
});
|
323
|
+
}
|
324
|
+
}
|
325
|
+
else {
|
326
|
+
this.loaders.splice(0, this.loaders.length);
|
327
|
+
}
|
328
|
+
}
|
329
|
+
copyEvent(from, to) {
|
330
|
+
from.subscribe((data) => {
|
331
|
+
to.emit(this.lastDismissReason || data);
|
332
|
+
});
|
333
|
+
}
|
334
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: BsModalService, deps: [{ token: i0.RendererFactory2 }, { token: i1.ComponentLoaderFactory }, { token: MODAL_CONFIG_DEFAULT_OVERRIDE, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
335
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: BsModalService, providedIn: 'platform' }); }
|
336
|
+
}
|
337
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: BsModalService, decorators: [{
|
338
|
+
type: Injectable,
|
339
|
+
args: [{ providedIn: 'platform' }]
|
340
|
+
}], ctorParameters: () => [{ type: i0.RendererFactory2 }, { type: i1.ComponentLoaderFactory }, { type: ModalOptions, decorators: [{
|
341
|
+
type: Optional
|
342
|
+
}, {
|
343
|
+
type: Inject,
|
344
|
+
args: [MODAL_CONFIG_DEFAULT_OVERRIDE]
|
345
|
+
}] }] });
|
346
|
+
|
81
347
|
class ModalContainerComponent {
|
82
348
|
constructor(options, _element, _renderer) {
|
83
349
|
this._element = _element;
|
@@ -176,98 +442,55 @@ class ModalContainerComponent {
|
|
176
442
|
}, this.isAnimated ? TRANSITION_DURATIONS.MODAL : 0);
|
177
443
|
}
|
178
444
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: ModalContainerComponent, deps: [{ token: ModalOptions }, { token: i0.ElementRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Component }); }
|
179
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.0.1", type: ModalContainerComponent, selector: "modal-container", host: { attributes: { "role": "dialog", "tabindex": "-1" }, listeners: { "mousedown": "onClickStarted($event)", "click": "onClickStop($event)", "window:popstate": "onPopState()", "window:keydown.esc": "onEsc($event)" }, properties: { "attr.aria-modal": "true", "attr.aria-labelledby": "config.ariaLabelledBy", "attr.aria-describedby": "config.ariaDescribedby" }, classAttribute: "modal" }, ngImport: i0, template: `
|
445
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.0.1", type: ModalContainerComponent, isStandalone: true, selector: "modal-container", host: { attributes: { "role": "dialog", "tabindex": "-1" }, listeners: { "mousedown": "onClickStarted($event)", "click": "onClickStop($event)", "window:popstate": "onPopState()", "window:keydown.esc": "onEsc($event)" }, properties: { "attr.aria-modal": "true", "attr.aria-labelledby": "config.ariaLabelledBy", "attr.aria-describedby": "config.ariaDescribedby" }, classAttribute: "modal" }, providers: [BsModalService], ngImport: i0, template: `
|
180
446
|
<div [class]="'modal-dialog' + (config.class ? ' ' + config.class : '')"
|
181
|
-
role="document"
|
182
|
-
focusTrap>
|
183
|
-
<div class="modal-content">
|
184
|
-
<ng-content></ng-content>
|
185
|
-
</div>
|
186
|
-
</div>
|
187
|
-
`, isInline: true, dependencies: [{ kind: "directive", type:
|
188
|
-
}
|
189
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: ModalContainerComponent, decorators: [{
|
190
|
-
type: Component,
|
191
|
-
args: [{
|
192
|
-
selector: 'modal-container',
|
193
|
-
template: `
|
194
|
-
<div [class]="'modal-dialog' + (config.class ? ' ' + config.class : '')"
|
195
|
-
role="document"
|
196
|
-
focusTrap>
|
197
|
-
<div class="modal-content">
|
198
|
-
<ng-content></ng-content>
|
199
|
-
</div>
|
200
|
-
</div>
|
201
|
-
`,
|
202
|
-
// eslint-disable-next-line @angular-eslint/no-host-metadata-property
|
203
|
-
host: {
|
204
|
-
class: 'modal',
|
205
|
-
role: 'dialog',
|
206
|
-
tabindex: '-1',
|
207
|
-
'[attr.aria-modal]': 'true',
|
208
|
-
'[attr.aria-labelledby]': 'config.ariaLabelledBy',
|
209
|
-
'[attr.aria-describedby]': 'config.ariaDescribedby'
|
210
|
-
}
|
211
|
-
}]
|
212
|
-
}], ctorParameters: () => [{ type: ModalOptions }, { type: i0.ElementRef }, { type: i0.Renderer2 }], propDecorators: { onClickStarted: [{
|
213
|
-
type: HostListener,
|
214
|
-
args: ['mousedown', ['$event']]
|
215
|
-
}], onClickStop: [{
|
216
|
-
type: HostListener,
|
217
|
-
args: ['click', ['$event']]
|
218
|
-
}], onPopState: [{
|
219
|
-
type: HostListener,
|
220
|
-
args: ['window:popstate']
|
221
|
-
}], onEsc: [{
|
222
|
-
type: HostListener,
|
223
|
-
args: ['window:keydown.esc', ['$event']]
|
224
|
-
}] } });
|
225
|
-
|
226
|
-
/** This component will be added as background layout for modals if enabled */
|
227
|
-
class ModalBackdropComponent {
|
228
|
-
get isAnimated() {
|
229
|
-
return this._isAnimated;
|
230
|
-
}
|
231
|
-
set isAnimated(value) {
|
232
|
-
this._isAnimated = value;
|
233
|
-
}
|
234
|
-
get isShown() {
|
235
|
-
return this._isShown;
|
236
|
-
}
|
237
|
-
set isShown(value) {
|
238
|
-
this._isShown = value;
|
239
|
-
if (value) {
|
240
|
-
this.renderer.addClass(this.element.nativeElement, `${CLASS_NAME.SHOW}`);
|
241
|
-
}
|
242
|
-
else {
|
243
|
-
this.renderer.removeClass(this.element.nativeElement, `${CLASS_NAME.SHOW}`);
|
244
|
-
}
|
245
|
-
}
|
246
|
-
constructor(element, renderer) {
|
247
|
-
this._isAnimated = false;
|
248
|
-
this._isShown = false;
|
249
|
-
this.element = element;
|
250
|
-
this.renderer = renderer;
|
251
|
-
}
|
252
|
-
ngOnInit() {
|
253
|
-
if (this.isAnimated) {
|
254
|
-
this.renderer.addClass(this.element.nativeElement, `${CLASS_NAME.FADE}`);
|
255
|
-
Utils.reflow(this.element.nativeElement);
|
256
|
-
}
|
257
|
-
this.isShown = true;
|
258
|
-
}
|
259
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: ModalBackdropComponent, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Component }); }
|
260
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.0.1", type: ModalBackdropComponent, selector: "bs-modal-backdrop", host: { classAttribute: "modal-backdrop" }, ngImport: i0, template: ' ', isInline: true }); }
|
447
|
+
role="document"
|
448
|
+
focusTrap>
|
449
|
+
<div class="modal-content">
|
450
|
+
<ng-content></ng-content>
|
451
|
+
</div>
|
452
|
+
</div>
|
453
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: FocusTrapDirective, selector: "[focusTrap]", inputs: ["cdkTrapFocus", "cdkTrapFocusAutoCapture"], exportAs: ["focusTrap"] }] }); }
|
261
454
|
}
|
262
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type:
|
455
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: ModalContainerComponent, decorators: [{
|
263
456
|
type: Component,
|
264
457
|
args: [{
|
265
|
-
selector: '
|
266
|
-
template:
|
458
|
+
selector: 'modal-container',
|
459
|
+
template: `
|
460
|
+
<div [class]="'modal-dialog' + (config.class ? ' ' + config.class : '')"
|
461
|
+
role="document"
|
462
|
+
focusTrap>
|
463
|
+
<div class="modal-content">
|
464
|
+
<ng-content></ng-content>
|
465
|
+
</div>
|
466
|
+
</div>
|
467
|
+
`,
|
267
468
|
// eslint-disable-next-line @angular-eslint/no-host-metadata-property
|
268
|
-
host: {
|
469
|
+
host: {
|
470
|
+
class: 'modal',
|
471
|
+
role: 'dialog',
|
472
|
+
tabindex: '-1',
|
473
|
+
'[attr.aria-modal]': 'true',
|
474
|
+
'[attr.aria-labelledby]': 'config.ariaLabelledBy',
|
475
|
+
'[attr.aria-describedby]': 'config.ariaDescribedby'
|
476
|
+
},
|
477
|
+
standalone: true,
|
478
|
+
imports: [FocusTrapDirective],
|
479
|
+
providers: [BsModalService]
|
269
480
|
}]
|
270
|
-
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }]
|
481
|
+
}], ctorParameters: () => [{ type: ModalOptions }, { type: i0.ElementRef }, { type: i0.Renderer2 }], propDecorators: { onClickStarted: [{
|
482
|
+
type: HostListener,
|
483
|
+
args: ['mousedown', ['$event']]
|
484
|
+
}], onClickStop: [{
|
485
|
+
type: HostListener,
|
486
|
+
args: ['click', ['$event']]
|
487
|
+
}], onPopState: [{
|
488
|
+
type: HostListener,
|
489
|
+
args: ['window:popstate']
|
490
|
+
}], onEsc: [{
|
491
|
+
type: HostListener,
|
492
|
+
args: ['window:keydown.esc', ['$event']]
|
493
|
+
}] } });
|
271
494
|
|
272
495
|
// todo: should we support enforce focus in?
|
273
496
|
// todo: in original bs there are was a way to prevent modal from showing
|
@@ -589,13 +812,14 @@ class ModalDirective {
|
|
589
812
|
return scrollbarWidth;
|
590
813
|
}
|
591
814
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: ModalDirective, deps: [{ token: i0.ElementRef }, { token: i0.ViewContainerRef }, { token: i0.Renderer2 }, { token: i1.ComponentLoaderFactory }, { token: MODAL_CONFIG_DEFAULT_OVERRIDE, optional: true }], target: i0.ɵɵFactoryTarget.Directive }); }
|
592
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.0.1", type: ModalDirective, selector: "[bsModal]", inputs: { config: "config", closeInterceptor: "closeInterceptor" }, outputs: { onShow: "onShow", onShown: "onShown", onHide: "onHide", onHidden: "onHidden" }, host: { listeners: { "mousedown": "onClickStarted($event)", "mouseup": "onClickStop($event)", "keydown.esc": "onEsc($event)" } }, exportAs: ["bs-modal"], ngImport: i0 }); }
|
815
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.0.1", type: ModalDirective, isStandalone: true, selector: "[bsModal]", inputs: { config: "config", closeInterceptor: "closeInterceptor" }, outputs: { onShow: "onShow", onShown: "onShown", onHide: "onHide", onHidden: "onHidden" }, host: { listeners: { "mousedown": "onClickStarted($event)", "mouseup": "onClickStop($event)", "keydown.esc": "onEsc($event)" } }, exportAs: ["bs-modal"], ngImport: i0 }); }
|
593
816
|
}
|
594
817
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: ModalDirective, decorators: [{
|
595
818
|
type: Directive,
|
596
819
|
args: [{
|
597
820
|
selector: '[bsModal]',
|
598
|
-
exportAs: 'bs-modal'
|
821
|
+
exportAs: 'bs-modal',
|
822
|
+
standalone: true
|
599
823
|
}]
|
600
824
|
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.ViewContainerRef }, { type: i0.Renderer2 }, { type: i1.ComponentLoaderFactory }, { type: ModalOptions, decorators: [{
|
601
825
|
type: Optional
|
@@ -625,229 +849,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.1", ngImpor
|
|
625
849
|
args: ['keydown.esc', ['$event']]
|
626
850
|
}] } });
|
627
851
|
|
628
|
-
let currentId = 1;
|
629
|
-
class BsModalService {
|
630
|
-
constructor(rendererFactory, clf, modalDefaultOption) {
|
631
|
-
this.clf = clf;
|
632
|
-
this.modalDefaultOption = modalDefaultOption;
|
633
|
-
this.onShow = new EventEmitter();
|
634
|
-
this.onShown = new EventEmitter();
|
635
|
-
this.onHide = new EventEmitter();
|
636
|
-
this.onHidden = new EventEmitter();
|
637
|
-
this.isBodyOverflowing = false;
|
638
|
-
this.originalBodyPadding = 0;
|
639
|
-
this.scrollbarWidth = 0;
|
640
|
-
this.modalsCount = 0;
|
641
|
-
this.loaders = [];
|
642
|
-
this._focusEl = null;
|
643
|
-
this._backdropLoader = this.clf.createLoader();
|
644
|
-
this._renderer = rendererFactory.createRenderer(null, null);
|
645
|
-
this.config = modalDefaultOption ?
|
646
|
-
(Object.assign({}, modalConfigDefaults, modalDefaultOption)) :
|
647
|
-
modalConfigDefaults;
|
648
|
-
}
|
649
|
-
/** Shows a modal */
|
650
|
-
show(
|
651
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
652
|
-
content, config) {
|
653
|
-
this._focusEl = document.activeElement;
|
654
|
-
this.modalsCount++;
|
655
|
-
this._createLoaders();
|
656
|
-
// must be different per every show() call
|
657
|
-
const id = config?.id || currentId++;
|
658
|
-
this.config = this.modalDefaultOption ?
|
659
|
-
Object.assign({}, modalConfigDefaults, this.modalDefaultOption, config) :
|
660
|
-
Object.assign({}, modalConfigDefaults, config);
|
661
|
-
this.config.id = id;
|
662
|
-
this._showBackdrop();
|
663
|
-
this.lastDismissReason = void 0;
|
664
|
-
return this._showModal(content);
|
665
|
-
}
|
666
|
-
hide(id) {
|
667
|
-
if (this.modalsCount === 1 || id == null) {
|
668
|
-
this._hideBackdrop();
|
669
|
-
this.resetScrollbar();
|
670
|
-
}
|
671
|
-
this.modalsCount = this.modalsCount >= 1 && id != null ? this.modalsCount - 1 : 0;
|
672
|
-
setTimeout(() => {
|
673
|
-
this._hideModal(id);
|
674
|
-
this.removeLoaders(id);
|
675
|
-
}, this.config.animated ? TRANSITION_DURATIONS.BACKDROP : 0);
|
676
|
-
if (this._focusEl) {
|
677
|
-
this._focusEl.focus();
|
678
|
-
}
|
679
|
-
}
|
680
|
-
_showBackdrop() {
|
681
|
-
const isBackdropEnabled = this.config.backdrop === true || this.config.backdrop === 'static';
|
682
|
-
const isBackdropInDOM = !this.backdropRef || !this.backdropRef.instance.isShown;
|
683
|
-
if (this.modalsCount === 1) {
|
684
|
-
this.removeBackdrop();
|
685
|
-
if (isBackdropEnabled && isBackdropInDOM) {
|
686
|
-
this._backdropLoader
|
687
|
-
.attach(ModalBackdropComponent)
|
688
|
-
.to('body')
|
689
|
-
.show({ isAnimated: this.config.animated });
|
690
|
-
this.backdropRef = this._backdropLoader._componentRef;
|
691
|
-
}
|
692
|
-
}
|
693
|
-
}
|
694
|
-
_hideBackdrop() {
|
695
|
-
if (!this.backdropRef) {
|
696
|
-
return;
|
697
|
-
}
|
698
|
-
this.backdropRef.instance.isShown = false;
|
699
|
-
const duration = this.config.animated ? TRANSITION_DURATIONS.BACKDROP : 0;
|
700
|
-
setTimeout(() => this.removeBackdrop(), duration);
|
701
|
-
}
|
702
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
703
|
-
_showModal(content) {
|
704
|
-
const modalLoader = this.loaders[this.loaders.length - 1];
|
705
|
-
if (this.config && this.config.providers) {
|
706
|
-
for (const provider of this.config.providers) {
|
707
|
-
modalLoader.provide(provider);
|
708
|
-
}
|
709
|
-
}
|
710
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
711
|
-
const bsModalRef = new BsModalRef();
|
712
|
-
const modalContainerRef = modalLoader
|
713
|
-
.provide({ provide: ModalOptions, useValue: this.config })
|
714
|
-
.provide({ provide: BsModalRef, useValue: bsModalRef })
|
715
|
-
.attach(ModalContainerComponent)
|
716
|
-
.to('body');
|
717
|
-
bsModalRef.hide = () => this.hide(bsModalRef.id);
|
718
|
-
bsModalRef.setClass = (newClass) => {
|
719
|
-
if (modalContainerRef.instance) {
|
720
|
-
modalContainerRef.instance.config.class = newClass;
|
721
|
-
}
|
722
|
-
};
|
723
|
-
bsModalRef.onHidden = new EventEmitter();
|
724
|
-
bsModalRef.onHide = new EventEmitter();
|
725
|
-
this.copyEvent(modalLoader.onBeforeHide, bsModalRef.onHide);
|
726
|
-
this.copyEvent(modalLoader.onHidden, bsModalRef.onHidden);
|
727
|
-
// call 'show' method after assign setClass in bsModalRef.
|
728
|
-
// it makes modal component's bsModalRef available to call setClass method
|
729
|
-
modalContainerRef.show({
|
730
|
-
content,
|
731
|
-
isAnimated: this.config.animated,
|
732
|
-
initialState: this.config.initialState,
|
733
|
-
bsModalService: this,
|
734
|
-
id: this.config.id
|
735
|
-
});
|
736
|
-
if (modalContainerRef.instance) {
|
737
|
-
modalContainerRef.instance.level = this.getModalsCount();
|
738
|
-
bsModalRef.content = modalLoader.getInnerComponent();
|
739
|
-
bsModalRef.id = modalContainerRef.instance.config?.id;
|
740
|
-
}
|
741
|
-
return bsModalRef;
|
742
|
-
}
|
743
|
-
_hideModal(id) {
|
744
|
-
if (id != null) {
|
745
|
-
const indexToRemove = this.loaders.findIndex(loader => loader.instance?.config.id === id);
|
746
|
-
const modalLoader = this.loaders[indexToRemove];
|
747
|
-
if (modalLoader) {
|
748
|
-
modalLoader.hide(id);
|
749
|
-
}
|
750
|
-
}
|
751
|
-
else {
|
752
|
-
this.loaders.forEach((loader) => {
|
753
|
-
if (loader.instance) {
|
754
|
-
loader.hide(loader.instance.config.id);
|
755
|
-
}
|
756
|
-
});
|
757
|
-
}
|
758
|
-
}
|
759
|
-
getModalsCount() {
|
760
|
-
return this.modalsCount;
|
761
|
-
}
|
762
|
-
setDismissReason(reason) {
|
763
|
-
this.lastDismissReason = reason;
|
764
|
-
}
|
765
|
-
removeBackdrop() {
|
766
|
-
this._renderer.removeClass(document.body, CLASS_NAME.OPEN);
|
767
|
-
this._renderer.setStyle(document.body, 'overflow-y', '');
|
768
|
-
this._backdropLoader.hide();
|
769
|
-
this.backdropRef = void 0;
|
770
|
-
}
|
771
|
-
/** Checks if the body is overflowing and sets scrollbar width */
|
772
|
-
/** @internal */
|
773
|
-
checkScrollbar() {
|
774
|
-
this.isBodyOverflowing = document.body.clientWidth < window.innerWidth;
|
775
|
-
this.scrollbarWidth = this.getScrollbarWidth();
|
776
|
-
}
|
777
|
-
setScrollbar() {
|
778
|
-
if (!document) {
|
779
|
-
return;
|
780
|
-
}
|
781
|
-
this.originalBodyPadding = parseInt(window
|
782
|
-
.getComputedStyle(document.body)
|
783
|
-
.getPropertyValue('padding-right') || '0', 10);
|
784
|
-
if (this.isBodyOverflowing) {
|
785
|
-
document.body.style.paddingRight = `${this.originalBodyPadding +
|
786
|
-
this.scrollbarWidth}px`;
|
787
|
-
}
|
788
|
-
}
|
789
|
-
resetScrollbar() {
|
790
|
-
document.body.style.paddingRight = `${this.originalBodyPadding}px`;
|
791
|
-
}
|
792
|
-
// thx d.walsh
|
793
|
-
getScrollbarWidth() {
|
794
|
-
const scrollDiv = this._renderer.createElement('div');
|
795
|
-
this._renderer.addClass(scrollDiv, CLASS_NAME.SCROLLBAR_MEASURER);
|
796
|
-
this._renderer.appendChild(document.body, scrollDiv);
|
797
|
-
const scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
|
798
|
-
this._renderer.removeChild(document.body, scrollDiv);
|
799
|
-
return scrollbarWidth;
|
800
|
-
}
|
801
|
-
_createLoaders() {
|
802
|
-
const loader = this.clf.createLoader();
|
803
|
-
this.copyEvent(loader.onBeforeShow, this.onShow);
|
804
|
-
this.copyEvent(loader.onShown, this.onShown);
|
805
|
-
this.copyEvent(loader.onBeforeHide, this.onHide);
|
806
|
-
this.copyEvent(loader.onHidden, this.onHidden);
|
807
|
-
this.loaders.push(loader);
|
808
|
-
}
|
809
|
-
removeLoaders(id) {
|
810
|
-
if (id != null) {
|
811
|
-
const indexToRemove = this.loaders.findIndex(loader => loader.instance?.config.id === id);
|
812
|
-
if (indexToRemove >= 0) {
|
813
|
-
this.loaders.splice(indexToRemove, 1);
|
814
|
-
this.loaders.forEach((loader, i) => {
|
815
|
-
if (loader.instance) {
|
816
|
-
loader.instance.level = i + 1;
|
817
|
-
}
|
818
|
-
});
|
819
|
-
}
|
820
|
-
}
|
821
|
-
else {
|
822
|
-
this.loaders.splice(0, this.loaders.length);
|
823
|
-
}
|
824
|
-
}
|
825
|
-
copyEvent(from, to) {
|
826
|
-
from.subscribe((data) => {
|
827
|
-
to.emit(this.lastDismissReason || data);
|
828
|
-
});
|
829
|
-
}
|
830
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: BsModalService, deps: [{ token: i0.RendererFactory2 }, { token: i1.ComponentLoaderFactory }, { token: MODAL_CONFIG_DEFAULT_OVERRIDE, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
831
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: BsModalService, providedIn: 'platform' }); }
|
832
|
-
}
|
833
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: BsModalService, decorators: [{
|
834
|
-
type: Injectable,
|
835
|
-
args: [{ providedIn: 'platform' }]
|
836
|
-
}], ctorParameters: () => [{ type: i0.RendererFactory2 }, { type: i1.ComponentLoaderFactory }, { type: ModalOptions, decorators: [{
|
837
|
-
type: Optional
|
838
|
-
}, {
|
839
|
-
type: Inject,
|
840
|
-
args: [MODAL_CONFIG_DEFAULT_OVERRIDE]
|
841
|
-
}] }] });
|
842
|
-
|
843
|
-
const focusTrapModule = FocusTrapModule.forRoot();
|
844
852
|
class ModalModule {
|
853
|
+
// @deprecated method not required anymore, will be deleted in v19.0.0
|
845
854
|
static forRoot() {
|
846
855
|
return {
|
847
856
|
ngModule: ModalModule,
|
848
857
|
providers: [BsModalService, ComponentLoaderFactory, PositioningService]
|
849
858
|
};
|
850
859
|
}
|
860
|
+
// @deprecated method not required anymore, will be deleted in v19.0.0
|
851
861
|
static forChild() {
|
852
862
|
return {
|
853
863
|
ngModule: ModalModule,
|
@@ -855,16 +865,17 @@ class ModalModule {
|
|
855
865
|
};
|
856
866
|
}
|
857
867
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: ModalModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
858
|
-
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.0.1", ngImport: i0, type: ModalModule,
|
868
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.0.1", ngImport: i0, type: ModalModule, imports: [FocusTrapModule,
|
869
|
+
ModalBackdropComponent,
|
859
870
|
ModalDirective,
|
860
|
-
ModalContainerComponent],
|
871
|
+
ModalContainerComponent], exports: [ModalBackdropComponent, ModalDirective] }); }
|
861
872
|
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: ModalModule, imports: [FocusTrapModule] }); }
|
862
873
|
}
|
863
874
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: ModalModule, decorators: [{
|
864
875
|
type: NgModule,
|
865
876
|
args: [{
|
866
|
-
imports: [
|
867
|
-
|
877
|
+
imports: [
|
878
|
+
FocusTrapModule,
|
868
879
|
ModalBackdropComponent,
|
869
880
|
ModalDirective,
|
870
881
|
ModalContainerComponent
|