@dereekb/dbx-web 9.3.3 → 9.5.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.
Files changed (51) hide show
  1. package/esm2020/lib/extension/calendar/calendar.component.mjs +2 -2
  2. package/esm2020/lib/extension/calendar/calendar.store.mjs +2 -2
  3. package/esm2020/lib/index.mjs +2 -1
  4. package/esm2020/lib/layout/bar/bar.mjs +1 -1
  5. package/esm2020/lib/layout/column/two/two.column.right.component.mjs +5 -3
  6. package/esm2020/lib/layout/style/index.mjs +2 -1
  7. package/esm2020/lib/layout/style/style.mjs +16 -0
  8. package/esm2020/lib/util/cdk.mjs +22 -0
  9. package/esm2020/lib/util/index.mjs +2 -0
  10. package/esm2020/mapbox/lib/index.mjs +4 -1
  11. package/esm2020/mapbox/lib/mapbox.layout.component.mjs +132 -0
  12. package/esm2020/mapbox/lib/mapbox.layout.drawer.component.mjs +24 -0
  13. package/esm2020/mapbox/lib/mapbox.menu.component.mjs +99 -0
  14. package/esm2020/mapbox/lib/mapbox.mjs +1 -1
  15. package/esm2020/mapbox/lib/mapbox.module.mjs +53 -6
  16. package/esm2020/mapbox/lib/mapbox.store.mjs +46 -6
  17. package/fesm2015/dereekb-dbx-web-mapbox.mjs +336 -14
  18. package/fesm2015/dereekb-dbx-web-mapbox.mjs.map +1 -1
  19. package/fesm2015/dereekb-dbx-web.mjs +60 -21
  20. package/fesm2015/dereekb-dbx-web.mjs.map +1 -1
  21. package/fesm2020/dereekb-dbx-web-mapbox.mjs +330 -14
  22. package/fesm2020/dereekb-dbx-web-mapbox.mjs.map +1 -1
  23. package/fesm2020/dereekb-dbx-web.mjs +60 -21
  24. package/fesm2020/dereekb-dbx-web.mjs.map +1 -1
  25. package/lib/index.d.ts +1 -0
  26. package/lib/layout/bar/bar.d.ts +2 -1
  27. package/lib/layout/column/two/two.column.right.component.d.ts +2 -1
  28. package/lib/layout/style/_style.scss +11 -0
  29. package/lib/layout/style/index.d.ts +1 -0
  30. package/lib/layout/style/style.d.ts +3 -0
  31. package/lib/util/cdk.d.ts +9 -0
  32. package/lib/util/index.d.ts +1 -0
  33. package/mapbox/esm2020/lib/index.mjs +4 -1
  34. package/mapbox/esm2020/lib/mapbox.layout.component.mjs +132 -0
  35. package/mapbox/esm2020/lib/mapbox.layout.drawer.component.mjs +24 -0
  36. package/mapbox/esm2020/lib/mapbox.menu.component.mjs +99 -0
  37. package/mapbox/esm2020/lib/mapbox.mjs +1 -1
  38. package/mapbox/esm2020/lib/mapbox.module.mjs +53 -6
  39. package/mapbox/esm2020/lib/mapbox.store.mjs +46 -6
  40. package/mapbox/fesm2015/dereekb-dbx-web-mapbox.mjs +336 -14
  41. package/mapbox/fesm2015/dereekb-dbx-web-mapbox.mjs.map +1 -1
  42. package/mapbox/fesm2020/dereekb-dbx-web-mapbox.mjs +330 -14
  43. package/mapbox/fesm2020/dereekb-dbx-web-mapbox.mjs.map +1 -1
  44. package/mapbox/lib/index.d.ts +3 -0
  45. package/mapbox/lib/mapbox.layout.component.d.ts +44 -0
  46. package/mapbox/lib/mapbox.layout.drawer.component.d.ts +12 -0
  47. package/mapbox/lib/mapbox.menu.component.d.ts +31 -0
  48. package/mapbox/lib/mapbox.module.d.ts +10 -2
  49. package/mapbox/lib/mapbox.store.d.ts +29 -0
  50. package/mapbox/package.json +5 -5
  51. package/package.json +3 -3
@@ -1,12 +1,25 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Injectable, Optional, Inject, Directive, Host, NgModule } from '@angular/core';
2
+ import { Injectable, Optional, Inject, Directive, Host, Component, ElementRef, ViewChild, Input, ChangeDetectionStrategy, NgModule } from '@angular/core';
3
+ import * as i2$1 from '@angular/common';
3
4
  import { CommonModule } from '@angular/common';
