@dereekb/dbx-web 9.3.2 → 9.5.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.
Files changed (53) 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 +98 -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.map.directive.mjs +4 -8
  17. package/esm2020/mapbox/lib/mapbox.store.mjs +46 -6
  18. package/fesm2015/dereekb-dbx-web-mapbox.mjs +337 -20
  19. package/fesm2015/dereekb-dbx-web-mapbox.mjs.map +1 -1
  20. package/fesm2015/dereekb-dbx-web.mjs +60 -21
  21. package/fesm2015/dereekb-dbx-web.mjs.map +1 -1
  22. package/fesm2020/dereekb-dbx-web-mapbox.mjs +331 -20
  23. package/fesm2020/dereekb-dbx-web-mapbox.mjs.map +1 -1
  24. package/fesm2020/dereekb-dbx-web.mjs +60 -21
  25. package/fesm2020/dereekb-dbx-web.mjs.map +1 -1
  26. package/lib/index.d.ts +1 -0
  27. package/lib/layout/bar/bar.d.ts +2 -1
  28. package/lib/layout/column/two/two.column.right.component.d.ts +2 -1
  29. package/lib/layout/style/_style.scss +11 -0
  30. package/lib/layout/style/index.d.ts +1 -0
  31. package/lib/layout/style/style.d.ts +3 -0
  32. package/lib/util/cdk.d.ts +9 -0
  33. package/lib/util/index.d.ts +1 -0
  34. package/mapbox/esm2020/lib/index.mjs +4 -1
  35. package/mapbox/esm2020/lib/mapbox.layout.component.mjs +132 -0
  36. package/mapbox/esm2020/lib/mapbox.layout.drawer.component.mjs +24 -0
  37. package/mapbox/esm2020/lib/mapbox.menu.component.mjs +98 -0
  38. package/mapbox/esm2020/lib/mapbox.mjs +1 -1
  39. package/mapbox/esm2020/lib/mapbox.module.mjs +53 -6
  40. package/mapbox/esm2020/lib/mapbox.store.map.directive.mjs +4 -8
  41. package/mapbox/esm2020/lib/mapbox.store.mjs +46 -6
  42. package/mapbox/fesm2015/dereekb-dbx-web-mapbox.mjs +337 -20
  43. package/mapbox/fesm2015/dereekb-dbx-web-mapbox.mjs.map +1 -1
  44. package/mapbox/fesm2020/dereekb-dbx-web-mapbox.mjs +331 -20
  45. package/mapbox/fesm2020/dereekb-dbx-web-mapbox.mjs.map +1 -1
  46. package/mapbox/lib/index.d.ts +3 -0
  47. package/mapbox/lib/mapbox.layout.component.d.ts +44 -0
  48. package/mapbox/lib/mapbox.layout.drawer.component.d.ts +12 -0
  49. package/mapbox/lib/mapbox.menu.component.d.ts +30 -0
  50. package/mapbox/lib/mapbox.module.d.ts +10 -2
  51. package/mapbox/lib/mapbox.store.d.ts +29 -0
  52. package/mapbox/package.json +5 -5
  53. 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 { latLngPointFunction, latLngBoundFunction, isSameLatLngPoint, isSameLatLngBound, isWithinLatLngBoundFunction, overlapsLatLngBoundFunction, latLngTuple } from '@dereekb/util';
5
+ import { latLngPointFunction, latLngBoundFunction, isSameLatLngPoint, isSameLatLngBound, isWithinLatLngBoundFunction, overlapsLatLngBoundFunction, diffLatLngBoundPoints, latLngBoundCenterPoint, addLatLngPoints, latLngPoint, DestroyFunctionObject } from '@dereekb/util';
5
6
  import * as i1 from 'ngx-mapbox-gl';
6
- import { cleanup, filterMaybe, onTrueToFalse } from '@dereekb/rxjs';
7
+ import { cleanup, filterMaybe, onTrueToFalse, SubscriptionObject } from '@dereekb/rxjs';
7
8
  import { ComponentStore } from '@ngrx/component-store';
8
- import { switchMap, NEVER, defaultIfEmpty, map, tap, distinctUntilChanged, shareReplay, of, combineLatest, filter, first, startWith, interval } from 'rxjs';
9
+ import { switchMap, NEVER, defaultIfEmpty, map, tap, distinctUntilChanged, shareReplay, of, combineLatest, filter, first, startWith, interval, Subject, BehaviorSubject, throttleTime, skip } from 'rxjs';
9
10
  import * as MapboxGl from '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
  }
