@dereekb/dbx-form 13.10.6 → 13.10.7

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.
@@ -7,7 +7,7 @@ import * as i0 from '@angular/core';
7
7
  import { inject, ChangeDetectionStrategy, Component, Injector, NgModule, ElementRef, input, computed, effect } from '@angular/core';
8
8
  import { FieldType } from '@ngx-formly/material';
9
9
  import { combineLatest, map, shareReplay, BehaviorSubject, of, switchMap, startWith, distinctUntilChanged, skipWhile, filter, skip, throttleTime, first } from 'rxjs';
10
- import { SubscriptionObject, filterMaybe, asObservableFromGetter } from '@dereekb/rxjs';
10
+ import { filterMaybe, asObservableFromGetter } from '@dereekb/rxjs';
11
11
  import { WaGeolocationService } from '@ng-web-apis/geolocation';
12
12
  import * as i3$1 from '@dereekb/dbx-web/mapbox';
13
13
  import { DbxMapboxMarkerComponent, DbxMapboxInjectionStore, DbxMapboxMapStore, DbxMapboxModule, provideMapboxStoreIfParentIsUnavailable, DbxMapboxService, mapboxZoomLevel, MAPBOX_MIN_ZOOM_LEVEL, MAPBOX_MAX_ZOOM_LEVEL } from '@dereekb/dbx-web/mapbox';
@@ -23,6 +23,7 @@ import * as i6 from '@angular/material/input';
23
23
  import { MatInputModule } from '@angular/material/input';
24
24
  import * as i2$1 from 'ngx-mapbox-gl';
25
25
  import { MapComponent, MarkerComponent } from 'ngx-mapbox-gl';
26
+ import { cleanSubscription, completeOnDestroy } from '@dereekb/dbx-core';
26
27
  import * as i1 from '@ngx-formly/core';
27
28
  import { FormlyModule } from '@ngx-formly/core';
28
29
  import { DEFAULT_PROPS, DEFAULT_VALIDATION_MESSAGES, provideDynamicForm } from '@ng-forge/dynamic-forms';