4
- import { cleanup, filterMaybe, onTrueToFalse } from '@dereekb/rxjs';
5
- import { latLngPointFunction, latLngBoundFunction, isSameLatLngPoint, isSameLatLngBound, isWithinLatLngBoundFunction, overlapsLatLngBoundFunction, latLngPoint } from '@dereekb/util';
5
+ import { cleanup, filterMaybe, onTrueToFalse, SubscriptionObject } from '@dereekb/rxjs';
6
+ import { latLngPointFunction, latLngBoundFunction, isSameLatLngPoint, isSameLatLngBound, isWithinLatLngBoundFunction, overlapsLatLngBoundFunction, diffLatLngBoundPoints, latLngBoundCenterPoint, addLatLngPoints, latLngPoint, DestroyFunctionObject } from '@dereekb/util';
6
7
  import { ComponentStore } from '@ngrx/component-store';
7
- import { switchMap, NEVER, defaultIfEmpty, map, tap, distinctUntilChanged, shareReplay, of, combineLatest, filter, first, startWith, interval } from 'rxjs';
8
+ import { switchMap, NEVER, defaultIfEmpty, map, tap, distinctUntilChanged, shareReplay, of, combineLatest, filter, first, startWith, interval, Subject, BehaviorSubject, throttleTime, skip } from 'rxjs';
8
9
  import * as MapboxGl from 'mapbox-gl';
9
10
  import * as i1 from 'ngx-mapbox-gl';
11
+ import { dbxColorBackground, disableRightClickInCdkBackdrop } from '@dereekb/dbx-web';
12
+ import * as i3 from '@angular/material/sidenav';
13
+ import { MatDrawerContainer, MatSidenavModule } from '@angular/material/sidenav';
14
+ import * as i4 from '@angular/material/button';
15
+ import { MatButtonModule } from '@angular/material/button';
16
+ import * as i5 from '@angular/material/icon';
17
+ import { MatIconModule } from '@angular/material/icon';
18
+ import * as i6 from 'angular-resize-event';
19
+ import { AngularResizeEventModule } from 'angular-resize-event';
20
+ import * as i2 from '@dereekb/dbx-core';
21
+ import { AbstractSubscriptionDirective, safeMarkForCheck, DbxInjectionComponentModule } from '@dereekb/dbx-core';
22
+ import * as i2$2 from '@angular/material/menu';
10
23
 
11
24
  class DbxMapboxConfig {
12
25
  }
@@ -51,7 +64,8 @@ class DbxMapboxMapStore extends ComponentStore {
51
64
  lifecycleState: 'init',
52
65
  moveState: 'init',
53
66
  zoomState: 'init',
54
- rotateState: 'init'
67
+ rotateState: 'init',
68
+ retainContent: true
55
69
  });
56
70
  this.dbxMapboxService = dbxMapboxService;
57
71
  this.latLngPoint = latLngPointFunction();
