@mintplayer/ng-bootstrap 15.16.0 → 15.16.1

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.
@@ -11,6 +11,10 @@ import { BsNoNoscriptModule } from '@mintplayer/ng-bootstrap/no-noscript';
11
11
  import { Color } from '@mintplayer/ng-bootstrap';
12
12
  import { BehaviorSubject, Subject, map, combineLatest, filter, debounceTime, takeUntil, take } from 'rxjs';
13
13
  import { SlideUpDownAnimation } from '@mintplayer/ng-animations';
14
+ import { takeUntil as takeUntil$1 } from 'rxjs/operators';
15
+ import { DomPortal } from '@angular/cdk/portal';
16
+ import * as i4 from '@mintplayer/ng-bootstrap/has-overlay';
17
+ import { BsHasOverlayModule } from '@mintplayer/ng-bootstrap/has-overlay';
14
18
 
15
19
  class BsNavbarComponent {
16
20
  constructor() {
@@ -209,13 +213,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
209
213
  }] } });
210
214
 
211
215
  class BsNavbarItemComponent {
212
- constructor(navbar, element, injector, platformId, parentDropdown) {
216
+ constructor(navbar, element,
217
+ // private injector: Injector,
218
+ platformId, parentDropdown) {
213
219
  this.navbar = navbar;
214
- this.element = element;
215
- this.injector = injector;
216
220
  this.platformId = platformId;
217
221
  this.hasDropdown = false;
218
222
  this.anchorTag = null;
223
+ this.destroyed$ = new Subject();
224
+ this.element = element;
219
225
  this.parentDropdown = parentDropdown;
220
226
  }
221
227
  ngAfterContentChecked() {
@@ -236,16 +242,28 @@ class BsNavbarItemComponent {
236
242
  dropdown.childDropdowns.forEach((child) => {
237
243
  child.isVisible = false;
238
244
  });
239
- // } else {
245
+ }
246
+ else if (this.parentDropdown) {
240
247
  // import('@angular/cdk/overlay').then(({ OverlayModule, Overlay }) => {
241
248
  // const overlayService = this.injector.get(Overlay);
242
249
  // return overlayService;
243
250
  // }).then((overlayService) => {
244
251
  // const p = new DomPortal(dropdown.element);
245
252
  // const overlayRef = overlayService.create({
253
+ // positionStrategy: overlayService.position()
254
+ // .flexibleConnectedTo(this.element)
255
+ // .withPositions([
256
+ // { originX: 'end', originY: 'top', overlayX: 'start', overlayY: 'top' }
257
+ // ])
246
258
  // });
247
- // overlayRef.attach(p);
259
+ // overlayRef.attach(p);
248
260
  // });
261
+ // dropdown.showInOverlay = true;
262
+ this.navbar.isSmallMode$
263
+ .pipe(takeUntil$1(this.destroyed$))
264
+ .subscribe((isSmallMode) => {
265
+ dropdown.showInOverlay = !isSmallMode;
266
+ });
249
267
  }
250
268
  });
251
269
  return false;
@@ -270,13 +288,16 @@ class BsNavbarItemComponent {
270
288
  }
271
289
  }
272
290
  }
291
+ ngOnDestroy() {
292
+ this.destroyed$.next(true);
293
+ }
273
294
  }
274
- BsNavbarItemComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: BsNavbarItemComponent, deps: [{ token: BsNavbarComponent }, { token: i0.ElementRef }, { token: i0.Injector }, { token: PLATFORM_ID }, { token: BsNavbarDropdownComponent, optional: true }], target: i0.ɵɵFactoryTarget.Component });
295
+ BsNavbarItemComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: BsNavbarItemComponent, deps: [{ token: BsNavbarComponent }, { token: i0.ElementRef }, { token: PLATFORM_ID }, { token: BsNavbarDropdownComponent, optional: true }], target: i0.ɵɵFactoryTarget.Component });
275
296
  BsNavbarItemComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.0", type: BsNavbarItemComponent, selector: "bs-navbar-item", queries: [{ propertyName: "dropdowns", predicate: i0.forwardRef(function () { return BsNavbarDropdownComponent; }) }], ngImport: i0, template: "<li [class.nav-item]=\"parentDropdown === null\" [class.dropdown]=\"(dropdowns.length > 0) && (parentDropdown === null)\" [class.dropend]=\"(dropdowns.length > 0) && (parentDropdown !== null)\">\n <ng-content></ng-content>\n</li>", styles: ["li.dropend ::ng-deep a.dropdown-toggle{padding-right:1.5rem}li.dropend ::ng-deep a.dropdown-toggle:after{position:absolute;right:.5rem;top:.75rem}\n"] });
