novo-elements 11.3.1-next.2 → 11.3.1-next.3

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,9 +1,10 @@
1
- import { AfterViewInit, ElementRef, EventEmitter, OnDestroy, OnInit } from '@angular/core';
1
+ import { AfterViewInit, DestroyRef, ElementRef, EventEmitter, OnDestroy, OnInit } from '@angular/core';
2
2
  import { ControlValueAccessor } from '@angular/forms';
3
3
  import { EditorView } from '@codemirror/view';
4
4
  import * as i0 from "@angular/core";
5
5
  export declare class NovoCodeEditor implements ControlValueAccessor, OnInit, OnDestroy, AfterViewInit {
6
6
  private elementRef;
7
+ private destroyRef;
7
8
  theme: string;
8
9
  lineNumbers: boolean;
9
10
  name: string;
@@ -15,7 +16,7 @@ export declare class NovoCodeEditor implements ControlValueAccessor, OnInit, OnD
15
16
  editorView: EditorView;
16
17
  initialValue: string;
17
18
  private disabled;
18
- constructor(elementRef: ElementRef);
19
+ constructor(elementRef: ElementRef, destroyRef: DestroyRef);
19
20
  ngOnInit(): void;
20
21
  ngOnDestroy(): void;
21
22
  ngAfterViewInit(): void;
@@ -28,6 +28,7 @@ export declare class NovoOverlayTemplateComponent implements OnDestroy {
28
28
  protected closingActionsSubscription: Subscription;
29
29
  private _parent;
30
30
  private overlayContainer;
31
+ private destroyRef;
31
32
  private overlayContext;
32
33
  constructor(overlay: Overlay, viewContainerRef: ViewContainerRef, zone: NgZone, changeDetectorRef: ChangeDetectorRef, document: any);
33
34
  ngOnDestroy(): void;
@@ -1,4 +1,4 @@
1
- import { AfterViewInit, ChangeDetectorRef, ElementRef, EventEmitter, OnChanges, OnInit, SimpleChanges } from '@angular/core';
1
+ import { AfterViewInit, ChangeDetectorRef, DestroyRef, ElementRef, EventEmitter, OnChanges, OnInit, SimpleChanges } from '@angular/core';
2
2
  import { ControlValueAccessor } from '@angular/forms';
3
3
  import { NovoOverlayTemplateComponent } from 'novo-elements/elements/common';
4
4
  import { DateFormatService, NovoLabelService } from 'novo-elements/services';
@@ -8,6 +8,7 @@ export declare class NovoDatePickerInputElement implements OnInit, OnChanges, Af
8
8
  labels: NovoLabelService;
9
9
  private _changeDetectorRef;
10
10
  dateFormatService: DateFormatService;
11
+ private destroyRef;
11
12
  value: any;
12
13
  formattedValue: string;
13
14
  showInvalidDateError: boolean;
@@ -91,7 +92,7 @@ export declare class NovoDatePickerInputElement implements OnInit, OnChanges, Af
91
92
  valueCleared: EventEmitter<any>;
92
93
  /** Element for the panel containing the autocomplete options. */
93
94
  overlay: NovoOverlayTemplateComponent;
94
- constructor(element: ElementRef, labels: NovoLabelService, _changeDetectorRef: ChangeDetectorRef, dateFormatService: DateFormatService);
95
+ constructor(element: ElementRef, labels: NovoLabelService, _changeDetectorRef: ChangeDetectorRef, dateFormatService: DateFormatService, destroyRef: DestroyRef);
95
96
  ngOnInit(): void;
96
97
  ngOnChanges(changes: SimpleChanges): void;
97
98
  ngAfterViewInit(): void;
@@ -1,10 +1,11 @@
1
1
  import { CdkScrollable, ScrollDispatcher } from '@angular/cdk/overlay';
2
- import { AfterContentInit, ChangeDetectorRef, ElementRef, NgZone } from '@angular/core';
2
+ import { AfterContentInit, ChangeDetectorRef, DestroyRef, ElementRef, NgZone } from '@angular/core';
3
3
  import * as i0 from "@angular/core";
4
4
  export declare class NovoLayoutContent extends CdkScrollable implements AfterContentInit {
5
5
  private _changeDetectorRef;
6
6
  _container: any;
7
- constructor(_changeDetectorRef: ChangeDetectorRef, _container: any, elementRef: ElementRef<HTMLElement>, scrollDispatcher: ScrollDispatcher, ngZone: NgZone);
7
+ private destroyRef;
8
+ constructor(_changeDetectorRef: ChangeDetectorRef, _container: any, elementRef: ElementRef<HTMLElement>, scrollDispatcher: ScrollDispatcher, ngZone: NgZone, destroyRef: DestroyRef);
8
9
  ngAfterContentInit(): void;
9
10
  getHostElement(): HTMLElement;
10
11
  static ɵfac: i0.ɵɵFactoryDeclaration<NovoLayoutContent, never>;
@@ -1,4 +1,4 @@
1
- import { ChangeDetectorRef, ComponentRef, ElementRef, EventEmitter, OnInit, ViewContainerRef } from '@angular/core';
1
+ import { ChangeDetectorRef, ComponentRef, DestroyRef, ElementRef, EventEmitter, OnInit, ViewContainerRef } from '@angular/core';
2
2
  import { ComponentUtils } from 'novo-elements/services';
3
3
  import { NovoOverlayTemplateComponent } from 'novo-elements/elements/common';
4
4
  import * as i0 from "@angular/core";
@@ -12,6 +12,7 @@ export declare class NovoPickerElement implements OnInit {
12
12
  element: ElementRef;
13
13
  private componentUtils;
14
14
  private ref;
15
+ private destroyRef;
15
16
  results: ViewContainerRef;
16
17
  config: any;
17
18
  placeholder: string;
@@ -47,7 +48,7 @@ export declare class NovoPickerElement implements OnInit {
47
48
  _value: any;
48
49
  onModelChange: Function;
49
50
  onModelTouched: Function;
50
- constructor(element: ElementRef, componentUtils: ComponentUtils, ref: ChangeDetectorRef);
51
+ constructor(element: ElementRef, componentUtils: ComponentUtils, ref: ChangeDetectorRef, destroyRef: DestroyRef);
51
52
  ngOnInit(): void;
52
53
  private onDebouncedKeyup;
53
54
  openPanel(): void;
@@ -1,12 +1,13 @@
1
- import { ComponentFactoryResolver, ComponentRef, EventEmitter, OnChanges, SimpleChange, ViewContainerRef } from '@angular/core';
1
+ import { ComponentFactoryResolver, ComponentRef, EventEmitter, OnChanges, OnDestroy, SimpleChange, ViewContainerRef } from '@angular/core';
2
2
  import { PopOverContent } from './PopOverContent';
3
3
  import * as i0 from "@angular/core";
4
- export declare class PopOverDirective implements OnChanges {
4
+ export declare class PopOverDirective implements OnChanges, OnDestroy {
5
5
  protected viewContainerRef: ViewContainerRef;
6
6
  protected resolver: ComponentFactoryResolver;
7
7
  protected PopoverComponent: typeof PopOverContent;
8
8
  protected popover: ComponentRef<PopOverContent>;
9
9
  protected visible: boolean;
10
+ private subscriptions;
10
11
  constructor(viewContainerRef: ViewContainerRef, resolver: ComponentFactoryResolver);
11
12
  content: string | PopOverContent;
12
13
  set novoPopover(content: string | PopOverContent);
@@ -26,6 +27,7 @@ export declare class PopOverDirective implements OnChanges {
26
27
  ngOnChanges(changes: {
27
28
  [propertyName: string]: SimpleChange;
28
29
  }): void;
30
+ ngOnDestroy(): void;
29
31
  toggle(): void;
30
32
  show(): void;
31
33
  hide(): void;
@@ -1,13 +1,14 @@
1
- import { TemplateRef, ViewContainerRef } from '@angular/core';
1
+ import { DestroyRef, TemplateRef, ViewContainerRef } from '@angular/core';
2
2
  import { Security } from 'novo-elements/services';
3
3
  import * as i0 from "@angular/core";
4
4
  export declare class Unless {
5
5
  templateRef: TemplateRef<any>;
6
6
  viewContainer: ViewContainerRef;
7
7
  security: Security;
8
+ private destroyRef;
8
9
  permissions: string;
9
10
  isDisplayed: boolean;
10
- constructor(templateRef: TemplateRef<any>, viewContainer: ViewContainerRef, security: Security);
11
+ constructor(templateRef: TemplateRef<any>, viewContainer: ViewContainerRef, security: Security, destroyRef: DestroyRef);
11
12
  set bhUnless(value: string);
12
13
  check(): void;
13
14
  static ɵfac: i0.ɵɵFactoryDeclaration<Unless, never>;
@@ -1,6 +1,7 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { forwardRef, EventEmitter, HostListener, HostBinding, ViewChild, Input, Output, Component, NgModule } from '@angular/core';
3
3
  import { NG_VALUE_ACCESSOR, FormsModule } from '@angular/forms';
4
+ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
4
5
  import { defaultKeymap } from '@codemirror/commands';
5
6
  import { javascript } from '@codemirror/lang-javascript';
6
7
  import { Annotation, EditorState } from '@codemirror/state';
@@ -21,8 +22,9 @@ const FormControlCodeWriter = Annotation.define();
21
22
  // (This is a replacement for the "novo-ace-editor". Notably, we are no longer naming it based on the underlying component. It is possible, in the future,
22
23
  // we decide there is another code editing component that better fits our use case - in which situation we should replace the implementation here, but keep its name)
23
24
  class NovoCodeEditor {
24
- constructor(elementRef) {
25
+ constructor(elementRef, destroyRef) {
25
26
  this.elementRef = elementRef;
27
+ this.destroyRef = destroyRef;
26
28
  this.theme = 'default';
27
29
  this.lineNumbers = true;
28
30
  this.blur = new EventEmitter();
@@ -35,6 +37,10 @@ class NovoCodeEditor {
35
37
  ngOnInit() {
36
38
  }
37
39
  ngOnDestroy() {
40
+ if (this.editorView) {
41
+ this.editorView.destroy();
42
+ this.editorView = null;
43
+ }
38
44
  }
39
45
  ngAfterViewInit() {
40
46
  this.createEditorView();
@@ -88,21 +94,21 @@ class NovoCodeEditor {
88
94
  }
89
95
  }
90
96
  registerOnChange(fn) {
91
- this.changed.subscribe(fn);
97
+ this.changed.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(fn);
92
98
  }
93
99
  registerOnTouched(fn) {
94
- this.blur.subscribe(fn);
100
+ this.blur.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(fn);
95
101
  }
96
102
  setDisabledState(isDisabled) {
97
103
  this.disabled = isDisabled;
98
104
  }
99
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: NovoCodeEditor, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component }); }
105
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: NovoCodeEditor, deps: [{ token: i0.ElementRef }, { token: i0.DestroyRef }], target: i0.ɵɵFactoryTarget.Component }); }
100
106
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.15", type: NovoCodeEditor, isStandalone: false, selector: "novo-code-editor", inputs: { theme: "theme", lineNumbers: "lineNumbers", name: "name", mode: "mode" }, outputs: { blur: "blur", focus: "focus" }, host: { listeners: { "focus": "onFocus()", "blur": "onBlur()" }, properties: { "class.editor-disabled": "this.disabled" } }, providers: [CODE_EDITOR_VALUE_ACCESSOR], viewQueries: [{ propertyName: "editorRoot", first: true, predicate: ["editorRoot"], descendants: true }], ngImport: i0, template: '', isInline: true, styles: [":host{height:200px;display:block;overflow:auto}\n"] }); }
101
107
  }
102
108
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: NovoCodeEditor, decorators: [{
103
109
  type: Component,
104
110
  args: [{ selector: 'novo-code-editor', template: '', providers: [CODE_EDITOR_VALUE_ACCESSOR], standalone: false, styles: [":host{height:200px;display:block;overflow:auto}\n"] }]
105
- }], ctorParameters: () => [{ type: i0.ElementRef }], propDecorators: { theme: [{
111
+ }], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.DestroyRef }], propDecorators: { theme: [{
106
112
  type: Input
107
113
  }], lineNumbers: [{
108
114
  type: Input
@@ -1 +1 @@
1
- {"version":3,"file":"novo-elements-addons-code-editor.mjs","sources":["../../../projects/novo-elements/src/addons/code-editor/CodeEditor.ts","../../../projects/novo-elements/src/addons/code-editor/CodeEditor.module.ts","../../../projects/novo-elements/src/addons/code-editor/novo-elements-addons-code-editor.ts"],"sourcesContent":["// NG2\nimport { AfterViewInit, Component, ElementRef, EventEmitter, HostBinding, HostListener, Input, OnDestroy, OnInit, Output, ViewChild, forwardRef } from '@angular/core';\nimport { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';\n// Vendor\nimport { defaultKeymap } from '@codemirror/commands';\nimport { javascript } from '@codemirror/lang-javascript';\nimport { Annotation, EditorState } from '@codemirror/state';\nimport { EditorView, keymap } from '@codemirror/view';\nimport { basicSetup } from 'codemirror';\n\n// organize-imports-ignore\n\n// APP\nconst CODE_EDITOR_VALUE_ACCESSOR = {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => NovoCodeEditor),\n multi: true,\n};\n\n// CodeMirror transaction annotation to show changes that came in through writeValue (FormControl value) as opposed to UI editing\nconst FormControlCodeWriter = Annotation.define();\n\n// (This is a replacement for the \"novo-ace-editor\". Notably, we are no longer naming it based on the underlying component. It is possible, in the future,\n// we decide there is another code editing component that better fits our use case - in which situation we should replace the implementation here, but keep its name)\n@Component({\n selector: 'novo-code-editor',\n template: '',\n styleUrls: ['./CodeEditor.scss'],\n providers: [CODE_EDITOR_VALUE_ACCESSOR],\n standalone: false,\n})\nexport class NovoCodeEditor implements ControlValueAccessor, OnInit, OnDestroy, AfterViewInit {\n @Input()\n theme: string = 'default';\n\n @Input()\n lineNumbers = true;\n\n @Input()\n name: string;\n\n @Output()\n blur = new EventEmitter();\n @Output()\n focus = new EventEmitter();\n\n private changed = new EventEmitter<string>();\n\n @Input() mode: string = 'javascript';\n\n @ViewChild('editorRoot')\n editorRoot: ElementRef<HTMLElement>;\n\n editorView: EditorView;\n initialValue = '';\n\n @HostBinding('class.editor-disabled')\n private disabled = false;\n\n constructor(private elementRef: ElementRef) {}\n\n ngOnInit(): void {\n }\n\n ngOnDestroy(): void {\n\n }\n\n ngAfterViewInit(): void {\n this.createEditorView();\n }\n\n createEditorView(): void {\n const extensions = [\n basicSetup,\n keymap.of(defaultKeymap),\n ];\n if (this.mode === 'javascript') {\n extensions.push(javascript());\n }\n const initialEditorState = EditorState.create({\n doc: this.initialValue,\n extensions,\n });\n this.editorView = new EditorView({\n state: initialEditorState,\n parent: this.elementRef.nativeElement,\n dispatch: (transaction, view) => {\n // Prevent changes if the form is disabled - unless the change came from writeValue function\n if (transaction.annotation(FormControlCodeWriter) || !(this.disabled && transaction.docChanged)) {\n view.update([transaction]);\n }\n if (transaction.docChanged) {\n this.changed.emit(view.state.doc.toString());\n }\n },\n });\n }\n\n @HostListener('focus')\n onFocus() {\n this.focus.emit();\n }\n\n @HostListener('blur')\n onBlur() {\n this.blur.emit();\n }\n\n // ControlValueAccessor forward implementation\n writeValue(value: any) {\n if (this.editorView) {\n this.editorView.dispatch({\n changes: {\n from: 0,\n to: this.editorView.state.doc.length,\n insert: value,\n },\n annotations: FormControlCodeWriter.of({}),\n });\n } else if (value != null) {\n this.initialValue = value;\n }\n }\n\n registerOnChange(fn: any) {\n this.changed.subscribe(fn);\n }\n\n registerOnTouched(fn: any) {\n this.blur.subscribe(fn);\n }\n\n setDisabledState(isDisabled: boolean): void {\n this.disabled = isDisabled;\n }\n}\n","import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { FormsModule } from '@angular/forms';\nimport { NovoCodeEditor } from './CodeEditor';\n\n@NgModule({\n imports: [CommonModule, FormsModule ],\n declarations: [NovoCodeEditor],\n exports: [NovoCodeEditor],\n})\nexport class NovoCodeEditorModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;AAAA;AAUA;AAEA;AACA,MAAM,0BAA0B,GAAG;AACjC,IAAA,OAAO,EAAE,iBAAiB;AAC1B,IAAA,WAAW,EAAE,UAAU,CAAC,MAAM,cAAc,CAAC;AAC7C,IAAA,KAAK,EAAE,IAAI;CACZ;AAED;AACA,MAAM,qBAAqB,GAAG,UAAU,CAAC,MAAM,EAAE;AAEjD;AACA;MAQa,cAAc,CAAA;AA4BzB,IAAA,WAAA,CAAoB,UAAsB,EAAA;QAAtB,IAAU,CAAA,UAAA,GAAV,UAAU;QA1B9B,IAAK,CAAA,KAAA,GAAW,SAAS;QAGzB,IAAW,CAAA,WAAA,GAAG,IAAI;AAMlB,QAAA,IAAA,CAAA,IAAI,GAAG,IAAI,YAAY,EAAE;AAEzB,QAAA,IAAA,CAAA,KAAK,GAAG,IAAI,YAAY,EAAE;AAElB,QAAA,IAAA,CAAA,OAAO,GAAG,IAAI,YAAY,EAAU;QAEnC,IAAI,CAAA,IAAA,GAAW,YAAY;QAMpC,IAAY,CAAA,YAAA,GAAG,EAAE;QAGT,IAAQ,CAAA,QAAA,GAAG,KAAK;;IAIxB,QAAQ,GAAA;;IAGR,WAAW,GAAA;;IAIX,eAAe,GAAA;QACb,IAAI,CAAC,gBAAgB,EAAE;;IAGzB,gBAAgB,GAAA;AACd,QAAA,MAAM,UAAU,GAAG;YACjB,UAAU;AACV,YAAA,MAAM,CAAC,EAAE,CAAC,aAAa,CAAC;SACzB;AACD,QAAA,IAAI,IAAI,CAAC,IAAI,KAAK,YAAY,EAA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Y,EAAE,CAAC,cAAc,CAAC;oBAC9B,OAAO,EAAE,CAAC,cAAc,CAAC;AAC5B,iBAAA;;;ACTD;;AAEG;;;;"}
1
+ {"version":3,"file":"novo-elements-addons-code-editor.mjs","sources":["../../../projects/novo-elements/src/addons/code-editor/CodeEditor.ts","../../../projects/novo-elements/src/addons/code-editor/CodeEditor.module.ts","../../../projects/novo-elements/src/addons/code-editor/novo-elements-addons-code-editor.ts"],"sourcesContent":["// NG2\nimport { AfterViewInit, Component, DestroyRef, ElementRef, EventEmitter, HostBinding, HostListener, Input, OnDestroy, OnInit, Output, ViewChild, forwardRef } from '@angular/core';\nimport { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\n// Vendor\nimport { defaultKeymap } from '@codemirror/commands';\nimport { javascript } from '@codemirror/lang-javascript';\nimport { Annotation, EditorState } from '@codemirror/state';\nimport { EditorView, keymap } from '@codemirror/view';\nimport { basicSetup } from 'codemirror';\n\n// organize-imports-ignore\n\n// APP\nconst CODE_EDITOR_VALUE_ACCESSOR = {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => NovoCodeEditor),\n multi: true,\n};\n\n// CodeMirror transaction annotation to show changes that came in through writeValue (FormControl value) as opposed to UI editing\nconst FormControlCodeWriter = Annotation.define();\n\n// (This is a replacement for the \"novo-ace-editor\". Notably, we are no longer naming it based on the underlying component. It is possible, in the future,\n// we decide there is another code editing component that better fits our use case - in which situation we should replace the implementation here, but keep its name)\n@Component({\n selector: 'novo-code-editor',\n template: '',\n styleUrls: ['./CodeEditor.scss'],\n providers: [CODE_EDITOR_VALUE_ACCESSOR],\n standalone: false,\n})\nexport class NovoCodeEditor implements ControlValueAccessor, OnInit, OnDestroy, AfterViewInit {\n @Input()\n theme: string = 'default';\n\n @Input()\n lineNumbers = true;\n\n @Input()\n name: string;\n\n @Output()\n blur = new EventEmitter();\n @Output()\n focus = new EventEmitter();\n\n private changed = new EventEmitter<string>();\n\n @Input() mode: string = 'javascript';\n\n @ViewChild('editorRoot')\n editorRoot: ElementRef<HTMLElement>;\n\n editorView: EditorView;\n initialValue = '';\n\n @HostBinding('class.editor-disabled')\n private disabled = false;\n\n constructor(private elementRef: ElementRef, private destroyRef: DestroyRef) {}\n\n ngOnInit(): void {\n }\n\n ngOnDestroy(): void {\n if (this.editorView) {\n this.editorView.destroy();\n this.editorView = null;\n }\n }\n\n ngAfterViewInit(): void {\n this.createEditorView();\n }\n\n createEditorView(): void {\n const extensions = [\n basicSetup,\n keymap.of(defaultKeymap),\n ];\n if (this.mode === 'javascript') {\n extensions.push(javascript());\n }\n const initialEditorState = EditorState.create({\n doc: this.initialValue,\n extensions,\n });\n this.editorView = new EditorView({\n state: initialEditorState,\n parent: this.elementRef.nativeElement,\n dispatch: (transaction, view) => {\n // Prevent changes if the form is disabled - unless the change came from writeValue function\n if (transaction.annotation(FormControlCodeWriter) || !(this.disabled && transaction.docChanged)) {\n view.update([transaction]);\n }\n if (transaction.docChanged) {\n this.changed.emit(view.state.doc.toString());\n }\n },\n });\n }\n\n @HostListener('focus')\n onFocus() {\n this.focus.emit();\n }\n\n @HostListener('blur')\n onBlur() {\n this.blur.emit();\n }\n\n // ControlValueAccessor forward implementation\n writeValue(value: any) {\n if (this.editorView) {\n this.editorView.dispatch({\n changes: {\n from: 0,\n to: this.editorView.state.doc.length,\n insert: value,\n },\n annotations: FormControlCodeWriter.of({}),\n });\n } else if (value != null) {\n this.initialValue = value;\n }\n }\n\n registerOnChange(fn: any) {\n this.changed.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(fn);\n }\n\n registerOnTouched(fn: any) {\n this.blur.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(fn);\n }\n\n setDisabledState(isDisabled: boolean): void {\n this.disabled = isDisabled;\n }\n}\n","import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { FormsModule } from '@angular/forms';\nimport { NovoCodeEditor } from './CodeEditor';\n\n@NgModule({\n imports: [CommonModule, FormsModule ],\n declarations: [NovoCodeEditor],\n exports: [NovoCodeEditor],\n})\nexport class NovoCodeEditorModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;AAAA;AAWA;AAEA;AACA,MAAM,0BAA0B,GAAG;AACjC,IAAA,OAAO,EAAE,iBAAiB;AAC1B,IAAA,WAAW,EAAE,UAAU,CAAC,MAAM,cAAc,CAAC;AAC7C,IAAA,KAAK,EAAE,IAAI;CACZ;AAED;AACA,MAAM,qBAAqB,GAAG,UAAU,CAAC,MAAM,EAAE;AAEjD;AACA;MAQa,cAAc,CAAA;IA4BzB,WAAoB,CAAA,UAAsB,EAAU,UAAsB,EAAA;QAAtD,IAAU,CAAA,UAAA,GAAV,UAAU;QAAsB,IAAU,CAAA,UAAA,GAAV,UAAU;QA1B9D,IAAK,CAAA,KAAA,GAAW,SAAS;QAGzB,IAAW,CAAA,WAAA,GAAG,IAAI;AAMlB,QAAA,IAAA,CAAA,IAAI,GAAG,IAAI,YAAY,EAAE;AAEzB,QAAA,IAAA,CAAA,KAAK,GAAG,IAAI,YAAY,EAAE;AAElB,QAAA,IAAA,CAAA,OAAO,GAAG,IAAI,YAAY,EAAU;QAEnC,IAAI,CAAA,IAAA,GAAW,YAAY;QAMpC,IAAY,CAAA,YAAA,GAAG,EAAE;QAGT,IAAQ,CAAA,QAAA,GAAG,KAAK;;IAIxB,QAAQ,GAAA;;IAGR,WAAW,GAAA;AACT,QAAA,IAAI,IAAI,CAAC,UAAU,EAAE;AACnB,YAAA,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE;AACzB,YAAA,IAAI,CAAC,UAAU,GAAG,IAAI;;;IAI1B,eAAe,GAAA;QACb,IAAI,CAAC,gBAAgB,EAAE;;IAGzB,gBAAgB,GAAA;AACd,QAAA,MAAM,UAAU,GAAG;YACjB,UAAU;AACV,YAAA,MAAM,CAAC,EAAE,CAAC,aAAa,CAAC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f,oBAAoB,EAAA,OAAA,EAAA,CAJnB,YAAY,EAAE,WAAW,CAAA,EAAA,CAAA,CAAA;;4FAI1B,oBAAoB,EAAA,UAAA,EAAA,CAAA;kBALhC,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACN,oBAAA,OAAO,EAAE,CAAC,YAAY,EAAE,WAAW,CAAE;oBACrC,YAAY,EAAE,CAAC,cAAc,CAAC;oBAC9B,OAAO,EAAE,CAAC,cAAc,CAAC;AAC5B,iBAAA;;;ACTD;;AAEG;;;;"}
@@ -1,7 +1,7 @@
1
1
  import * as i1 from '@angular/common';
2
2
  import { CommonModule, DOCUMENT } from '@angular/common';
3
3
  import * as i0 from '@angular/core';
4
- import { EventEmitter, Injectable, HostBinding, Input, Directive, Host, Optional, Inject, ChangeDetectionStrategy, ViewEncapsulation, Component, NgModule, InjectionToken, Output, input, inject, TemplateRef, ViewChild } from '@angular/core';
4
+ import { EventEmitter, Injectable, HostBinding, Input, Directive, Host, Optional, Inject, ChangeDetectionStrategy, ViewEncapsulation, Component, NgModule, InjectionToken, Output, input, inject, DestroyRef, TemplateRef, ViewChild } from '@angular/core';
5
5
  import { of, Subject, fromEvent, merge } from 'rxjs';
6
6
  import * as tokens from 'novo-design-tokens';
7
7
  import { BooleanInput, Helpers } from 'novo-elements/utils';
@@ -11,6 +11,7 @@ import { hasModifierKey } from '@angular/cdk/keycodes';
11
11
  import * as i1$1 from '@angular/cdk/overlay';
12
12
  import { OverlayContainer, OverlayConfig, OverlayModule } from '@angular/cdk/overlay';
13
13
  import { TemplatePortal } from '@angular/cdk/portal';
14
+ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
14
15
  import { filter, first, switchMap } from 'rxjs/operators';
15
16
  import { ScrollingModule } from '@angular/cdk/scrolling';
16
17
  import { FormsModule } from '@angular/forms';
@@ -1780,6 +1781,7 @@ class NovoOverlayTemplateComponent {
1780
1781
  this.closing = new EventEmitter();
1781
1782
  this.backDropClicked = new EventEmitter();
1782
1783
  this.overlayContainer = inject(OverlayContainer);
1784
+ this.destroyRef = inject(DestroyRef);
1783
1785
  }
1784
1786
  ngOnDestroy() {
1785
1787
  this.destroyOverlay();
@@ -1889,7 +1891,7 @@ class NovoOverlayTemplateComponent {
1889
1891
  createOverlay(template) {
1890
1892
  this.portal = new TemplatePortal(template, this.viewContainerRef);
1891
1893
  this.overlayRef = this.overlay.create(this.getOverlayConfig());
1892
- this.overlayRef.backdropClick().subscribe(() => {
1894
+ this.overlayRef.backdropClick().pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {
1893
1895
  this.backDropClicked.emit(true);
1894
1896
  this.closePanel();
1895
1897
  });