@@ -57,7 +70,8 @@ class DbxMapboxMapStore extends ComponentStore {
57
70
  lifecycleState: 'init',
58
71
  moveState: 'init',
59
72
  zoomState: 'init',
60
- rotateState: 'init'
73
+ rotateState: 'init',
74
+ retainContent: true
61
75
  });
62
76
  this.dbxMapboxService = dbxMapboxService;
63
77
  this.latLngPoint = latLngPointFunction();
@@ -94,6 +108,7 @@ class DbxMapboxMapStore extends ComponentStore {
94
108
  addListener('rotateend', () => this._setRotateState('idle'));
95
109
  addListener('click', (x) => this._setClickEvent(x));
96
110
  addListener('dblclick', (x) => this._setDoubleClickEvent(x));
111
+ addListener('contextmenu', (x) => this._setRightClickEvent(x));
97
112
  const subs = [];
98
113
  return {
99
114
  service,
@@ -279,17 +294,23 @@ class DbxMapboxMapStore extends ComponentStore {
279
294
  this.bearing$ = this.whenInitialized$.pipe(switchMap(() => {
280
295
  return this.isRotating$.pipe(onTrueToFalse(), startWith(undefined), switchMap((x) => this.bearingNow$.pipe(first())), distinctUntilChanged(), shareReplay(1));
281
296
  }));
282
- this.clickEvent$ = this.state$.pipe(map((x) => x.clickEvent));
283
- this.doubleClickEvent$ = this.state$.pipe(map((x) => x.doubleClickEvent));
297
+ this.content$ = this.state$.pipe(map((x) => x.content), distinctUntilChanged(), shareReplay(1));
298
+ this.hasContent$ = this.content$.pipe(map(Boolean));
299
+ this.clickEvent$ = this.state$.pipe(map((x) => x.clickEvent), distinctUntilChanged(), shareReplay(1));
300
+ this.doubleClickEvent$ = this.state$.pipe(map((x) => x.doubleClickEvent), distinctUntilChanged(), shareReplay(1));
301
+ this.rightClickEvent$ = this.state$.pipe(map((x) => x.rightClickEvent), distinctUntilChanged(), shareReplay(1));
284
302
  // MARK: State Changes
285
- this._setMapService = this.updater((state, mapService) => ({ mapService, moveState: 'init', lifecycleState: 'init', zoomState: 'init', rotateState: 'init' }));
303
+ this._setMapService = this.updater((state, mapService) => ({ mapService, moveState: 'init', lifecycleState: 'init', zoomState: 'init', rotateState: 'init', retainContent: state.retainContent, content: state.retainContent ? state.content : undefined }));
286
304
  this._setLifecycleState = this.updater((state, lifecycleState) => (Object.assign(Object.assign({}, state), { lifecycleState })));
287
305
  this._setMoveState = this.updater((state, moveState) => (Object.assign(Object.assign({}, state), { moveState })));
288
306
  this._setZoomState = this.updater((state, zoomState) => (Object.assign(Object.assign({}, state), { zoomState })));
289
307
  this._setRotateState = this.updater((state, rotateState) => (Object.assign(Object.assign({}, state), { rotateState })));
290
308
  this._setClickEvent = this.updater((state, clickEvent) => (Object.assign(Object.assign({}, state), { clickEvent })));
291
309
  this._setDoubleClickEvent = this.updater((state, doubleClickEvent) => (Object.assign(Object.assign({}, state), { doubleClickEvent })));
310
+ this._setRightClickEvent = this.updater((state, rightClickEvent) => (Object.assign(Object.assign({}, state), { rightClickEvent })));
292
311
  this._setError = this.updater((state, error) => (Object.assign(Object.assign({}, state), { error })));
312
+ this.clearContent = this.updater((state) => (Object.assign(Object.assign({}, state), { content: undefined })));
313
+ this.setContent = this.updater((state, content) => (Object.assign(Object.assign({}, state), { content })));
293
314
  }
294
315
  // MARK: Accessors
295
316
  get timerRefreshPeriod() {
@@ -315,6 +336,38 @@ class DbxMapboxMapStore extends ComponentStore {
315
336
  }
316
337
  }), shareReplay());
