@paperless/angular 3.5.1 → 3.6.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.
@@ -1,18 +1,17 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Component, EventEmitter, ViewChild, Output, Input, ChangeDetectionStrategy, HostListener, Directive, Self, Injector, Injectable, NgModule, HostBinding, TemplateRef, ContentChild, Host, ElementRef, ContentChildren, ViewChildren, inject, Pipe, provideAppInitializer } from '@angular/core';
2
+ import { Component, EventEmitter, ViewChild, Output, Input, ChangeDetectionStrategy, HostListener, Directive, Self, signal, effect, inject, Injector, TemplateRef, Injectable, NgModule, HostBinding, ContentChild, Host, ElementRef, ContentChildren, ViewChildren, Pipe, provideAppInitializer } from '@angular/core';
3
3
  import * as i1 from '@angular/forms';
4
4
  import { FormControl, FormGroup, FormArray, NG_VALUE_ACCESSOR, NumberValueAccessor } from '@angular/forms';
5
5
  import { BehaviorSubject, filter, Subject, timer, fromEvent, distinctUntilChanged, debounceTime, take, map as map$1 } from 'rxjs';
6
6
  import { ObserversModule } from '@angular/cdk/observers';
7
- import * as i1$1 from '@angular/cdk/overlay';
8
- import { OverlayConfig, OverlayModule as OverlayModule$1 } from '@angular/cdk/overlay';
7
+ import { Overlay, OverlayConfig, createOverlayRef, OverlayModule as OverlayModule$1 } from '@angular/cdk/overlay';
9
8
  import { PlatformModule } from '@angular/cdk/platform';
10
- import { CdkPortal, ComponentPortal, PortalModule } from '@angular/cdk/portal';
9
+ import { CdkPortal, TemplatePortal, ComponentPortal, PortalModule } from '@angular/cdk/portal';
11
10
  import { __decorate } from 'tslib';
12
11
  import { untilDestroyed, UntilDestroy } from '@ngneat/until-destroy';
13
12
  import { startWith, tap, pairwise, map, filter as filter$1, debounce } from 'rxjs/operators';
14
13
  import { PAGINATION_DEFAULT_PAGE_SIZE, cn, getTableCellColumnClasses, objectGetByPath, state, isMobile, floatingMenuContainerClass, onStateChange, TABLE_COLUMN_SIZES, SELECT_DEFAULT_MAX_DISPLAYED_ITEMS } from '@paperless/core';
15
- import * as i1$2 from '@angular/common';
14
+ import * as i1$1 from '@angular/common';
16
15
  import { NgTemplateOutlet, AsyncPipe, CommonModule, DatePipe, CurrencyPipe } from '@angular/common';
17
16
  import { defineCustomElement as defineCustomElement$1 } from '@paperless/core/components/p-accordion.js';
18
17
  import { defineCustomElement as defineCustomElement$2 } from '@paperless/core/components/p-attachment.js';
@@ -90,7 +89,7 @@ import { defineCustomElement as defineCustomElement$19 } from '@paperless/core/c
90
89
  import { RouterLink, RouterModule } from '@angular/router';
91
90
  import { v4 } from 'uuid';
92
91
  import { defineCustomElements } from '@paperless/core/loader';
93
- import * as i1$3 from '@angular/platform-browser';
92
+ import * as i1$2 from '@angular/platform-browser';
94
93
 
95
94
  class BaseFormComponent {
96
95
  markedDirty = false;
@@ -690,41 +689,60 @@ const DIRECTIVES$1 = [
690
689
  class OverlayRef {
691
690
  _overlay;
692
691
  instance;
692
+ componentRef;
693
+ injector;
694
+ effectRef;
695
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
696
+ data = signal({}, ...(ngDevMode ? [{ debugName: "data" }] : []));
693
697
  closed$ = new Subject();
694
698
  constructor(_overlay) {
695
699
  this._overlay = _overlay;
696
700
  }
701
+ createEffect() {
702
+ if (!this.injector || !this.componentRef) {
703
+ return;
704
+ }
705
+ this.effectRef = effect(() => {
706
+ const data = this.data();
707
+ for (const key of Object.keys(data)) {
708
+ const value = typeof data[key] === 'function' ? data[key]() : data[key];
709
+ this.componentRef.setInput(key, value);
710
+ }
711
+ }, { ...(ngDevMode ? { debugName: "effectRef" } : {}), injector: this.injector });
712
+ }
697
713
  close() {
698
714
  this._overlay.dispose();
699
715
  this.closed$.next(null);
716
+ if (this.effectRef) {
717
+ this.effectRef.destroy();
718
+ }
700
719
  }
701
720
  }
702
721
 
703
722
  /* eslint-disable @typescript-eslint/no-explicit-any */
704
723
  class OverlayService {
705
- injector;
706
- overlay;
724
+ overlay = inject(Overlay);
725
+ injector = inject(Injector);
707
726
  overlayRef;
708
- constructor(injector, overlay) {
709
- this.injector = injector;
710
- this.overlay = overlay;
711
- }
712
727
  open(component, options = {}) {
713
728
  const overlay = this._createOverlay();
714
729
  const overlayRef = new OverlayRef(overlay);
715
- this._attachModalContainer(overlay, overlayRef, component, options.providers ?? []);
730
+ this._attachModalContainer(overlay, overlayRef, component, options.providers ?? [], options.data ?? {});
716
731
  this._attachData(overlayRef, options);
717
732
  this.overlayRef = overlayRef;
718
733
  return overlayRef;
719
734
  }
720
- _attachModalContainer(overlay, overlayRef, component, providers) {
735
+ _attachModalContainer(overlay, overlayRef, component, providers, data) {
721
736
  const injector = this._createInjector(overlayRef, providers);
722
737
  const containerPortal = component instanceof CdkPortal
723
738
  ? component
724
- : new ComponentPortal(component, null, injector);
739
+ : component instanceof TemplateRef
740
+ ? new TemplatePortal(component, null, { $implicit: data }, injector)
741
+ : new ComponentPortal(component, null, injector);
725
742
  const containerRef = overlay.attach(containerPortal);
743
+ overlayRef.componentRef = containerRef;
726
744
  overlayRef.instance = containerRef.instance;
727
- return containerRef.instance;
745
+ overlayRef.injector = injector;
728
746
  }
729
747
  _createInjector(overlayRef, providers) {
730
748
  return Injector.create({
@@ -754,29 +772,26 @@ class OverlayService {
754
772
  }
755
773
  _createOverlay() {
756
774
  // Returns an OverlayConfig
757
- const overlayConfig = this._getOverlayConfig();
775
+ const config = this._getOverlayConfig();
758
776
  // Returns an OverlayRef
759
- return this.overlay.create(overlayConfig);
777
+ return createOverlayRef(this.injector, config);
760
778
  }
761
779
  _attachData(overlayRef, options) {
762
780
  if (!options.data || typeof options.data !== 'object') {
763
781
  return;
764
782
  }
765
- const instance = overlayRef.instance;
766
- for (const key of Object.keys(options.data)) {
767
- if (typeof instance[key] === 'function') {
768
- instance[key].set(options.data[key]);
769
- continue;
770
- }
771
- instance[key] = options.data[key];
783
+ if (overlayRef.instance instanceof TemplateRef) {
784
+ return;
772
785
  }
786
+ overlayRef.createEffect();
787
+ overlayRef.data.set(options.data);
773
788
  }
774
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: OverlayService, deps: [{ token: i0.Injector }, { token: i1$1.Overlay }], target: i0.ɵɵFactoryTarget.Injectable });
789
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: OverlayService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
775
790
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: OverlayService });
776
791
  }
777
792
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: OverlayService, decorators: [{
778
793
  type: Injectable
779
- }], ctorParameters: () => [{ type: i0.Injector }, { type: i1$1.Overlay }] });
794
+ }] });
780
795
 