@@ -88,6 +102,7 @@ class DbxMapboxMapStore extends ComponentStore {
88
102
  addListener('rotateend', () => this._setRotateState('idle'));
89
103
  addListener('click', (x) => this._setClickEvent(x));
90
104
  addListener('dblclick', (x) => this._setDoubleClickEvent(x));
105
+ addListener('contextmenu', (x) => this._setRightClickEvent(x));
91
106
  const subs = [];
92
107
  return {
93
108
  service,
@@ -270,17 +285,23 @@ class DbxMapboxMapStore extends ComponentStore {
270
285
  this.bearing$ = this.whenInitialized$.pipe(switchMap(() => {
271
286
  return this.isRotating$.pipe(onTrueToFalse(), startWith(undefined), switchMap((x) => this.bearingNow$.pipe(first())), distinctUntilChanged(), shareReplay(1));
272
287
  }));
273
- this.clickEvent$ = this.state$.pipe(map((x) => x.clickEvent));
274
- this.doubleClickEvent$ = this.state$.pipe(map((x) => x.doubleClickEvent));
288
+ this.content$ = this.state$.pipe(map((x) => x.content), distinctUntilChanged(), shareReplay(1));
289
+ this.hasContent$ = this.content$.pipe(map(Boolean));
290
+ this.clickEvent$ = this.state$.pipe(map((x) => x.clickEvent), distinctUntilChanged(), shareReplay(1));
291
+ this.doubleClickEvent$ = this.state$.pipe(map((x) => x.doubleClickEvent), distinctUntilChanged(), shareReplay(1));
292
+ this.rightClickEvent$ = this.state$.pipe(map((x) => x.rightClickEvent), distinctUntilChanged(), shareReplay(1));
275
293
  // MARK: State Changes
276
- this._setMapService = this.updater((state, mapService) => ({ mapService, moveState: 'init', lifecycleState: 'init', zoomState: 'init', rotateState: 'init' }));
294
+ this._setMapService = this.updater((state, mapService) => ({ mapService, moveState: 'init', lifecycleState: 'init', zoomState: 'init', rotateState: 'init', retainContent: state.retainContent, content: state.retainContent ? state.content : undefined }));
277
295
  this._setLifecycleState = this.updater((state, lifecycleState) => ({ ...state, lifecycleState }));
278
296
  this._setMoveState = this.updater((state, moveState) => ({ ...state, moveState }));
279
297
  this._setZoomState = this.updater((state, zoomState) => ({ ...state, zoomState }));
280
298
  this._setRotateState = this.updater((state, rotateState) => ({ ...state, rotateState }));
281
299
  this._setClickEvent = this.updater((state, clickEvent) => ({ ...state, clickEvent }));
282
300
  this._setDoubleClickEvent = this.updater((state, doubleClickEvent) => ({ ...state, doubleClickEvent }));
301
+ this._setRightClickEvent = this.updater((state, rightClickEvent) => ({ ...state, rightClickEvent }));
283
302
  this._setError = this.updater((state, error) => ({ ...state, error }));
303
+ this.clearContent = this.updater((state) => ({ ...state, content: undefined }));
304
+ this.setContent = this.updater((state, content) => ({ ...state, content }));
284
305
  }
285
306
  // MARK: Accessors
286
307
  get timerRefreshPeriod() {
@@ -306,6 +327,38 @@ class DbxMapboxMapStore extends ComponentStore {
306
327
  }
307
328
  }), shareReplay());
308
329
  }
330
+ atNextIdle() {
331
+ return this.moveState$.pipe(map((x) => x === 'idle'), first());
332
+ }
333
+ calculateNextCenterWithOffset(inputOffset) {
334
+ const offset = this.latLngPoint(inputOffset);
335
+ return this.atNextIdle().pipe(switchMap(() => this.center$.pipe(first(), map((center) => {
336
+ const newCenter = {
337
+ lat: offset.lat + center.lat,
338
+ lng: offset.lng + center.lng
339
+ };
340
+ return newCenter;
341
+ }))));
342
+ }
343
+ calculateNextCenterOffsetWithScreenMarginChange(sizing) {
344
+ return this.atNextIdle().pipe(switchMap(() => this.bound$.pipe((first(),
345
+ map((bounds) => {
346
+ const diff = diffLatLngBoundPoints(bounds);
347
+ const center = latLngBoundCenterPoint(bounds);
348
+ const offsetWidth = sizing.leftMargin + sizing.rightMargin; // 300 + 0
349
+ const newWidth = sizing.fullWidth - offsetWidth; // 1000 - 300 - 0
350
+ const newWidthRatio = newWidth / sizing.fullWidth; // 700 / 1000
351
+ const newCenterLongitudeWidth = diff.lng * newWidthRatio; // 70% offset
352
+ const effectiveOffset = {
353
+ lat: 0,
354
+ lng: newCenterLongitudeWidth / 2
355
+ };
356
+ const newCenter = addLatLngPoints(bounds.sw, effectiveOffset);
357
+ newCenter.lat = center.lat; // retain center position
358
+ // console.log({ sizing, bounds, effectiveOffset, newWidth, offsetWidth, diff, center, newCenter });
359
+ return newCenter;
360
+ })))));
361
+ }
309
362
  }
310
363
  DbxMapboxMapStore.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.2", ngImport: i0, type: DbxMapboxMapStore, deps: [{ token: DbxMapboxService }], target: i0.ɵɵFactoryTarget.Injectable });
311
364
  DbxMapboxMapStore.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.2", ngImport: i0, type: DbxMapboxMapStore });
@@ -353,6 +406,237 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.2", ngImpor
353
406
  type: Optional
354
407
  }] }]; } });
355
408
 