317
338
  }
339
+ atNextIdle() {
340
+ return this.moveState$.pipe(map((x) => x === 'idle'), first());
341
+ }
342
+ calculateNextCenterWithOffset(inputOffset) {
343
+ const offset = this.latLngPoint(inputOffset);
344
+ return this.atNextIdle().pipe(switchMap(() => this.center$.pipe(first(), map((center) => {
345
+ const newCenter = {
346
+ lat: offset.lat + center.lat,
347
+ lng: offset.lng + center.lng
348
+ };
349
+ return newCenter;
350
+ }))));
351
+ }
352
+ calculateNextCenterOffsetWithScreenMarginChange(sizing) {
353
+ return this.atNextIdle().pipe(switchMap(() => this.bound$.pipe((first(),
354
+ map((bounds) => {
355
+ const diff = diffLatLngBoundPoints(bounds);
356
+ const center = latLngBoundCenterPoint(bounds);
357
+ const offsetWidth = sizing.leftMargin + sizing.rightMargin; // 300 + 0
358
+ const newWidth = sizing.fullWidth - offsetWidth; // 1000 - 300 - 0
359
+ const newWidthRatio = newWidth / sizing.fullWidth; // 700 / 1000
360
+ const newCenterLongitudeWidth = diff.lng * newWidthRatio; // 70% offset
361
+ const effectiveOffset = {
362
+ lat: 0,
363
+ lng: newCenterLongitudeWidth / 2
364
+ };
365
+ const newCenter = addLatLngPoints(bounds.sw, effectiveOffset);
366
+ newCenter.lat = center.lat; // retain center position
367
+ // console.log({ sizing, bounds, effectiveOffset, newWidth, offsetWidth, diff, center, newCenter });
368
+ return newCenter;
369
+ })))));
370
+ }
318
371
  }
319
372
  DbxMapboxMapStore.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.2", ngImport: i0, type: DbxMapboxMapStore, deps: [{ token: DbxMapboxService }], target: i0.ɵɵFactoryTarget.Injectable });
320
373
  DbxMapboxMapStore.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.2", ngImport: i0, type: DbxMapboxMapStore });
@@ -342,14 +395,10 @@ class DbxMapboxMapDirective {
342
395
  ngOnInit() {
343
396
  // style must be provided first before the map will load.
344
397
  this.mapboxMap.style = this.dbxMapboxService.defaultStyle;
398
+ this.mapboxMap.zoom = [this.dbxMapboxService.defaultZoom];
399
+ this.mapboxMap.center = latLngPoint(this.dbxMapboxService.defaultCenter);
345
400
  if (this.dbxMapboxMapStore) {
346
401
  this.dbxMapboxMapStore.setMapService(this.mapService);
347
- this.dbxMapboxMapStore.setCenter(this.dbxMapboxService.defaultCenter);
348
- this.dbxMapboxMapStore.setZoom(this.dbxMapboxService.defaultZoom);
349
- }
350
- else {
351
- this.mapboxMap.zoom = [this.dbxMapboxService.defaultZoom];
352
- this.mapboxMap.center = latLngTuple(this.dbxMapboxService.defaultCenter);
353
402
  }
354
403
  }
355
404
  }
@@ -370,6 +419,238 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.2", ngImpor
370
419
  }] }];
371
420
  } });
372
421
 