781
796
  class OverlayModule {
782
797
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: OverlayModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
@@ -5049,7 +5064,7 @@ class CustomCurrencyPipe {
5049
5064
  transform(value, currencyCode = 'EUR', display = 'symbol', digitsInfo = '1.2-2', locale = 'nl') {
5050
5065
  return this._currencyPipe.transform(value, currencyCode, display, digitsInfo, locale);
5051
5066
  }
5052
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: CustomCurrencyPipe, deps: [{ token: i1$2.CurrencyPipe }], target: i0.ɵɵFactoryTarget.Pipe });
5067
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: CustomCurrencyPipe, deps: [{ token: i1$1.CurrencyPipe }], target: i0.ɵɵFactoryTarget.Pipe });
5053
5068
  static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.0", ngImport: i0, type: CustomCurrencyPipe, isStandalone: true, name: "pcurrency" });
5054
5069
  }
5055
5070
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: CustomCurrencyPipe, decorators: [{
@@ -5057,7 +5072,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImpor
5057
5072
  args: [{
5058
5073
  name: 'pcurrency',
5059
5074
  }]
5060
- }], ctorParameters: () => [{ type: i1$2.CurrencyPipe }] });
5075
+ }], ctorParameters: () => [{ type: i1$1.CurrencyPipe }] });
5061
5076
 
5062
5077
  class CustomDatePipe {
5063
5078
  _datePipe;
@@ -5067,7 +5082,7 @@ class CustomDatePipe {
5067
5082
  transform(value, format = 'd MMM yyyy') {
5068
5083
  return this._datePipe.transform(value, format);
5069
5084
  }
5070
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: CustomDatePipe, deps: [{ token: i1$2.DatePipe }], target: i0.ɵɵFactoryTarget.Pipe });
5085
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: CustomDatePipe, deps: [{ token: i1$1.DatePipe }], target: i0.ɵɵFactoryTarget.Pipe });
5071
5086
  static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.0", ngImport: i0, type: CustomDatePipe, isStandalone: true, name: "pdate" });
5072
5087
  }
5073
5088
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: CustomDatePipe, decorators: [{
@@ -5075,7 +5090,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImpor
5075
5090
  args: [{
5076
5091
  name: 'pdate',
5077
5092
  }]
5078
- }], ctorParameters: () => [{ type: i1$2.DatePipe }] });
5093
+ }], ctorParameters: () => [{ type: i1$1.DatePipe }] });
5079
5094
 
5080
5095
  class SafePipe {
5081
5096
  sanitizer;
@@ -5104,7 +5119,7 @@ class SafePipe {
5104
5119
  }
5105
5120
  }
5106
5121
  }
5107
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: SafePipe, deps: [{ token: i1$3.DomSanitizer }], target: i0.ɵɵFactoryTarget.Pipe });
5122
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: SafePipe, deps: [{ token: i1$2.DomSanitizer }], target: i0.ɵɵFactoryTarget.Pipe });
5108
5123
  static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.0", ngImport: i0, type: SafePipe, isStandalone: true, name: "psafe" });
5109
5124
  }
5110
5125
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: SafePipe, decorators: [{
@@ -5112,7 +5127,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImpor
5112
5127
  args: [{
5113
5128
  name: 'psafe',
5114
5129
  }]
5115
- }], ctorParameters: () => [{ type: i1$3.DomSanitizer }] });
5130
+ }], ctorParameters: () => [{ type: i1$2.DomSanitizer }] });
5116
5131
 
5117
5132
  class SelectAutocompletePipe {
5118
5133
  transform(value) {