409
+ /**
410
+ * Content drawer that connects with DbxMapboxMapStore to
411
+ */
412
+ class DbxMapboxLayoutDrawerComponent {
413
+ constructor(dbxMapboxMapStore) {
414
+ this.dbxMapboxMapStore = dbxMapboxMapStore;
415
+ this.config$ = this.dbxMapboxMapStore.content$;
416
+ }
417
+ }
418
+ DbxMapboxLayoutDrawerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.2", ngImport: i0, type: DbxMapboxLayoutDrawerComponent, deps: [{ token: DbxMapboxMapStore }], target: i0.ɵɵFactoryTarget.Component });
419
+ DbxMapboxLayoutDrawerComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.1.2", type: DbxMapboxLayoutDrawerComponent, selector: "dbx-mapbox-layout-drawer", host: { classAttribute: "dbx-mapbox-layout-drawer" }, ngImport: i0, template: "<div>\n <dbx-injection [config]=\"config$ | async\"></dbx-injection>\n</div>\n", dependencies: [{ kind: "component", type: i2.DbxInjectionComponent, selector: "dbx-injection, [dbxInjection], [dbx-injection]", inputs: ["config", "template"] }, { kind: "pipe", type: i2$1.AsyncPipe, name: "async" }] });
420
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.2", ngImport: i0, type: DbxMapboxLayoutDrawerComponent, decorators: [{
421
+ type: Component,
422
+ args: [{ selector: 'dbx-mapbox-layout-drawer', host: {
423
+ class: 'dbx-mapbox-layout-drawer'
424
+ }, template: "<div>\n <dbx-injection [config]=\"config$ | async\"></dbx-injection>\n</div>\n" }]
425
+ }], ctorParameters: function () { return [{ type: DbxMapboxMapStore }]; } });
426
+
427
+ /**
428
+ * Responsive component meant to split a left and right column.
429
+ *
430
+ * The left column is smaller than the right column, which contains the primary content.
431
+ *
432
+ * Requires a TwoColumnsContextStore to be provided.
433
+ */
434
+ class DbxMapboxLayoutComponent extends SubscriptionObject {
435
+ constructor(dbxMapboxMapStore) {
436
+ super();
437
+ this.dbxMapboxMapStore = dbxMapboxMapStore;
438
+ this._resized = new Subject();
439
+ this._updateMargins = new Subject();
440
+ this._side = new BehaviorSubject('right');
441
+ this._openToggle = new BehaviorSubject(true);
442
+ this._color = new BehaviorSubject(undefined);
443
+ this._toggleSub = new SubscriptionObject();
444
+ this.side$ = this._side.pipe(distinctUntilChanged(), shareReplay(1));
445
+ this.opened$ = combineLatest([this.dbxMapboxMapStore.hasContent$, this._openToggle]).pipe(map(([hasContent, open]) => hasContent && open), distinctUntilChanged(), shareReplay(1));
446
+ this.position$ = this.side$.pipe(map((x) => (x === 'right' ? 'end' : 'start')), distinctUntilChanged(), shareReplay(1));
447
+ this.drawerClasses$ = combineLatest([this.side$, this.dbxMapboxMapStore.hasContent$, this.opened$]).pipe(
448
+ //
449
+ map(([side, hasContent, open]) => (hasContent ? 'has-drawer-content' : 'no-drawer-content') + ` ${side}-drawer ` + (open ? 'open-drawer' : '')), distinctUntilChanged(), shareReplay(1));
450
+ this.drawerButtonClasses$ = combineLatest([this.dbxMapboxMapStore.hasContent$, this._color]).pipe(
451
+ //
452
+ map(([hasContent, color]) => dbxColorBackground(color)), distinctUntilChanged(), shareReplay(1));
453
+ this.buttonIcon$ = combineLatest([this.side$, this.opened$]).pipe(map(([side, opened]) => {
454
+ let icons = ['chevron_right', 'chevron_left'];
455
+ if (side === 'left') {
456
+ icons = icons.reverse();
457
+ }
458
+ return opened ? icons[0] : icons[1];
459
+ }));
460
+ }
461
+ ngOnInit() {
462
+ this.subscription = this.side$.pipe(switchMap(() => this._resized.pipe(throttleTime(100, undefined, { leading: true, trailing: true }), map(() => 'r'), startWith('s')))).subscribe((reason) => {
463
+ this.dbxMapboxMapStore.mapInstance$.subscribe((x) => {
464
+ x.resize();
465
+ // side changed
466
+ if (reason === 's') {
467
+ setTimeout(() => {
468
+ this._updateMargins.next();
469
+ });
470
+ }
471
+ });
472
+ });
473
+ this._toggleSub.subscription = combineLatest([this.opened$.pipe(distinctUntilChanged(), skip(1)), this._updateMargins]).subscribe(([opened]) => {
474
+ let { right } = this.container._contentMargins;
475
+ this.container.updateContentMargins();
476
+ setTimeout(() => {
477
+ const flip = opened ? 1 : -1;
478
+ if (opened) {
479
+ right = this.container._contentMargins.right;
480
+ }
481
+ right = (right || 0) * flip;
482
+ const element = this.content.nativeElement;
483
+ const width = element.clientWidth;
484
+ const easeTo = this.dbxMapboxMapStore
485
+ .calculateNextCenterOffsetWithScreenMarginChange({
486
+ leftMargin: 0,
487
+ rightMargin: right,
488
+ fullWidth: width
489
+ })
490
+ .pipe(first(), map((center) => ({ to: { center, duration: 3200, essential: false } })));
491
+ this.dbxMapboxMapStore.easeTo(easeTo);
492
+ });
493
+ });
494
+ }
495
+ ngOnDestroy() {
496
+ this._resized.complete();
497
+ this._updateMargins.complete();
498
+ this._side.complete();
499
+ this._openToggle.complete();
500
+ this._color.complete();
501
+ this._toggleSub.destroy();
502
+ }
503
+ toggleDrawer(open) {
504
+ if (open == null) {
505
+ open = !this._openToggle.value;
506
+ }
507
+ this._openToggle.next(open);
508
+ }
509
+ set side(side) {
510
+ if (side != null) {
511
+ this._side.next(side);
512
+ }
513
+ }
514
+ set opened(opened) {
515
+ if (opened != null) {
516
+ this._openToggle.next(opened);
517
+ }
518
+ }
519
+ set drawerColor(color) {
520
+ this._color.next(color);
521
+ }
522
+ onResized(event) {
523
+ this._resized.next();
524
+ }
525
+ }
526
+ DbxMapboxLayoutComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.2", ngImport: i0, type: DbxMapboxLayoutComponent, deps: [{ token: DbxMapboxMapStore }], target: i0.ɵɵFactoryTarget.Component });
527
+ DbxMapboxLayoutComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.1.2", type: DbxMapboxLayoutComponent, selector: "dbx-mapbox-layout", inputs: { side: "side", opened: "opened", drawerColor: "drawerColor" }, viewQueries: [{ propertyName: "container", first: true, predicate: MatDrawerContainer, descendants: true }, { propertyName: "content", first: true, predicate: ["content"], descendants: true, read: ElementRef, static: true }], usesInheritance: true, ngImport: i0, template: "<mat-drawer-container class=\"dbx-mapbox-layout-container\" [ngClass]=\"(drawerClasses$ | async) || ''\" [hasBackdrop]=\"false\">\n <mat-drawer class=\"dbx-mapbox-layout-drawer\" #drawer [opened]=\"opened$ | async\" mode=\"push\" [position]=\"(position$ | async) || 'end'\">\n <div class=\"dbx-mapbox-layout-drawer-content\" [ngClass]=\"(drawerButtonClasses$ | async) || ''\">\n <ng-content select=\"[drawer]\"></ng-content>\n <dbx-mapbox-layout-drawer></dbx-mapbox-layout-drawer>\n </div>\n </mat-drawer>\n <mat-drawer-content #content class=\"dbx-mapbox-layout-content\" (resized)=\"onResized($event)\">\n <button mat-icon-button (click)=\"toggleDrawer()\" class=\"dbx-mapbox-layout-drawer-button\" [ngClass]=\"(drawerButtonClasses$ | async) || ''\">\n <mat-icon>{{ buttonIcon$ | async }}</mat-icon>\n </button>\n <ng-content></ng-content>\n </mat-drawer-content>\n</mat-drawer-container>\n", styles: [".dbx-mapbox-layout-container{height:100%;max-width:100%}.dbx-mapbox-layout-container .mat-drawer-container{height:100%}.dbx-mapbox-layout-container .dbx-mapbox-layout-drawer-content{height:100%;width:100%;overflow:hidden}.dbx-mapbox-layout-content>.dbx-mapbox-layout-drawer-button{position:absolute;z-index:2;top:40%;border:none;display:flex;overflow:hidden}.left-drawer .dbx-mapbox-layout-content>.dbx-mapbox-layout-drawer-button{left:0;border-radius:0 20px 20px 0}.right-drawer .dbx-mapbox-layout-content>.dbx-mapbox-layout-drawer-button{right:0;border-radius:20px 0 0 20px}.has-drawer-content .dbx-mapbox-layout-content>.dbx-mapbox-layout-drawer-button{width:35px}.has-drawer-content.open-drawer .dbx-mapbox-layout-content>.dbx-mapbox-layout-drawer-button{width:35px}.no-drawer-content .dbx-mapbox-layout-content>.dbx-mapbox-layout-drawer-button{width:0px}.dbx-mapbox-layout-content>.dbx-mapbox-layout-drawer-button mat-icon{padding-left:8px}\n"], dependencies: [{ kind: "directive", type: i2$1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "component", type: i3.MatDrawer, selector: "mat-drawer", inputs: ["position", "mode", "disableClose", "autoFocus", "opened"], outputs: ["openedChange", "opened", "openedStart", "closed", "closedStart", "positionChanged"], exportAs: ["matDrawer"] }, { kind: "component", type: i3.MatDrawerContainer, selector: "mat-drawer-container", inputs: ["autosize", "hasBackdrop"], outputs: ["backdropClick"], exportAs: ["matDrawerContainer"] }, { kind: "component", type: i3.MatDrawerContent, selector: "mat-drawer-content" }, { kind: "component", type: i4.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "component", type: i5.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "directive", type: i6.ResizedDirective, selector: "[resized]", outputs: ["resized"] }, { kind: "component", type: DbxMapboxLayoutDrawerComponent, selector: "dbx-mapbox-layout-drawer" }, { kind: "pipe", type: i2$1.AsyncPipe, name: "async" }] });
528
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.2", ngImport: i0, type: DbxMapboxLayoutComponent, decorators: [{
529
+ type: Component,
530
+ args: [{ selector: 'dbx-mapbox-layout', template: "<mat-drawer-container class=\"dbx-mapbox-layout-container\" [ngClass]=\"(drawerClasses$ | async) || ''\" [hasBackdrop]=\"false\">\n <mat-drawer class=\"dbx-mapbox-layout-drawer\" #drawer [opened]=\"opened$ | async\" mode=\"push\" [position]=\"(position$ | async) || 'end'\">\n <div class=\"dbx-mapbox-layout-drawer-content\" [ngClass]=\"(drawerButtonClasses$ | async) || ''\">\n <ng-content select=\"[drawer]\"></ng-content>\n <dbx-mapbox-layout-drawer></dbx-mapbox-layout-drawer>\n </div>\n </mat-drawer>\n <mat-drawer-content #content class=\"dbx-mapbox-layout-content\" (resized)=\"onResized($event)\">\n <button mat-icon-button (click)=\"toggleDrawer()\" class=\"dbx-mapbox-layout-drawer-button\" [ngClass]=\"(drawerButtonClasses$ | async) || ''\">\n <mat-icon>{{ buttonIcon$ | async }}</mat-icon>\n </button>\n <ng-content></ng-content>\n </mat-drawer-content>\n</mat-drawer-container>\n", styles: [".dbx-mapbox-layout-container{height:100%;max-width:100%}.dbx-mapbox-layout-container .mat-drawer-container{height:100%}.dbx-mapbox-layout-container .dbx-mapbox-layout-drawer-content{height:100%;width:100%;overflow:hidden}.dbx-mapbox-layout-content>.dbx-mapbox-layout-drawer-button{position:absolute;z-index:2;top:40%;border:none;display:flex;overflow:hidden}.left-drawer .dbx-mapbox-layout-content>.dbx-mapbox-layout-drawer-button{left:0;border-radius:0 20px 20px 0}.right-drawer .dbx-mapbox-layout-content>.dbx-mapbox-layout-drawer-button{right:0;border-radius:20px 0 0 20px}.has-drawer-content .dbx-mapbox-layout-content>.dbx-mapbox-layout-drawer-button{width:35px}.has-drawer-content.open-drawer .dbx-mapbox-layout-content>.dbx-mapbox-layout-drawer-button{width:35px}.no-drawer-content .dbx-mapbox-layout-content>.dbx-mapbox-layout-drawer-button{width:0px}.dbx-mapbox-layout-content>.dbx-mapbox-layout-drawer-button mat-icon{padding-left:8px}\n"] }]
531
+ }], ctorParameters: function () { return [{ type: DbxMapboxMapStore }]; }, propDecorators: { container: [{
532
+ type: ViewChild,
533
+ args: [MatDrawerContainer]
534
+ }], content: [{
535
+ type: ViewChild,
536
+ args: ['content', { read: ElementRef, static: true }]
537
+ }], side: [{
538
+ type: Input
539
+ }], opened: [{
540
+ type: Input
541
+ }], drawerColor: [{
542
+ type: Input
543
+ }] } });
544
+
545
+ /**
546
+ * Directive that connects a host MatMenuTrigger to a DbxMapboxMapStore and listens for right-clicks on the map.
547
+ *
548
+ * The map dissapears if the mouse scrolls anywhere else on the map.
549
+ */
550
+ class DbxMapboxMenuComponent extends AbstractSubscriptionDirective {
551
+ constructor(dbxMapboxMapStore, matMenuTrigger, ngZone, cdRef) {
552
+ super();
553
+ this.dbxMapboxMapStore = dbxMapboxMapStore;
554
+ this.matMenuTrigger = matMenuTrigger;
555
+ this.ngZone = ngZone;
556
+ this.cdRef = cdRef;
557
+ this._pos = { x: `0`, y: `0` };
558
+ this._active = new BehaviorSubject(true);
559
+ this._menuCloseSub = new SubscriptionObject();
560
+ this._preventRightClick = new DestroyFunctionObject();
561
+ }
562
+ get pos() {
563
+ return this._pos;
564
+ }
565
+ ngOnInit() {
566
+ this.sub = this._active
567
+ .pipe(switchMap((active) => {
568
+ if (active) {
569
+ return this.dbxMapboxMapStore.rightClickEvent$;
570
+ }
571
+ else {
572
+ return of();
573
+ }
574
+ }), filter(Boolean))
575
+ .subscribe((event) => {
576
+ const menu = this.matMenuTrigger.menu;
577
+ const buttonEvent = event.originalEvent;
578
+ if (menu && buttonEvent) {
579
+ buttonEvent.preventDefault();
580
+ // update position of this component for menu to open at
581
+ this._pos = {
582
+ x: `${buttonEvent.x}px`,
583
+ y: `${buttonEvent.y}px`
584
+ };
585
+ safeMarkForCheck(this.cdRef);
586
+ // open menu
587
+ this.ngZone.run(() => this.matMenuTrigger.openMenu());
588
+ // prevent right clicks in the cdkOverlay while the menu is open
589
+ this._preventRightClick.destroy = disableRightClickInCdkBackdrop(undefined, () => {
590
+ this.ngZone.run(() => this.matMenuTrigger.closeMenu());
591
+ });
592
+ }
593
+ });
594
+ this._menuCloseSub.subscription = this.matMenuTrigger.menuClosed.subscribe(() => {
595
+ // destroy prevention when the menu is closed.
596
+ this._preventRightClick.destroy();
597
+ });
598
+ }
599
+ ngOnDestroy() {
600
+ super.ngOnDestroy();
601
+ this._active.complete();
602
+ this._preventRightClick.destroy();
603
+ this._menuCloseSub.destroy();
604
+ if (this.matMenuTrigger) {
605
+ this.matMenuTrigger.closeMenu();
606
+ }
607
+ }
608
+ set active(active) {
609
+ this._active.next(active ?? true);
610
+ }
611
+ }
612
+ DbxMapboxMenuComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.2", ngImport: i0, type: DbxMapboxMenuComponent, deps: [{ token: DbxMapboxMapStore }, { token: i2$2.MatMenuTrigger, host: true }, { token: i0.NgZone }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
613
+ DbxMapboxMenuComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.1.2", type: DbxMapboxMenuComponent, selector: "dbx-mapbox-menu", inputs: { active: ["dbxMapboxMenu", "active"] }, host: { properties: { "style.top": "pos.y", "style.left": "pos.x" }, styleAttribute: "visibility: hidden; position: fixed" }, usesInheritance: true, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
614
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.2", ngImport: i0, type: DbxMapboxMenuComponent, decorators: [{
615
+ type: Component,
616
+ args: [{
617
+ selector: 'dbx-mapbox-menu',
618
+ template: '',
619
+ host: {
620
+ style: 'visibility: hidden; position: fixed',
621
+ '[style.top]': 'pos.y',
622
+ '[style.left]': 'pos.x'
623
+ },
624
+ changeDetection: ChangeDetectionStrategy.OnPush
625
+ }]
626
+ }], ctorParameters: function () { return [{ type: DbxMapboxMapStore }, { type: i2$2.MatMenuTrigger, decorators: [{
627
+ type: Host
628
+ }] }, { type: i0.NgZone }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { active: [{
629
+ type: Input,
630
+ args: ['dbxMapboxMenu']
631
+ }] } });
632
+
633
+ const declarations = [
634
+ //
635
+ DbxMapboxMapDirective,
636
+ DbxMapboxLayoutComponent,
637
+ DbxMapboxLayoutDrawerComponent,
638
+ DbxMapboxMenuComponent
639
+ ];
356
640
  class DbxMapboxModule {
357
641
  static forRoot(config) {
358
642
  return {
@@ -367,14 +651,46 @@ class DbxMapboxModule {
367
651
  }
368
652
  }
369
653
  DbxMapboxModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.2", ngImport: i0, type: DbxMapboxModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
370
- DbxMapboxModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.1.2", ngImport: i0, type: DbxMapboxModule, declarations: [DbxMapboxMapDirective], imports: [CommonModule], exports: [DbxMapboxMapDirective] });
371
- DbxMapboxModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.1.2", ngImport: i0, type: DbxMapboxModule, imports: [CommonModule] });
654
+ DbxMapboxModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.1.2", ngImport: i0, type: DbxMapboxModule, declarations: [
655
+ //
656
+ DbxMapboxMapDirective,
657
+ DbxMapboxLayoutComponent,
658
+ DbxMapboxLayoutDrawerComponent,
659
+ DbxMapboxMenuComponent], imports: [
660
+ //
661
+ CommonModule,
662
+ MatSidenavModule,
663
+ DbxInjectionComponentModule,
664
+ MatButtonModule,
665
+ MatIconModule,
666
+ AngularResizeEventModule], exports: [
667
+ //
668
+ DbxMapboxMapDirective,
669
+ DbxMapboxLayoutComponent,
670
+ DbxMapboxLayoutDrawerComponent,
671
+ DbxMapboxMenuComponent] });
672
+ DbxMapboxModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.1.2", ngImport: i0, type: DbxMapboxModule, imports: [
673
+ //
674
+ CommonModule,
675
+ MatSidenavModule,
676
+ DbxInjectionComponentModule,
677
+ MatButtonModule,
678
+ MatIconModule,
679
+ AngularResizeEventModule] });
372
680
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.2", ngImport: i0, type: DbxMapboxModule, decorators: [{
373
681
  type: NgModule,