422
+ /**
423
+ * Content drawer that connects with DbxMapboxMapStore to
424
+ */
425
+ class DbxMapboxLayoutDrawerComponent {
426
+ constructor(dbxMapboxMapStore) {
427
+ this.dbxMapboxMapStore = dbxMapboxMapStore;
428
+ this.config$ = this.dbxMapboxMapStore.content$;
429
+ }
430
+ }
431
+ DbxMapboxLayoutDrawerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.2", ngImport: i0, type: DbxMapboxLayoutDrawerComponent, deps: [{ token: DbxMapboxMapStore }], target: i0.ɵɵFactoryTarget.Component });
432
+ 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" }] });
433
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.2", ngImport: i0, type: DbxMapboxLayoutDrawerComponent, decorators: [{
434
+ type: Component,
435
+ args: [{ selector: 'dbx-mapbox-layout-drawer', host: {
436
+ class: 'dbx-mapbox-layout-drawer'
437
+ }, template: "<div>\n <dbx-injection [config]=\"config$ | async\"></dbx-injection>\n</div>\n" }]
438
+ }], ctorParameters: function () { return [{ type: DbxMapboxMapStore }]; } });
439
+
440
+ /**
441
+ * Responsive component meant to split a left and right column.
442
+ *
443
+ * The left column is smaller than the right column, which contains the primary content.
444
+ *
445
+ * Requires a TwoColumnsContextStore to be provided.
446
+ */
447
+ class DbxMapboxLayoutComponent extends SubscriptionObject {
448
+ constructor(dbxMapboxMapStore) {
449
+ super();
450
+ this.dbxMapboxMapStore = dbxMapboxMapStore;
451
+ this._resized = new Subject();
452
+ this._updateMargins = new Subject();
453
+ this._side = new BehaviorSubject('right');
454
+ this._openToggle = new BehaviorSubject(true);
455
+ this._color = new BehaviorSubject(undefined);
456
+ this._toggleSub = new SubscriptionObject();
457
+ this.side$ = this._side.pipe(distinctUntilChanged(), shareReplay(1));
458
+ this.opened$ = combineLatest([this.dbxMapboxMapStore.hasContent$, this._openToggle]).pipe(map(([hasContent, open]) => hasContent && open), distinctUntilChanged(), shareReplay(1));
459
+ this.position$ = this.side$.pipe(map((x) => (x === 'right' ? 'end' : 'start')), distinctUntilChanged(), shareReplay(1));
460
+ this.drawerClasses$ = combineLatest([this.side$, this.dbxMapboxMapStore.hasContent$, this.opened$]).pipe(
461
+ //
462
+ map(([side, hasContent, open]) => (hasContent ? 'has-drawer-content' : 'no-drawer-content') + ` ${side}-drawer ` + (open ? 'open-drawer' : '')), distinctUntilChanged(), shareReplay(1));
463
+ this.drawerButtonClasses$ = combineLatest([this.dbxMapboxMapStore.hasContent$, this._color]).pipe(
464
+ //
465
+ map(([hasContent, color]) => dbxColorBackground(color)), distinctUntilChanged(), shareReplay(1));
466
+ this.buttonIcon$ = combineLatest([this.side$, this.opened$]).pipe(map(([side, opened]) => {
467
+ let icons = ['chevron_right', 'chevron_left'];
468
+ if (side === 'left') {
469
+ icons = icons.reverse();
470
+ }
471
+ return opened ? icons[0] : icons[1];
472
+ }));
473
+ }
474
+ ngOnInit() {
475
+ this.subscription = this.side$.pipe(switchMap(() => this._resized.pipe(throttleTime(100, undefined, { leading: true, trailing: true }), map(() => 'r'), startWith('s')))).subscribe((reason) => {
476
+ this.dbxMapboxMapStore.mapInstance$.subscribe((x) => {
477
+ x.resize();
478
+ // side changed
479
+ if (reason === 's') {
480
+ setTimeout(() => {
481
+ this._updateMargins.next();
482
+ });
483
+ }
484
+ });
485
+ });
486
+ this._toggleSub.subscription = combineLatest([this.opened$.pipe(distinctUntilChanged(), skip(1)), this._updateMargins]).subscribe(([opened]) => {
487
+ let { right } = this.container._contentMargins;
488
+ this.container.updateContentMargins();
489
+ setTimeout(() => {
490
+ const flip = opened ? 1 : -1;
491
+ if (opened) {
492
+ right = this.container._contentMargins.right;
493
+ }
494
+ right = (right || 0) * flip;
495
+ const element = this.content.nativeElement;
496
+ const width = element.clientWidth;
497
+ const easeTo = this.dbxMapboxMapStore
498
+ .calculateNextCenterOffsetWithScreenMarginChange({
499
+ leftMargin: 0,
500
+ rightMargin: right,
501
+ fullWidth: width
502
+ })
503
+ .pipe(first(), map((center) => ({ to: { center, duration: 3200, essential: false } })));
504
+ this.dbxMapboxMapStore.easeTo(easeTo);
505
+ });
506
+ });
507
+ }
508
+ ngOnDestroy() {
509
+ this._resized.complete();
510
+ this._updateMargins.complete();
511
+ this._side.complete();
512
+ this._openToggle.complete();
513
+ this._color.complete();
514
+ this._toggleSub.destroy();
515
+ }
516
+ toggleDrawer(open) {
517
+ if (open == null) {
518
+ open = !this._openToggle.value;
519
+ }
520
+ this._openToggle.next(open);
521
+ }
522
+ set side(side) {
523
+ if (side != null) {
524
+ this._side.next(side);
525
+ }
526
+ }
527
+ set opened(opened) {
528
+ if (opened != null) {
529
+ this._openToggle.next(opened);
530
+ }
531
+ }
532
+ set drawerColor(color) {
533
+ this._color.next(color);
534
+ }
535
+ onResized(event) {
536
+ this._resized.next();
537
+ }
538
+ }
539
+ DbxMapboxLayoutComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.2", ngImport: i0, type: DbxMapboxLayoutComponent, deps: [{ token: DbxMapboxMapStore }], target: i0.ɵɵFactoryTarget.Component });
540
+ 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" }] });
541
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.2", ngImport: i0, type: DbxMapboxLayoutComponent, decorators: [{
542
+ type: Component,
543
+ 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"] }]
544
+ }], ctorParameters: function () { return [{ type: DbxMapboxMapStore }]; }, propDecorators: { container: [{
545
+ type: ViewChild,
546
+ args: [MatDrawerContainer]
547
+ }], content: [{
548
+ type: ViewChild,
549
+ args: ['content', { read: ElementRef, static: true }]
550
+ }], side: [{
551
+ type: Input
552
+ }], opened: [{
553
+ type: Input
554
+ }], drawerColor: [{
555
+ type: Input
556
+ }] } });
557
+
558
+ /**
559
+ * Directive that connects a host MatMenuTrigger to a DbxMapboxMapStore and listens for right-clicks on the map.
560
+ *
561
+ * The map dissapears if the mouse scrolls anywhere else on the map.
562
+ */
563
+ class DbxMapboxMenuComponent extends AbstractSubscriptionDirective {
564
+ constructor(dbxMapboxMapStore, matMenuTrigger, cdRef) {
565
+ super();
566
+ this.dbxMapboxMapStore = dbxMapboxMapStore;
567
+ this.matMenuTrigger = matMenuTrigger;
568
+ this.cdRef = cdRef;
569
+ this._pos = { x: `0`, y: `0` };
570
+ this._active = new BehaviorSubject(true);
571
+ this._menuCloseSub = new SubscriptionObject();
572
+ this._preventRightClick = new DestroyFunctionObject();
573
+ }
574
+ get pos() {
575
+ return this._pos;
576
+ }
577
+ ngOnInit() {
578
+ this.sub = this._active
579
+ .pipe(switchMap((active) => {
580
+ if (active) {
581
+ return this.dbxMapboxMapStore.rightClickEvent$;
582
+ }
583
+ else {
584
+ return of();
585
+ }
586
+ }), filter(Boolean))
587
+ .subscribe((event) => {
588
+ const menu = this.matMenuTrigger.menu;
589
+ const buttonEvent = event.originalEvent;
590
+ if (menu && buttonEvent) {
591
+ buttonEvent.preventDefault();
592
+ // update position of this component for menu to open at
593
+ this._pos = {
594
+ x: `${buttonEvent.x}px`,
595
+ y: `${buttonEvent.y}px`
596
+ };
597
+ safeMarkForCheck(this.cdRef);
598
+ // open menu
599
+ this.matMenuTrigger.openMenu();
600
+ // prevent right clicks in the cdkOverlay while the menu is open
601
+ this._preventRightClick.destroy = disableRightClickInCdkBackdrop(undefined, () => {
602
+ this.matMenuTrigger.closeMenu();
603
+ });
604
+ }
605
+ });
606
+ this._menuCloseSub.subscription = this.matMenuTrigger.menuClosed.subscribe(() => {
607
+ // destroy prevention when the menu is closed.
608
+ this._preventRightClick.destroy();
609
+ });
610
+ }
611
+ ngOnDestroy() {
612
+ super.ngOnDestroy();
613
+ this._active.complete();
614
+ this._preventRightClick.destroy();
615
+ this._menuCloseSub.destroy();
616
+ if (this.matMenuTrigger) {
617
+ this.matMenuTrigger.closeMenu();
618
+ }
619
+ }
620
+ set active(active) {
621
+ this._active.next(active !== null && active !== void 0 ? active : true);
622
+ }
623
+ }
624
+ 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.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
625
+ 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 });
626
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.2", ngImport: i0, type: DbxMapboxMenuComponent, decorators: [{
627
+ type: Component,
628
+ args: [{
629
+ selector: 'dbx-mapbox-menu',
630
+ template: '',
631
+ host: {
632
+ style: 'visibility: hidden; position: fixed',
633
+ '[style.top]': 'pos.y',
634
+ '[style.left]': 'pos.x'
635
+ },
636
+ changeDetection: ChangeDetectionStrategy.OnPush
637
+ }]
638
+ }], ctorParameters: function () {
639
+ return [{ type: DbxMapboxMapStore }, { type: i2$2.MatMenuTrigger, decorators: [{
640
+ type: Host
641
+ }] }, { type: i0.ChangeDetectorRef }];
642
+ }, propDecorators: { active: [{
643
+ type: Input,
644
+ args: ['dbxMapboxMenu']
645
+ }] } });
646
+
647
+ const declarations = [
648
+ //
649
+ DbxMapboxMapDirective,
650
+ DbxMapboxLayoutComponent,
651
+ DbxMapboxLayoutDrawerComponent,
652
+ DbxMapboxMenuComponent
653
+ ];
373
654
  class DbxMapboxModule {
374
655
  static forRoot(config) {
375
656
  return {
@@ -384,14 +665,50 @@ class DbxMapboxModule {
384
665
  }
385
666
  }
386
667
  DbxMapboxModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.2", ngImport: i0, type: DbxMapboxModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
387
- DbxMapboxModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.1.2", ngImport: i0, type: DbxMapboxModule, declarations: [DbxMapboxMapDirective], imports: [CommonModule], exports: [DbxMapboxMapDirective] });
388
- DbxMapboxModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.1.2", ngImport: i0, type: DbxMapboxModule, imports: [CommonModule] });
668
+ DbxMapboxModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.1.2", ngImport: i0, type: DbxMapboxModule, declarations: [
669
+ //
670
+ DbxMapboxMapDirective,
671
+ DbxMapboxLayoutComponent,
672
+ DbxMapboxLayoutDrawerComponent,
673
+ DbxMapboxMenuComponent
674
+ ], imports: [
675
+ //
676
+ CommonModule,
677
+ MatSidenavModule,
678
+ DbxInjectionComponentModule,
679
+ MatButtonModule,
680
+ MatIconModule,
681
+ AngularResizeEventModule
682
+ ], exports: [
683
+ //
684
+ DbxMapboxMapDirective,
685
+ DbxMapboxLayoutComponent,
686
+ DbxMapboxLayoutDrawerComponent,
687
+ DbxMapboxMenuComponent
688
+ ] });
689
+ DbxMapboxModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.1.2", ngImport: i0, type: DbxMapboxModule, imports: [
690
+ //
691
+ CommonModule,
692
+ MatSidenavModule,
693
+ DbxInjectionComponentModule,
694
+ MatButtonModule,
695
+ MatIconModule,
696
+ AngularResizeEventModule
697
+ ] });
389
698
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.2", ngImport: i0, type: DbxMapboxModule, decorators: [{
390
699
  type: NgModule,
391
700
  args: [{
392
- imports: [CommonModule],
393
- declarations: [DbxMapboxMapDirective],
394
- exports: [DbxMapboxMapDirective]
701
+ imports: [
702
+ //
703
+ CommonModule,
704
+ MatSidenavModule,
705
+ DbxInjectionComponentModule,
706
+ MatButtonModule,
707
+ MatIconModule,
708
+ AngularResizeEventModule
709
+ ],
710
+ declarations,
711
+ exports: declarations
395
712
  }]
396
713
  }] });
397
714
 
@@ -411,5 +728,5 @@ const KNOWN_MAPBOX_STYLES = [
411
728
  * Generated bundle index. Do not edit.
412
729
  */
413
730
 
414
- 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 };
731
+ 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 };
415
732
  //# sourceMappingURL=dereekb-dbx-web-mapbox.mjs.map