276
297
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: BsNavbarItemComponent, decorators: [{
277
298
  type: Component,
278
299
  args: [{ selector: 'bs-navbar-item', template: "<li [class.nav-item]=\"parentDropdown === null\" [class.dropdown]=\"(dropdowns.length > 0) && (parentDropdown === null)\" [class.dropend]=\"(dropdowns.length > 0) && (parentDropdown !== null)\">\n <ng-content></ng-content>\n</li>", styles: ["li.dropend ::ng-deep a.dropdown-toggle{padding-right:1.5rem}li.dropend ::ng-deep a.dropdown-toggle:after{position:absolute;right:.5rem;top:.75rem}\n"] }]
279
- }], ctorParameters: function () { return [{ type: BsNavbarComponent }, { type: i0.ElementRef }, { type: i0.Injector }, { type: Object, decorators: [{
300
+ }], ctorParameters: function () { return [{ type: BsNavbarComponent }, { type: i0.ElementRef }, { type: Object, decorators: [{
280
301
  type: Inject,
281
302
  args: [PLATFORM_ID]
282
303
  }] }, { type: BsNavbarDropdownComponent, decorators: [{
@@ -287,10 +308,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
287
308
  }] } });
288
309
 
289
310
  class BsNavbarDropdownComponent {
290
- constructor(navbar, parentDropdown, navbarItem, element, document, platformId) {
311
+ constructor(navbar, parentDropdown, navbarItem, element, injector, document, platformId) {
291
312
  this.navbar = navbar;
292
313
  this.element = element;
314
+ this.injector = injector;
293
315
  this.document = document;
316
+ this.isAttached = false;
294
317
  this.autoclose = true;
295
318
  this.destroyed$ = new Subject();
296
319
  this.isBrowser = false;
@@ -302,6 +325,7 @@ class BsNavbarDropdownComponent {
302
325
  this.isBrowser = !isPlatformServer(platformId);
303
326
  this.isVisible$.pipe(takeUntil(this.destroyed$)).subscribe((isVisible) => {
304
327
  if (isVisible) {
328
+ setTimeout(() => this.overlay && this.overlay.updatePosition(), 20);
305
329
  this.topPos$.next(this.element.nativeElement.offsetTop);
306
330
  }
307
331
  else {
@@ -325,10 +349,48 @@ class BsNavbarDropdownComponent {
325
349
  if (isSmallMode) {
326
350
  return null;
327
351
  }
352
+ else if (isPlatformServer(platformId)) {
353
+ // Javascript disabled
354
+ // Only apply max-height to the top-dropdown
355
+ return parentDropdown ? null : maxHeight;
356
+ }
328
357
  else {
358
+ // If javascript enabled
329
359
  return maxHeight;
330
360
  }
331
361
  }));
362
+ if (!!parentDropdown) {
363
+ // Setup overlay
364
+ import('@angular/cdk/overlay').then(({ OverlayModule, Overlay }) => {
365
+ const overlayService = this.injector.get(Overlay);
366
+ return overlayService;
367
+ }).then((overlayService) => {
368
+ this.domPortal = new DomPortal(this.element);
369
+ this.overlay = overlayService.create({
370
+ positionStrategy: overlayService.position()
371
+ .flexibleConnectedTo(this.navbarItem.element)
372
+ .withPositions([
373
+ { originX: 'end', originY: 'top', overlayX: 'start', overlayY: 'top', offsetX: -7, offsetY: -9 }
374
+ ])
375
+ });
376
+ // For some reason we have to trigger this from the BsDropdownItem
377
+ // this.showInOverlay = true;
378
+ });
379
+ }
380
+ }
381
+ set showInOverlay(value) {
382
+ if (this.overlay && this.domPortal) {
383
+ console.log('showInOverlay', value);
384
+ // if (value && !this.overlay.hasAttached()) {
385
+ if (value && !this.isAttached) {
386
+ this.overlay.attach(this.domPortal);
387
+ this.isAttached = true;
388
+ }
389
+ if (!value && this.isAttached) {
390
+ this.overlay.detach();
391
+ this.isAttached = false;
392
+ }
393
+ }
332
394
  }
333
395
  get isVisible() {
334
396
  return this.isVisible$.value;
@@ -344,11 +406,11 @@ class BsNavbarDropdownComponent {
344
406
  this.destroyed$.next(true);
345
407
  }
346
408
  }
347
- BsNavbarDropdownComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: BsNavbarDropdownComponent, deps: [{ token: BsNavbarComponent }, { token: BsNavbarDropdownComponent, host: true, optional: true, skipSelf: true }, { token: forwardRef(() => BsNavbarItemComponent), host: true }, { token: i0.ElementRef }, { token: DOCUMENT }, { token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Component });
348
- BsNavbarDropdownComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.0", type: BsNavbarDropdownComponent, selector: "bs-navbar-dropdown", inputs: { autoclose: "autoclose" }, queries: [{ propertyName: "childDropdowns", predicate: i0.forwardRef(function () { return BsNavbarDropdownComponent; }), descendants: true }], viewQueries: [{ propertyName: "dropdownElement", first: true, predicate: ["dd"], descendants: true }], ngImport: i0, template: "<!-- <bs-has-overlay></bs-has-overlay> -->\n<!-- [class.overflow-auto]=\"isBrowser\" -->\n<!-- [style.max-height]=\"maxHeightOrNull$ | async\" -->\n<ul #dd class=\"dropdown-menu\" [class.show]=\"isVisible$ | async\" [class.submenu]=\"!!parentDropdown\" (clickOutside)=\"isVisible = false\" [exclude]=\"elementsToExclude\" aria-labelledby=\"navbarDropdown\">\n <ng-content></ng-content>\n</ul>\n\n<!-- \n - Working demo: https://codepen.io/agop/pen/VwwMGR\n - Location must be set through javascript\n - bsNoScript => If noscript, 2nd-level submenus must be shown inside the 1st-level submenu\n -->\n <!-- \n - Another option: https://stackblitz.com/edit/web-platform-vmsr4l?file=index.html\n - But this doesn't seem to work here\n -->", styles: ["@media (max-width: 767px){.submenu{margin-left:.5rem;margin-right:.5rem}}@media (min-width: 768px){.submenu{position:absolute;left:100%;top:-1px;margin-top:-.5rem}}\n"], dependencies: [{ kind: "directive", type: i2$1.ClickOutsideDirective, selector: "[clickOutside]", inputs: ["clickOutsideEnabled", "attachOutsideOnClick", "delayClickOutsideInit", "emitOnBlur", "exclude", "excludeBeforeClick", "clickOutsideEvents"], outputs: ["clickOutside"] }, { kind: "pipe", type: i1.AsyncPipe, name: "async" }] });
409
+ BsNavbarDropdownComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: BsNavbarDropdownComponent, deps: [{ token: BsNavbarComponent }, { token: BsNavbarDropdownComponent, host: true, optional: true, skipSelf: true }, { token: forwardRef(() => BsNavbarItemComponent), host: true }, { token: i0.ElementRef }, { token: i0.Injector }, { token: DOCUMENT }, { token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Component });
410
+ BsNavbarDropdownComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.0", type: BsNavbarDropdownComponent, selector: "bs-navbar-dropdown", inputs: { autoclose: "autoclose" }, queries: [{ propertyName: "childDropdowns", predicate: i0.forwardRef(function () { return BsNavbarDropdownComponent; }), descendants: true }], viewQueries: [{ propertyName: "dropdownElement", first: true, predicate: ["dd"], descendants: true }], ngImport: i0, template: "<bs-has-overlay></bs-has-overlay>\n<ul #dd class=\"dropdown-menu\" [class.show]=\"isVisible$ | async\" [class.submenu]=\"!!parentDropdown\" [class.overflow-y-auto]=\"isBrowser\" [style.max-height]=\"maxHeightOrNull$ | async\" bsNoNoscript (clickOutside)=\"isVisible = false\" [exclude]=\"elementsToExclude\" aria-labelledby=\"navbarDropdown\">\n <ng-content></ng-content>\n</ul>\n\n<!-- \n - Working demo: https://codepen.io/agop/pen/VwwMGR\n - Location must be set through javascript\n - bsNoScript => If noscript, 2nd-level submenus must be shown inside the 1st-level submenu\n -->\n <!-- \n - Another option: https://stackblitz.com/edit/web-platform-vmsr4l?file=index.html\n - But this doesn't seem to work here\n -->", styles: [".submenu:not(.noscript){margin:0 .5rem!important}.submenu.noscript{margin:0 .5rem;position:initial!important}:not(.submenu).noscript{max-height:calc(100vh - 100% - 1rem);overflow-y:auto}.overflow-y-auto{overflow-y:auto}\n"], dependencies: [{ kind: "directive", type: i2$1.ClickOutsideDirective, selector: "[clickOutside]", inputs: ["clickOutsideEnabled", "attachOutsideOnClick", "delayClickOutsideInit", "emitOnBlur", "exclude", "excludeBeforeClick", "clickOutsideEvents"], outputs: ["clickOutside"] }, { kind: "directive", type: i3.BsNoNoscriptDirective, selector: "[bsNoNoscript]" }, { kind: "component", type: i4.BsHasOverlayComponent, selector: "bs-has-overlay" }, { kind: "pipe", type: i1.AsyncPipe, name: "async" }] });
349
411
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: BsNavbarDropdownComponent, decorators: [{
350
412
  type: Component,
351
- args: [{ selector: 'bs-navbar-dropdown', template: "<!-- <bs-has-overlay></bs-has-overlay> -->\n<!-- [class.overflow-auto]=\"isBrowser\" -->\n<!-- [style.max-height]=\"maxHeightOrNull$ | async\" -->\n<ul #dd class=\"dropdown-menu\" [class.show]=\"isVisible$ | async\" [class.submenu]=\"!!parentDropdown\" (clickOutside)=\"isVisible = false\" [exclude]=\"elementsToExclude\" aria-labelledby=\"navbarDropdown\">\n <ng-content></ng-content>\n</ul>\n\n<!-- \n - Working demo: https://codepen.io/agop/pen/VwwMGR\n - Location must be set through javascript\n - bsNoScript => If noscript, 2nd-level submenus must be shown inside the 1st-level submenu\n -->\n <!-- \n - Another option: https://stackblitz.com/edit/web-platform-vmsr4l?file=index.html\n - But this doesn't seem to work here\n -->", styles: ["@media (max-width: 767px){.submenu{margin-left:.5rem;margin-right:.5rem}}@media (min-width: 768px){.submenu{position:absolute;left:100%;top:-1px;margin-top:-.5rem}}\n"] }]
413
+ args: [{ selector: 'bs-navbar-dropdown', template: "<bs-has-overlay></bs-has-overlay>\n<ul #dd class=\"dropdown-menu\" [class.show]=\"isVisible$ | async\" [class.submenu]=\"!!parentDropdown\" [class.overflow-y-auto]=\"isBrowser\" [style.max-height]=\"maxHeightOrNull$ | async\" bsNoNoscript (clickOutside)=\"isVisible = false\" [exclude]=\"elementsToExclude\" aria-labelledby=\"navbarDropdown\">\n <ng-content></ng-content>\n</ul>\n\n<!-- \n - Working demo: https://codepen.io/agop/pen/VwwMGR\n - Location must be set through javascript\n - bsNoScript => If noscript, 2nd-level submenus must be shown inside the 1st-level submenu\n -->\n <!-- \n - Another option: https://stackblitz.com/edit/web-platform-vmsr4l?file=index.html\n - But this doesn't seem to work here\n -->", styles: [".submenu:not(.noscript){margin:0 .5rem!important}.submenu.noscript{margin:0 .5rem;position:initial!important}:not(.submenu).noscript{max-height:calc(100vh - 100% - 1rem);overflow-y:auto}.overflow-y-auto{overflow-y:auto}\n"] }]
352
414
  }], ctorParameters: function () { return [{ type: BsNavbarComponent }, { type: BsNavbarDropdownComponent, decorators: [{
353
415
  type: SkipSelf
354
416
  }, {
@@ -360,7 +422,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
360
422
  }, {
361
423
  type: Inject,
362
424
  args: [forwardRef(() => BsNavbarItemComponent)]
363
- }] }, { type: i0.ElementRef }, { type: Document, decorators: [{
425
+ }] }, { type: i0.ElementRef }, { type: i0.Injector }, { type: Document, decorators: [{
364
426
  type: Inject,
365
427
  args: [DOCUMENT]
366
428
  }] }, { type: Object, decorators: [{
@@ -581,7 +643,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
581
643
  args: ['click', ['$event']]
582
644
  }] } });
583
645
 
584
- // import { BsHasOverlayModule } from '@mintplayer/ng-bootstrap/has-overlay';
585
646
  class BsNavbarModule {
586
647
  }
587
648
  BsNavbarModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: BsNavbarModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
@@ -597,7 +658,8 @@ BsNavbarModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version:
597
658
  BsNavbarTogglerComponent], imports: [CommonModule,
598
659
  ClickOutsideModule,
599
660
  BsUserAgentModule,
600
- BsNoNoscriptModule], exports: [BsNavbarComponent,
661
+ BsNoNoscriptModule,
662
+ BsHasOverlayModule], exports: [BsNavbarComponent,
601
663
  BsNavbarNavComponent,
602
664
  BsNavbarDropdownComponent,
603
665
  BsNavbarItemComponent,
@@ -610,7 +672,8 @@ BsNavbarModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version:
610
672
  BsNavbarModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: BsNavbarModule, imports: [CommonModule,
611
673
  ClickOutsideModule,
612
674
  BsUserAgentModule,
613
- BsNoNoscriptModule] });
675
+ BsNoNoscriptModule,
676
+ BsHasOverlayModule] });
614
677
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: BsNavbarModule, decorators: [{
615
678
  type: NgModule,
616
679
  args: [{
@@ -631,7 +694,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
631
694
  ClickOutsideModule,
632
695
  BsUserAgentModule,
633
696
  BsNoNoscriptModule,
634
- // BsHasOverlayModule,
697
+ BsHasOverlayModule,
635
698
  ],
636
699
  exports: [
637
700
  BsNavbarComponent,