@@ -110,21 +111,21 @@ class DbxFormMapboxLatLngFieldComponent extends FieldType {
110
111
  dbxMapboxInjectionStore = inject(DbxMapboxInjectionStore, { optional: true });
111
112
  dbxMapboxMapStore = inject(DbxMapboxMapStore);
112
113
  injector = inject(Injector);
113
- _sub = new SubscriptionObject();
114
- _geoSub = new SubscriptionObject();
115
- _centerSub = new SubscriptionObject();
116
- _flyToCenterSub = new SubscriptionObject();
117
- _clickSub = new SubscriptionObject();
118
- _zoom = new BehaviorSubject(12);
119
- _markerConfig = new BehaviorSubject(of(DEFAULT_DBX_FORM_MAPBOX_LAT_LNG_MARKER_CONFIG));
114
+ _sub = cleanSubscription();
115
+ _geoSub = cleanSubscription();
116
+ _centerSub = cleanSubscription();
117
+ _flyToCenterSub = cleanSubscription();
118
+ _clickSub = cleanSubscription();
119
+ _zoom = completeOnDestroy(new BehaviorSubject(12));
120
+ _markerConfig = completeOnDestroy(new BehaviorSubject(of(DEFAULT_DBX_FORM_MAPBOX_LAT_LNG_MARKER_CONFIG)));
120
121
  _latLngStringFunction;
121
122
  _latLngPointFunction;
122
123
  compactClass$ = mapCompactModeObs(this.compact?.mode$, {
123
124
  compact: 'dbx-mapbox-input-field-compact'
124
125
  }).pipe(filterMaybe());
125
- _useCurrentLocationDisabled = new BehaviorSubject(false);
126
+ _useCurrentLocationDisabled = completeOnDestroy(new BehaviorSubject(false));
126
127
  useCurrentLocationDisabled$ = this._useCurrentLocationDisabled.asObservable();
127
- _formControlObs = new BehaviorSubject(undefined);
128
+ _formControlObs = completeOnDestroy(new BehaviorSubject(undefined));
128
129
  formControl$ = this._formControlObs.pipe(filterMaybe());
129
130
  value$ = this.formControl$.pipe(switchMap((control) => control.valueChanges.pipe(startWith(control.value))), shareReplay(1));
130
131
  latLng$ = this.value$.pipe(filterMaybe(), map((x) => this._latLngPointFunction(x)), distinctUntilChanged(isSameLatLngPoint), shareReplay(1));
@@ -243,14 +244,6 @@ class DbxFormMapboxLatLngFieldComponent extends FieldType {
243
244
  }
244
245
  ngOnDestroy() {
245
246
  super.ngOnDestroy();
246
- this._zoom.complete();
247
- this._markerConfig.complete();
248
- this._formControlObs.complete();
249
- this._sub.destroy();
250
- this._geoSub.destroy();
251
- this._centerSub.destroy();
252
- this._flyToCenterSub.destroy();
253
- this._clickSub.destroy();
254
247
  }
255
248
  flyToMarker() {
256
249
  this.dbxMapboxMapStore.easeTo(this.nonZeroLatLng$.pipe(first(), map((x) => ({ center: x }))));
@@ -452,13 +445,13 @@ class DbxForgeMapboxLatLngFieldComponent {
452
445
  // Internal text form control for the coordinate input
453
446
  textCtrl = new FormControl('');
454
447
  // Subscription management
455
- _sub = new SubscriptionObject();
456
- _geoSub = new SubscriptionObject();
457
- _centerSub = new SubscriptionObject();
458
- _flyToCenterSub = new SubscriptionObject();
459
- _clickSub = new SubscriptionObject();
460
- _zoom = new BehaviorSubject(12);
461
- _markerConfig = new BehaviorSubject(of(DEFAULT_DBX_FORGE_MAPBOX_LAT_LNG_MARKER_CONFIG));
448
+ _sub = cleanSubscription();
449
+ _geoSub = cleanSubscription();
450
+ _centerSub = cleanSubscription();
451
+ _flyToCenterSub = cleanSubscription();
452
+ _clickSub = cleanSubscription();
453
+ _zoom = completeOnDestroy(new BehaviorSubject(12));
454
+ _markerConfig = completeOnDestroy(new BehaviorSubject(of(DEFAULT_DBX_FORGE_MAPBOX_LAT_LNG_MARKER_CONFIG)));
462
455
  // Reactive lat/lng conversion functions derived from props so latLng$ recomputes when props arrive.
463
456
  latLngPointConfigSignal = computed(() => {
464
457
  const p = this.props();
@@ -469,7 +462,7 @@ class DbxForgeMapboxLatLngFieldComponent {
469
462
  compactClass$ = mapCompactModeObs(this.compact?.mode$, {
470
463
  compact: 'dbx-mapbox-input-field-compact'
471
464
  }).pipe(filterMaybe());
472
- _useCurrentLocationDisabled = new BehaviorSubject(false);
465
+ _useCurrentLocationDisabled = completeOnDestroy(new BehaviorSubject(false));
473
466
  useCurrentLocationDisabled$ = this._useCurrentLocationDisabled.asObservable();
474
467
  // Field value signal (double-call pattern)
475
468
  fieldValue = computed(() => {
@@ -586,16 +579,6 @@ class DbxForgeMapboxLatLngFieldComponent {
586
579
  }
587
580
  });
588
581
  }
589
- ngOnDestroy() {
590
- this._zoom.complete();
591
- this._markerConfig.complete();
592
- this._useCurrentLocationDisabled.complete();
593
- this._sub.destroy();
594
- this._geoSub.destroy();
595
- this._centerSub.destroy();
596
- this._flyToCenterSub.destroy();
597
- this._clickSub.destroy();
598
- }
599
582
  flyToMarker() {
600
583
  this.dbxMapboxMapStore.easeTo(this.nonZeroLatLng$.pipe(first(), map((x) => ({ center: x }))));
601
584
  }
@@ -742,9 +725,9 @@ class DbxFormMapboxZoomFieldComponent extends FieldType {
742
725
  compact: 'dbx-mapbox-input-field-compact'
743
726
  }).pipe(filterMaybe());
744
727
  compactClassSignal = toSignal(this.compactClass$, { initialValue: '' });
745
- _sub = new SubscriptionObject();
746
- _center = new BehaviorSubject(undefined);
747
- _formControlObs = new BehaviorSubject(undefined);
728
+ _sub = cleanSubscription();
729
+ _center = completeOnDestroy(new BehaviorSubject(undefined));
730
+ _formControlObs = completeOnDestroy(new BehaviorSubject(undefined));
748
731
  formControl$ = this._formControlObs.pipe(filterMaybe());
749
732
  value$ = this.formControl$.pipe(switchMap((control) => control.valueChanges.pipe(startWith(control.value))), shareReplay(1));
750
733
  zoom$ = this.value$.pipe(filterMaybe(), shareReplay(1));
@@ -813,9 +796,6 @@ class DbxFormMapboxZoomFieldComponent extends FieldType {
813
796
  }
814
797
  ngOnDestroy() {
815
798
  super.ngOnDestroy();
816
- this._formControlObs.complete();
817
- this._center.complete();
818
- this._sub.destroy();
819
799
  if (!this._undoZoomLimit) {
820
800
  this.dbxMapboxMapStore.setZoomRange({});
821
801
  }
@@ -952,8 +932,8 @@ class DbxForgeMapboxZoomFieldComponent {
952
932
  }).pipe(filterMaybe());
953
933
  compactClassSignal = toSignal(this.compactClass$, { initialValue: '' });
954
934
  // Subscription management
955
- _sub = new SubscriptionObject();
956
- _center = new BehaviorSubject(undefined);
935
+ _sub = cleanSubscription();
936
+ _center = completeOnDestroy(new BehaviorSubject(undefined));
957
937
  // Field value signal (double-call pattern)
958
938
  fieldValue = computed(() => {
959
939
  const state = this.field()?.();
@@ -1033,8 +1013,6 @@ class DbxForgeMapboxZoomFieldComponent {
1033
1013
  });
1034
1014
  }
1035
1015
  ngOnDestroy() {
1036
- this._center.complete();
1037
- this._sub.destroy();
1038
1016
  if (!this._undoZoomLimit) {
1039
1017
  this.dbxMapboxMapStore.setZoomRange({});
1040
1018
  }