374
682
  args: [{
375
- imports: [CommonModule],
376
- declarations: [DbxMapboxMapDirective],
377
- exports: [DbxMapboxMapDirective]
683
+ imports: [
684
+ //
685
+ CommonModule,
686
+ MatSidenavModule,
687
+ DbxInjectionComponentModule,
688
+ MatButtonModule,
689
+ MatIconModule,
690
+ AngularResizeEventModule
691
+ ],
692
+ declarations,
693
+ exports: declarations
378
694
  }]
379
695
  }] });
380
696
 
@@ -394,5 +710,5 @@ const KNOWN_MAPBOX_STYLES = [
394
710
  * Generated bundle index. Do not edit.
395
711
  */
396
712
 
397
- export { DEFAULT_MAPBOX_CENTER, DEFAULT_MAPBOX_MAP_STORE_TIMER_REFRESH_PERIOD, DEFAULT_MAPBOX_STYLE, DEFAULT_MAPBOX_ZOOM, DbxMapboxConfig, DbxMapboxMapDirective, DbxMapboxMapStore, DbxMapboxModule, DbxMapboxService, KNOWN_MAPBOX_STYLES };
713
+ export { DEFAULT_MAPBOX_CENTER, DEFAULT_MAPBOX_MAP_STORE_TIMER_REFRESH_PERIOD, DEFAULT_MAPBOX_STYLE, DEFAULT_MAPBOX_ZOOM, DbxMapboxConfig, DbxMapboxLayoutComponent, DbxMapboxLayoutDrawerComponent, DbxMapboxMapDirective, DbxMapboxMapStore, DbxMapboxMenuComponent, DbxMapboxModule, DbxMapboxService, KNOWN_MAPBOX_STYLES };
398
714
  //# sourceMappingURL=dereekb-dbx-web-mapbox.mjs.map