nmce-directives 0.0.7 → 0.0.8

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 (31) hide show
  1. package/_directives/autofocus.d.ts +3 -0
  2. package/_directives/currencyFormatter.directive.d.ts +3 -0
  3. package/_directives/dataComponent.directive.d.ts +3 -0
  4. package/_directives/directives.module.d.ts +10 -0
  5. package/_directives/scrollInto.directive.d.ts +3 -0
  6. package/esm2020/_directives/autofocus.mjs +46 -0
  7. package/esm2020/_directives/currencyFormatter.directive.mjs +35 -0
  8. package/esm2020/_directives/dataComponent.directive.mjs +16 -0
  9. package/esm2020/_directives/directives.module.mjs +46 -0
  10. package/{esm2015/_directives/index.js → esm2020/_directives/index.mjs} +0 -0
  11. package/esm2020/_directives/scrollInto.directive.mjs +28 -0
  12. package/{esm2015/nmce-directives.js → esm2020/nmce-directives.mjs} +0 -0
  13. package/{esm2015/public-api.js → esm2020/public-api.mjs} +0 -0
  14. package/fesm2015/nmce-directives.mjs +173 -0
  15. package/fesm2015/nmce-directives.mjs.map +1 -0
  16. package/fesm2020/nmce-directives.mjs +173 -0
  17. package/fesm2020/nmce-directives.mjs.map +1 -0
  18. package/nmce-directives.d.ts +1 -0
  19. package/package.json +22 -10
  20. package/bundles/nmce-directives.umd.js +0 -179
  21. package/bundles/nmce-directives.umd.js.map +0 -1
  22. package/bundles/nmce-directives.umd.min.js +0 -2
  23. package/bundles/nmce-directives.umd.min.js.map +0 -1
  24. package/esm2015/_directives/autofocus.js +0 -46
  25. package/esm2015/_directives/currencyFormatter.directive.js +0 -33
  26. package/esm2015/_directives/dataComponent.directive.js +0 -15
  27. package/esm2015/_directives/directives.module.js +0 -31
  28. package/esm2015/_directives/scrollInto.directive.js +0 -28
  29. package/fesm2015/nmce-directives.js +0 -159
  30. package/fesm2015/nmce-directives.js.map +0 -1
  31. package/nmce-directives.metadata.json +0 -1
@@ -1,4 +1,5 @@
1
1
  import { AfterViewInit, DoCheck, ElementRef } from '@angular/core';
2
+ import * as i0 from "@angular/core";
2
3
  /**
3
4
  * Use as a parametered input parameter in html element.
4
5
  * When used inside a material dialog, this directive may be at odd against the autofocus config parameter of MatDialogConfig,
@@ -14,4 +15,6 @@ export declare class AutofocusDirective implements AfterViewInit, DoCheck {
14
15
  ngAfterViewInit(): void;
15
16
  ngDoCheck(): void;
16
17
  set autofocus(condition: boolean);
18
+ static ɵfac: i0.ɵɵFactoryDeclaration<AutofocusDirective, never>;
19
+ static ɵdir: i0.ɵɵDirectiveDeclaration<AutofocusDirective, "[autofocus]", never, { "autofocus": "autofocus"; }, {}, never>;
17
20
  }
@@ -1,4 +1,5 @@
1
1
  import { ElementRef, OnInit } from '@angular/core';
2
+ import * as i0 from "@angular/core";
2
3
  /**
3
4
  * Decorate HTML input for inputing and displaying currency. The input type must not be number and should be text only.
4
5
  * If the input type is number, the built-in validator will be fighting against this directive.
@@ -10,4 +11,6 @@ export declare class CurrencyFormatterDirective implements OnInit {
10
11
  ngOnInit(): void;
11
12
  onFocus(value: string): void;
12
13
  onBlur(value: string): void;
14
+ static ɵfac: i0.ɵɵFactoryDeclaration<CurrencyFormatterDirective, never>;
15
+ static ɵdir: i0.ɵɵDirectiveDeclaration<CurrencyFormatterDirective, "[currencyFormatter]", never, {}, {}, never>;
13
16
  }
@@ -1,5 +1,8 @@
1
1
  import { ViewContainerRef } from '@angular/core';
2
+ import * as i0 from "@angular/core";
2
3
  export declare class DataComponentDirective {
3
4
  viewContainerRef: ViewContainerRef;
4
5
  constructor(viewContainerRef: ViewContainerRef);
6
+ static ɵfac: i0.ɵɵFactoryDeclaration<DataComponentDirective, never>;
7
+ static ɵdir: i0.ɵɵDirectiveDeclaration<DataComponentDirective, "[dataComponentHost]", never, {}, {}, never>;
5
8
  }
@@ -1,6 +1,16 @@
1
+ import * as i0 from "@angular/core";
2
+ import * as i1 from "./autofocus";
3
+ import * as i2 from "./currencyFormatter.directive";
4
+ import * as i3 from "./scrollInto.directive";
5
+ import * as i4 from "./dataComponent.directive";
6
+ import * as i5 from "@angular/common";
7
+ import * as i6 from "@angular/forms";
1
8
  /**
2
9
  * Contain components. Other feature/lazy modules that need to access custom html element of components like my-datetimepicker still need to import this module explicitly.
3
10
  *
4
11
  */
5
12
  export declare class NmceDirectivesModule {
13
+ static ɵfac: i0.ɵɵFactoryDeclaration<NmceDirectivesModule, never>;
14
+ static ɵmod: i0.ɵɵNgModuleDeclaration<NmceDirectivesModule, [typeof i1.AutofocusDirective, typeof i2.CurrencyFormatterDirective, typeof i3.ScrollIntoDirective, typeof i4.DataComponentDirective], [typeof i5.CommonModule, typeof i6.FormsModule], [typeof i1.AutofocusDirective, typeof i2.CurrencyFormatterDirective, typeof i3.ScrollIntoDirective, typeof i4.DataComponentDirective]>;
15
+ static ɵinj: i0.ɵɵInjectorDeclaration<NmceDirectivesModule>;
6
16
  }
@@ -1,4 +1,5 @@
1
1
  import { AfterViewInit, ElementRef } from '@angular/core';
2
+ import * as i0 from "@angular/core";
2
3
  /**
3
4
  * Scroll to element attached. And the element may be an Angular Material component too.
4
5
  */
@@ -7,4 +8,6 @@ export declare class ScrollIntoDirective implements AfterViewInit {
7
8
  constructor(el: ElementRef);
8
9
  scrollInto: boolean;
9
10
  ngAfterViewInit(): void;
11
+ static ɵfac: i0.ɵɵFactoryDeclaration<ScrollIntoDirective, never>;
12
+ static ɵdir: i0.ɵɵDirectiveDeclaration<ScrollIntoDirective, "[scrollInto]", never, { "scrollInto": "scrollInto"; }, {}, never>;
10
13
  }
@@ -0,0 +1,46 @@
1
+ import { Directive, Input } from '@angular/core';
2
+ import * as i0 from "@angular/core";
3
+ /**
4
+ * Use as a parametered input parameter in html element.
5
+ * When used inside a material dialog, this directive may be at odd against the autofocus config parameter of MatDialogConfig,
6
+ * if the autofocus config is not false. Generally speaking, no need to use this directive in a component presented in a mateiral dialog.
7
+ */
8
+ export class AutofocusDirective {
9
+ constructor(el) {
10
+ this.el = el;
11
+ this.toFocus = false;
12
+ this.focused = false;
13
+ this.initialised = false;
14
+ this.everFocused = false;
15
+ //console.debug('autofocusDirective created.');
16
+ }
17
+ ngAfterViewInit() {
18
+ this.initialised = true;
19
+ this.ngDoCheck();
20
+ }
21
+ ngDoCheck() {
22
+ if (!this.initialised) {
23
+ return;
24
+ }
25
+ if (this.toFocus && !this.everFocused && !this.focused) {
26
+ this.el.nativeElement.focus();
27
+ this.focused = true;
28
+ this.everFocused = true;
29
+ console.debug('focused now.');
30
+ }
31
+ }
32
+ set autofocus(condition) {
33
+ this.toFocus = condition !== false;
34
+ }
35
+ }
36
+ AutofocusDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: AutofocusDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
37
+ AutofocusDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.1.1", type: AutofocusDirective, selector: "[autofocus]", inputs: { autofocus: "autofocus" }, ngImport: i0 });
38
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: AutofocusDirective, decorators: [{
39
+ type: Directive,
40
+ args: [{
41
+ selector: '[autofocus]'
42
+ }]
43
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { autofocus: [{
44
+ type: Input
45
+ }] } });
46
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXV0b2ZvY3VzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vcHJvamVjdHMvbm1jZS1kaXJlY3RpdmVzL3NyYy9fZGlyZWN0aXZlcy9hdXRvZm9jdXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFpQixTQUFTLEVBQXVCLEtBQUssRUFBRSxNQUFNLGVBQWUsQ0FBQzs7QUFFckY7Ozs7R0FJRztBQUlILE1BQU0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Gl2ZSBjcmVhdGVkLicpO1xyXG5cdH1cclxuXHJcblx0bmdBZnRlclZpZXdJbml0KCkge1xyXG5cdFx0dGhpcy5pbml0aWFsaXNlZCA9IHRydWU7XHJcblx0XHR0aGlzLm5nRG9DaGVjaygpO1xyXG5cdH1cclxuXHJcblx0bmdEb0NoZWNrKCkge1xyXG5cdFx0aWYgKCF0aGlzLmluaXRpYWxpc2VkKSB7IHJldHVybjsgfVxyXG5cdFx0aWYgKHRoaXMudG9Gb2N1cyAmJiAhdGhpcy5ldmVyRm9jdXNlZCAmJiAhdGhpcy5mb2N1c2VkKSB7XHJcblx0XHRcdHRoaXMuZWwubmF0aXZlRWxlbWVudC5mb2N1cygpO1xyXG5cdFx0XHR0aGlzLmZvY3VzZWQgPSB0cnVlO1xyXG5cdFx0XHR0aGlzLmV2ZXJGb2N1c2VkID0gdHJ1ZTtcclxuXHRcdFx0Y29uc29sZS5kZWJ1ZygnZm9jdXNlZCBub3cuJyk7XHJcblx0XHR9XHJcblx0fVxyXG5cclxuXHRASW5wdXQoKSBzZXQgYXV0b2ZvY3VzKGNvbmRpdGlvbjogYm9vbGVhbikge1xyXG5cdFx0dGhpcy50b0ZvY3VzID0gY29uZGl0aW9uICE9PSBmYWxzZTtcclxuXHR9XHJcbn1cclxuIl19
@@ -0,0 +1,35 @@
1
+ import { Directive, HostListener } from '@angular/core';
2
+ import { CurrencyFunc } from 'nmce-func';
3
+ import * as i0 from "@angular/core";
4
+ /**
5
+ * Decorate HTML input for inputing and displaying currency. The input type must not be number and should be text only.
6
+ * If the input type is number, the built-in validator will be fighting against this directive.
7
+ */
8
+ export class CurrencyFormatterDirective {
9
+ constructor(elementRef) {
10
+ this.elementRef = elementRef;
11
+ this.el = this.elementRef.nativeElement;
12
+ }
13
+ ngOnInit() {
14
+ this.el.value = CurrencyFunc.transformCurrency(this.el.value);
15
+ }
16
+ onFocus(value) {
17
+ this.el.value = CurrencyFunc.parseCurrency(value); // opossite of transform
18
+ }
19
+ onBlur(value) {
20
+ this.el.value = CurrencyFunc.transformCurrency(value);
21
+ }
22
+ }
23
+ CurrencyFormatterDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: CurrencyFormatterDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
24
+ CurrencyFormatterDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.1.1", type: CurrencyFormatterDirective, selector: "[currencyFormatter]", host: { listeners: { "focus": "onFocus($event.target.value)", "blur": "onBlur($event.target.value)" } }, ngImport: i0 });
25
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: CurrencyFormatterDirective, decorators: [{
26
+ type: Directive,
27
+ args: [{ selector: '[currencyFormatter]' }]
28
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { onFocus: [{
29
+ type: HostListener,
30
+ args: ['focus', ['$event.target.value']]
31
+ }], onBlur: [{
32
+ type: HostListener,
33
+ args: ['blur', ['$event.target.value']]
34
+ }] } });
35
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY3VycmVuY3lGb3JtYXR0ZXIuZGlyZWN0aXZlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vcHJvamVjdHMvbm1jZS1kaXJlY3RpdmVzL3NyYy9fZGlyZWN0aXZlcy9jdXJyZW5jeUZvcm1hdHRlci5kaXJlY3RpdmUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFNBQVMsRUFBYyxZQUFZLEVBQVUsTUFBTSxlQUFlLENBQUM7QUFDNUUsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLFdBQVcsQ0FBQzs7QUFFekM7OztHQUdHO0FBRUgsTUFBTSxPQUFPLDBCQUEwQjtJQUl0QyxZQUFvQixV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oaXMuZWwudmFsdWUgPSBDdXJyZW5jeUZ1bmMucGFyc2VDdXJyZW5jeSh2YWx1ZSk7IC8vIG9wb3NzaXRlIG9mIHRyYW5zZm9ybVxyXG5cdH1cclxuXHJcblx0QEhvc3RMaXN0ZW5lcignYmx1cicsIFsnJGV2ZW50LnRhcmdldC52YWx1ZSddKVxyXG5cdG9uQmx1cih2YWx1ZTogc3RyaW5nKSB7XHJcblx0XHR0aGlzLmVsLnZhbHVlID0gQ3VycmVuY3lGdW5jLnRyYW5zZm9ybUN1cnJlbmN5KHZhbHVlKTtcclxuXHR9XHJcblxyXG59XHJcblxyXG4iXX0=
@@ -0,0 +1,16 @@
1
+ import { Directive } from '@angular/core';
2
+ import * as i0 from "@angular/core";
3
+ export class DataComponentDirective {
4
+ constructor(viewContainerRef) {
5
+ this.viewContainerRef = viewContainerRef;
6
+ }
7
+ }
8
+ DataComponentDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: DataComponentDirective, deps: [{ token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
9
+ DataComponentDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.1.1", type: DataComponentDirective, selector: "[dataComponentHost]", ngImport: i0 });
10
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: DataComponentDirective, decorators: [{
11
+ type: Directive,
12
+ args: [{
13
+ selector: '[dataComponentHost]',
14
+ }]
15
+ }], ctorParameters: function () { return [{ type: i0.ViewContainerRef }]; } });
16
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGF0YUNvbXBvbmVudC5kaXJlY3RpdmUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9wcm9qZWN0cy9ubWNlLWRpcmVjdGl2ZXMvc3JjL19kaXJlY3RpdmVzL2RhdGFDb21wb25lbnQuZGlyZWN0aXZlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxTQUFTLEVBQW9CLE1BQU0sZUFBZSxDQUFDOztBQUs1RCxNQUFNLE9BQU8sc0JBQXNCO0lBQ2xDLFlBQW1CLGdCQUFrQztRQUFsQyxxQkFBZ0IsR0FBaEIsZ0JBQWdCLENBQWtCO0lBQUksQ0FBQzs7bUhBRDlDLHNCQUFzQjt1R0FBdEIsc0JBQXNCOzJGQUF0QixzQkFBc0I7a0JBSGxDLFNBQVM7bUJBQUM7b0JBQ1YsUUFBUSxFQUFFLHFCQUFxQjtpQkFDL0IiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBEaXJlY3RpdmUsIFZpZXdDb250YWluZXJSZWYgfSBmcm9tICdAYW5ndWxhci9jb3JlJztcclxuXHJcbkBEaXJlY3RpdmUoe1xyXG5cdHNlbGVjdG9yOiAnW2RhdGFDb21wb25lbnRIb3N0XScsXHJcbn0pXHJcbmV4cG9ydCBjbGFzcyBEYXRhQ29tcG9uZW50RGlyZWN0aXZlIHtcclxuXHRjb25zdHJ1Y3RvcihwdWJsaWMgdmlld0NvbnRhaW5lclJlZjogVmlld0NvbnRhaW5lclJlZikgeyB9XHJcbn1cclxuIl19
@@ -0,0 +1,46 @@
1
+ import { CommonModule } from '@angular/common';
2
+ import { NgModule } from '@angular/core';
3
+ import { FormsModule } from '@angular/forms';
4
+ import { AutofocusDirective, CurrencyFormatterDirective, DataComponentDirective, ScrollIntoDirective } from './index';
5
+ import * as i0 from "@angular/core";
6
+ /**
7
+ * Contain components. Other feature/lazy modules that need to access custom html element of components like my-datetimepicker still need to import this module explicitly.
8
+ *
9
+ */
10
+ export class NmceDirectivesModule {
11
+ }
12
+ NmceDirectivesModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: NmceDirectivesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
13
+ NmceDirectivesModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: NmceDirectivesModule, declarations: [AutofocusDirective,
14
+ CurrencyFormatterDirective,
15
+ ScrollIntoDirective,
16
+ DataComponentDirective], imports: [CommonModule,
17
+ FormsModule], exports: [AutofocusDirective,
18
+ CurrencyFormatterDirective,
19
+ ScrollIntoDirective,
20
+ DataComponentDirective] });
21
+ NmceDirectivesModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: NmceDirectivesModule, imports: [[
22
+ CommonModule,
23
+ FormsModule,
24
+ ]] });
25
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: NmceDirectivesModule, decorators: [{
26
+ type: NgModule,
27
+ args: [{
28
+ imports: [
29
+ CommonModule,
30
+ FormsModule,
31
+ ],
32
+ declarations: [
33
+ AutofocusDirective,
34
+ CurrencyFormatterDirective,
35
+ ScrollIntoDirective,
36
+ DataComponentDirective,
37
+ ],
38
+ exports: [
39
+ AutofocusDirective,
40
+ CurrencyFormatterDirective,
41
+ ScrollIntoDirective,
42
+ DataComponentDirective,
43
+ ]
44
+ }]
45
+ }] });
46
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGlyZWN0aXZlcy5tb2R1bGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9wcm9qZWN0cy9ubWNlLWRpcmVjdGl2ZXMvc3JjL19kaXJlY3RpdmVzL2RpcmVjdGl2ZXMubW9kdWxlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxZQUFZLEVBQUUsTUFBTSxpQkFBaUIsQ0FBQztBQUMvQyxPQUFPLEVBQUUsUUFBUSxFQUFFLE1BQU0sZUFBZSxDQUFDO0FBQ3pDLE9BQU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**
4
+ * Scroll to element attached. And the element may be an Angular Material component too.
5
+ */
6
+ export class ScrollIntoDirective {
7
+ constructor(el) {
8
+ this.el = el;
9
+ this.scrollInto = false;
10
+ // console.debug('ScrollIntoDirective created.');
11
+ }
12
+ ngAfterViewInit() {
13
+ if (this.scrollInto) {
14
+ this.el.nativeElement.scrollIntoView();
15
+ }
16
+ }
17
+ }
18
+ ScrollIntoDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: ScrollIntoDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
19
+ ScrollIntoDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.1.1", type: ScrollIntoDirective, selector: "[scrollInto]", inputs: { scrollInto: "scrollInto" }, ngImport: i0 });
20
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: ScrollIntoDirective, decorators: [{
21
+ type: Directive,
22
+ args: [{
23
+ selector: '[scrollInto]'
24
+ }]
25
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { scrollInto: [{
26
+ type: Input
27
+ }] } });
28
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2Nyb2xsSW50by5kaXJlY3RpdmUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9wcm9qZWN0cy9ubWNlLWRpcmVjdGl2ZXMvc3JjL19kaXJlY3RpdmVzL3Njcm9sbEludG8uZGlyZWN0aXZlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBaUIsU0FBUyxFQUFjLEtBQUssRUFBRSxNQUFNLGVBQWUsQ0FBQzs7QUFFNUU7O0dBRUc7QUFJSCxNQUFNLE9BQU8sbUJBQW1CO0lBQy9CLFlBQW9CLEVBQWM7UUFBZCxPQUFFLEdBQU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G5cdFx0aWYgKHRoaXMuc2Nyb2xsSW50bykge1xyXG5cdFx0XHR0aGlzLmVsLm5hdGl2ZUVsZW1lbnQuc2Nyb2xsSW50b1ZpZXcoKTtcclxuXHRcdH1cclxuXHR9XHJcbn1cclxuIl19
@@ -0,0 +1,173 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Directive, Input, HostListener, NgModule } from '@angular/core';
3
+ import { CurrencyFunc } from 'nmce-func';
4
+ import { CommonModule } from '@angular/common';
5
+ import { FormsModule } from '@angular/forms';
6
+
7
+ /**
8
+ * Use as a parametered input parameter in html element.
9
+ * When used inside a material dialog, this directive may be at odd against the autofocus config parameter of MatDialogConfig,
10
+ * if the autofocus config is not false. Generally speaking, no need to use this directive in a component presented in a mateiral dialog.
11
+ */
12
+ class AutofocusDirective {
13
+ constructor(el) {
14
+ this.el = el;
15
+ this.toFocus = false;
16
+ this.focused = false;
17
+ this.initialised = false;
18
+ this.everFocused = false;
19
+ //console.debug('autofocusDirective created.');
20
+ }
21
+ ngAfterViewInit() {
22
+ this.initialised = true;
23
+ this.ngDoCheck();
24
+ }
25
+ ngDoCheck() {
26
+ if (!this.initialised) {
27
+ return;
28
+ }
29
+ if (this.toFocus && !this.everFocused && !this.focused) {
30
+ this.el.nativeElement.focus();
31
+ this.focused = true;
32
+ this.everFocused = true;
33
+ console.debug('focused now.');
34
+ }
35
+ }
36
+ set autofocus(condition) {
37
+ this.toFocus = condition !== false;
38
+ }
39
+ }
40
+ AutofocusDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: AutofocusDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
41
+ AutofocusDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.1.1", type: AutofocusDirective, selector: "[autofocus]", inputs: { autofocus: "autofocus" }, ngImport: i0 });
42
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: AutofocusDirective, decorators: [{
43
+ type: Directive,
44
+ args: [{
45
+ selector: '[autofocus]'
46
+ }]
47
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { autofocus: [{
48
+ type: Input
49
+ }] } });
50
+
51
+ /**
52
+ * Decorate HTML input for inputing and displaying currency. The input type must not be number and should be text only.
53
+ * If the input type is number, the built-in validator will be fighting against this directive.
54
+ */
55
+ class CurrencyFormatterDirective {
56
+ constructor(elementRef) {
57
+ this.elementRef = elementRef;
58
+ this.el = this.elementRef.nativeElement;
59
+ }
60
+ ngOnInit() {
61
+ this.el.value = CurrencyFunc.transformCurrency(this.el.value);
62
+ }
63
+ onFocus(value) {
64
+ this.el.value = CurrencyFunc.parseCurrency(value); // opossite of transform
65
+ }
66
+ onBlur(value) {
67
+ this.el.value = CurrencyFunc.transformCurrency(value);
68
+ }
69
+ }
70
+ CurrencyFormatterDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: CurrencyFormatterDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
71
+ CurrencyFormatterDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.1.1", type: CurrencyFormatterDirective, selector: "[currencyFormatter]", host: { listeners: { "focus": "onFocus($event.target.value)", "blur": "onBlur($event.target.value)" } }, ngImport: i0 });
72
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: CurrencyFormatterDirective, decorators: [{
73
+ type: Directive,
74
+ args: [{ selector: '[currencyFormatter]' }]
75
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { onFocus: [{
76
+ type: HostListener,
77
+ args: ['focus', ['$event.target.value']]
78
+ }], onBlur: [{
79
+ type: HostListener,
80
+ args: ['blur', ['$event.target.value']]
81
+ }] } });
82
+
83
+ class DataComponentDirective {
84
+ constructor(viewContainerRef) {
85
+ this.viewContainerRef = viewContainerRef;
86
+ }
87
+ }
88
+ DataComponentDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: DataComponentDirective, deps: [{ token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
89
+ DataComponentDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.1.1", type: DataComponentDirective, selector: "[dataComponentHost]", ngImport: i0 });
90
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: DataComponentDirective, decorators: [{
91
+ type: Directive,
92
+ args: [{
93
+ selector: '[dataComponentHost]',
94
+ }]
95
+ }], ctorParameters: function () { return [{ type: i0.ViewContainerRef }]; } });
96
+
97
+ /**
98
+ * Scroll to element attached. And the element may be an Angular Material component too.
99
+ */
100
+ class ScrollIntoDirective {
101
+ constructor(el) {
102
+ this.el = el;
103
+ this.scrollInto = false;
104
+ // console.debug('ScrollIntoDirective created.');
105
+ }
106
+ ngAfterViewInit() {
107
+ if (this.scrollInto) {
108
+ this.el.nativeElement.scrollIntoView();
109
+ }
110
+ }
111
+ }
112
+ ScrollIntoDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: ScrollIntoDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
113
+ ScrollIntoDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.1.1", type: ScrollIntoDirective, selector: "[scrollInto]", inputs: { scrollInto: "scrollInto" }, ngImport: i0 });
114
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: ScrollIntoDirective, decorators: [{
115
+ type: Directive,
116
+ args: [{
117
+ selector: '[scrollInto]'
118
+ }]
119
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { scrollInto: [{
120
+ type: Input
121
+ }] } });
122
+
123
+ /**
124
+ * Contain components. Other feature/lazy modules that need to access custom html element of components like my-datetimepicker still need to import this module explicitly.
125
+ *
126
+ */
127
+ class NmceDirectivesModule {
128
+ }
129
+ NmceDirectivesModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: NmceDirectivesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
130
+ NmceDirectivesModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: NmceDirectivesModule, declarations: [AutofocusDirective,
131
+ CurrencyFormatterDirective,
132
+ ScrollIntoDirective,
133
+ DataComponentDirective], imports: [CommonModule,
134
+ FormsModule], exports: [AutofocusDirective,
135
+ CurrencyFormatterDirective,
136
+ ScrollIntoDirective,
137
+ DataComponentDirective] });
138
+ NmceDirectivesModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: NmceDirectivesModule, imports: [[
139
+ CommonModule,
140
+ FormsModule,
141
+ ]] });
142
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: NmceDirectivesModule, decorators: [{
143
+ type: NgModule,
144
+ args: [{
145
+ imports: [
146
+ CommonModule,
147
+ FormsModule,
148
+ ],
149
+ declarations: [
150
+ AutofocusDirective,
151
+ CurrencyFormatterDirective,
152
+ ScrollIntoDirective,
153
+ DataComponentDirective,
154
+ ],
155
+ exports: [
156
+ AutofocusDirective,
157
+ CurrencyFormatterDirective,
158
+ ScrollIntoDirective,
159
+ DataComponentDirective,
160
+ ]
161
+ }]
162
+ }] });
163
+
164
+ /*
165
+ * Public API Surface of nmce-directives
166
+ */
167
+
168
+ /**
169
+ * Generated bundle index. Do not edit.
170
+ */
171
+
172
+ export { AutofocusDirective, CurrencyFormatterDirective, DataComponentDirective, NmceDirectivesModule, ScrollIntoDirective };
173
+ //# sourceMappingURL=nmce-directives.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nmce-directives.mjs","sources":["../../../projects/nmce-directives/src/_directives/autofocus.ts","../../../projects/nmce-directives/src/_directives/currencyFormatter.directive.ts","../../../projects/nmce-directives/src/_directives/dataComponent.directive.ts","../../../projects/nmce-directives/src/_directives/scrollInto.directive.ts","../../../projects/nmce-directives/src/_directives/directives.module.ts","../../../projects/nmce-directives/src/public-api.ts","../../../projects/nmce-directives/src/nmce-directives.ts"],"sourcesContent":["import { AfterViewInit, Directive, DoCheck, ElementRef, Input } from '@angular/core';\r\n\r\n/**\r\n * Use as a parametered input parameter in html element.\r\n * When used inside a material dialog, this directive may be at odd against the autofocus config parameter of MatDialogConfig, \r\n * if the autofocus config is not false. Generally speaking, no need to use this directive in a component presented in a mateiral dialog.\r\n */\r\n@Directive({\r\n\tselector: '[autofocus]'\r\n})\r\nexport class AutofocusDirective implements AfterViewInit, DoCheck {\r\n\tprivate toFocus = false;\r\n\tprivate focused = false;\r\n\tprivate initialised = false;\r\n\tprivate everFocused = false;\r\n\tconstructor(private el: ElementRef) {\r\n\t\t//console.debug('autofocusDirective created.');\r\n\t}\r\n\r\n\tngAfterViewInit() {\r\n\t\tthis.initialised = true;\r\n\t\tthis.ngDoCheck();\r\n\t}\r\n\r\n\tngDoCheck() {\r\n\t\tif (!this.initialised) { return; }\r\n\t\tif (this.toFocus && !this.everFocused && !this.focused) {\r\n\t\t\tthis.el.nativeElement.focus();\r\n\t\t\tthis.focused = true;\r\n\t\t\tthis.everFocused = true;\r\n\t\t\tconsole.debug('focused now.');\r\n\t\t}\r\n\t}\r\n\r\n\t@Input() set autofocus(condition: boolean) {\r\n\t\tthis.toFocus = condition !== false;\r\n\t}\r\n}\r\n","import { Directive, ElementRef, HostListener, OnInit } from '@angular/core';\r\nimport { CurrencyFunc } from 'nmce-func';\r\n\r\n/**\r\n * Decorate HTML input for inputing and displaying currency. The input type must not be number and should be text only.\r\n * If the input type is number, the built-in validator will be fighting against this directive.\r\n */\r\n@Directive({ selector: '[currencyFormatter]' })//inspired by https://blog.ngconsultant.io/custom-input-formatting-with-simple-directives-for-angular-2-ec792082976\r\nexport class CurrencyFormatterDirective implements OnInit {\r\n\r\n\tprivate el: HTMLInputElement;\r\n\r\n\tconstructor(private elementRef: ElementRef) {\r\n\t\tthis.el = this.elementRef.nativeElement;\r\n\t}\r\n\r\n\tngOnInit() {\r\n\t\tthis.el.value = CurrencyFunc.transformCurrency(this.el.value);\r\n\t}\r\n\r\n\t@HostListener('focus', ['$event.target.value'])\r\n\tonFocus(value: string) {\r\n\t\tthis.el.value = CurrencyFunc.parseCurrency(value); // opossite of transform\r\n\t}\r\n\r\n\t@HostListener('blur', ['$event.target.value'])\r\n\tonBlur(value: string) {\r\n\t\tthis.el.value = CurrencyFunc.transformCurrency(value);\r\n\t}\r\n\r\n}\r\n\r\n","import { Directive, ViewContainerRef } from '@angular/core';\r\n\r\n@Directive({\r\n\tselector: '[dataComponentHost]',\r\n})\r\nexport class DataComponentDirective {\r\n\tconstructor(public viewContainerRef: ViewContainerRef) { }\r\n}\r\n","import { AfterViewInit, Directive, ElementRef, Input } from '@angular/core';\r\n\r\n/**\r\n * Scroll to element attached. And the element may be an Angular Material component too.\r\n */\r\n@Directive({\r\n\tselector: '[scrollInto]'\r\n})\r\nexport class ScrollIntoDirective implements AfterViewInit {\r\n\tconstructor(private el: ElementRef) {\r\n\t\t//\tconsole.debug('ScrollIntoDirective created.');\r\n\t}\r\n\r\n\t@Input()\r\n\tscrollInto: boolean = false;\r\n\r\n\tngAfterViewInit() {\r\n\t\tif (this.scrollInto) {\r\n\t\t\tthis.el.nativeElement.scrollIntoView();\r\n\t\t}\r\n\t}\r\n}\r\n","import { CommonModule } from '@angular/common';\r\nimport { NgModule } from '@angular/core';\r\nimport { FormsModule } from '@angular/forms';\r\nimport {\r\n\tAutofocusDirective, CurrencyFormatterDirective, DataComponentDirective, ScrollIntoDirective\r\n} from './index';\r\n\r\n\r\n\r\n/**\r\n * Contain components. Other feature/lazy modules that need to access custom html element of components like my-datetimepicker still need to import this module explicitly.\r\n *\r\n */\r\n@NgModule({\r\n\timports: [\r\n\t\tCommonModule,\r\n\t\tFormsModule,\r\n\t],\r\n\r\n\tdeclarations: [\r\n\t\tAutofocusDirective,\r\n\t\tCurrencyFormatterDirective,\r\n\t\tScrollIntoDirective,\r\n\t\tDataComponentDirective,\r\n\t],\r\n\r\n\r\n\texports: [\r\n\t\tAutofocusDirective,\r\n\t\tCurrencyFormatterDirective,\r\n\t\tScrollIntoDirective,\r\n\t\tDataComponentDirective,\r\n\t]\r\n})\r\nexport class NmceDirectivesModule { }\r\n","/*\n * Public API Surface of nmce-directives\n */\n\nexport * from './_directives/index';\nexport * from './_directives/directives.module';\n\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;AAEA;;;;;MAQa,kBAAkB;IAK9B,YAAoB,EAAc;QAAd,OAAE,GAAF,EAAE,CAAY;QAJ1B,YAAO,GAAG,KAAK,CAAC;QAChB,YAAO,GAAG,KAAK,CAAC;QAChB,gBAAW,GAAG,KAAK,CAAC;QACpB,gBAAW,GAAG,KAAK,CAAC;;KAG3B;IAED,eAAe;QACd,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,SAAS,EAAE,CAAC;KACjB;IAED,SAAS;QACR,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YAAE,OAAO;SAAE;QAClC,IAAI,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACvD,IAAI,CAAC,EAAE,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;YAC9B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;YACpB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;YACxB,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;SAC9B;KACD;IAED,IAAa,SAAS,CA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AAU,GAAY,KAAK,CAAC;;KAH3B;IAKD,eAAe;QACd,IAAI,IAAI,CAAC,UAAU,EAAE;YACpB,IAAI,CAAC,EAAE,CAAC,aAAa,CAAC,cAAc,EAAE,CAAC;SACvC;KACD;;gHAZW,mBAAmB;oGAAnB,mBAAmB;2FAAnB,mBAAmB;kBAH/B,SAAS;mBAAC;oBACV,QAAQ,EAAE,cAAc;iBACxB;iGAOA,UAAU;sBADT,KAAK;;;ACJP;;;;MAyBa,oBAAoB;;iHAApB,oBAAoB;kHAApB,oBAAoB,iBAd/B,kBAAkB;QAClB,0BAA0B;QAC1B,mBAAmB;QACnB,sBAAsB,aARtB,YAAY;QACZ,WAAW,aAYX,kBAAkB;QAClB,0BAA0B;QAC1B,mBAAmB;QACnB,sBAAsB;kHAGX,oBAAoB,YApBvB;YACR,YAAY;YACZ,WAAW;SACX;2FAiBW,oBAAoB;kBArBhC,QAAQ;mBAAC;oBACT,OAAO,EAAE;wBACR,YAAY;wBACZ,WAAW;qBACX;oBAED,YAAY,EAAE;wBACb,kBAAkB;wBAClB,0BAA0B;wBAC1B,mBAAmB;wBACnB,sBAAsB;qBACtB;oBAGD,OAAO,EAAE;wBACR,kBAAkB;wBAClB,0BAA0B;wBAC1B,mBAAmB;wBACnB,sBAAsB;qBACtB;iBACD;;;ACjCD;;;;ACAA;;;;;;"}
@@ -0,0 +1,173 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Directive, Input, HostListener, NgModule } from '@angular/core';
3
+ import { CurrencyFunc } from 'nmce-func';
4
+ import { CommonModule } from '@angular/common';
5
+ import { FormsModule } from '@angular/forms';
6
+
7
+ /**
8
+ * Use as a parametered input parameter in html element.
9
+ * When used inside a material dialog, this directive may be at odd against the autofocus config parameter of MatDialogConfig,
10
+ * if the autofocus config is not false. Generally speaking, no need to use this directive in a component presented in a mateiral dialog.
11
+ */
12
+ class AutofocusDirective {
13
+ constructor(el) {
14
+ this.el = el;
15
+ this.toFocus = false;
16
+ this.focused = false;
17
+ this.initialised = false;
18
+ this.everFocused = false;
19
+ //console.debug('autofocusDirective created.');
20
+ }
21
+ ngAfterViewInit() {
22
+ this.initialised = true;
23
+ this.ngDoCheck();
24
+ }
25
+ ngDoCheck() {
26
+ if (!this.initialised) {
27
+ return;
28
+ }
29
+ if (this.toFocus && !this.everFocused && !this.focused) {
30
+ this.el.nativeElement.focus();
31
+ this.focused = true;
32
+ this.everFocused = true;
33
+ console.debug('focused now.');
34
+ }
35
+ }
36
+ set autofocus(condition) {
37
+ this.toFocus = condition !== false;
38
+ }
39
+ }
40
+ AutofocusDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: AutofocusDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
41
+ AutofocusDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.1.1", type: AutofocusDirective, selector: "[autofocus]", inputs: { autofocus: "autofocus" }, ngImport: i0 });
42
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: AutofocusDirective, decorators: [{
43
+ type: Directive,
44
+ args: [{
45
+ selector: '[autofocus]'
46
+ }]
47
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { autofocus: [{
48
+ type: Input
49
+ }] } });
50
+
51
+ /**
52
+ * Decorate HTML input for inputing and displaying currency. The input type must not be number and should be text only.
53
+ * If the input type is number, the built-in validator will be fighting against this directive.
54
+ */
55
+ class CurrencyFormatterDirective {
56
+ constructor(elementRef) {
57
+ this.elementRef = elementRef;
58
+ this.el = this.elementRef.nativeElement;
59
+ }
60
+ ngOnInit() {
61
+ this.el.value = CurrencyFunc.transformCurrency(this.el.value);
62
+ }
63
+ onFocus(value) {
64
+ this.el.value = CurrencyFunc.parseCurrency(value); // opossite of transform
65
+ }
66
+ onBlur(value) {
67
+ this.el.value = CurrencyFunc.transformCurrency(value);
68
+ }
69
+ }
70
+ CurrencyFormatterDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: CurrencyFormatterDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
71
+ CurrencyFormatterDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.1.1", type: CurrencyFormatterDirective, selector: "[currencyFormatter]", host: { listeners: { "focus": "onFocus($event.target.value)", "blur": "onBlur($event.target.value)" } }, ngImport: i0 });
72
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: CurrencyFormatterDirective, decorators: [{
73
+ type: Directive,
74
+ args: [{ selector: '[currencyFormatter]' }]
75
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { onFocus: [{
76
+ type: HostListener,
77
+ args: ['focus', ['$event.target.value']]
78
+ }], onBlur: [{
79
+ type: HostListener,
80
+ args: ['blur', ['$event.target.value']]
81
+ }] } });
82
+
83
+ class DataComponentDirective {
84
+ constructor(viewContainerRef) {
85
+ this.viewContainerRef = viewContainerRef;
86
+ }
87
+ }
88
+ DataComponentDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: DataComponentDirective, deps: [{ token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
89
+ DataComponentDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.1.1", type: DataComponentDirective, selector: "[dataComponentHost]", ngImport: i0 });
90
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: DataComponentDirective, decorators: [{
91
+ type: Directive,
92
+ args: [{
93
+ selector: '[dataComponentHost]',
94
+ }]
95
+ }], ctorParameters: function () { return [{ type: i0.ViewContainerRef }]; } });
96
+
97
+ /**
98
+ * Scroll to element attached. And the element may be an Angular Material component too.
99
+ */
100
+ class ScrollIntoDirective {
101
+ constructor(el) {
102
+ this.el = el;
103
+ this.scrollInto = false;
104
+ // console.debug('ScrollIntoDirective created.');
105
+ }
106
+ ngAfterViewInit() {
107
+ if (this.scrollInto) {
108
+ this.el.nativeElement.scrollIntoView();
109
+ }
110
+ }
111
+ }
112
+ ScrollIntoDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: ScrollIntoDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
113
+ ScrollIntoDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.1.1", type: ScrollIntoDirective, selector: "[scrollInto]", inputs: { scrollInto: "scrollInto" }, ngImport: i0 });
114
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: ScrollIntoDirective, decorators: [{
115
+ type: Directive,
116
+ args: [{
117
+ selector: '[scrollInto]'
118
+ }]
119
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { scrollInto: [{
120
+ type: Input
121
+ }] } });
122
+
123
+ /**
124
+ * Contain components. Other feature/lazy modules that need to access custom html element of components like my-datetimepicker still need to import this module explicitly.
125
+ *
126
+ */
127
+ class NmceDirectivesModule {
128
+ }
129
+ NmceDirectivesModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: NmceDirectivesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
130
+ NmceDirectivesModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: NmceDirectivesModule, declarations: [AutofocusDirective,
131
+ CurrencyFormatterDirective,
132
+ ScrollIntoDirective,
133
+ DataComponentDirective], imports: [CommonModule,
134
+ FormsModule], exports: [AutofocusDirective,
135
+ CurrencyFormatterDirective,
136
+ ScrollIntoDirective,
137
+ DataComponentDirective] });
138
+ NmceDirectivesModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: NmceDirectivesModule, imports: [[
139
+ CommonModule,
140
+ FormsModule,
141
+ ]] });
142
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: NmceDirectivesModule, decorators: [{
143
+ type: NgModule,
144
+ args: [{
145
+ imports: [
146
+ CommonModule,
147
+ FormsModule,
148
+ ],
149
+ declarations: [
150
+ AutofocusDirective,
151
+ CurrencyFormatterDirective,
152
+ ScrollIntoDirective,
153
+ DataComponentDirective,
154
+ ],
155
+ exports: [
156
+ AutofocusDirective,
157
+ CurrencyFormatterDirective,
158
+ ScrollIntoDirective,
159
+ DataComponentDirective,
160
+ ]
161
+ }]
162
+ }] });
163
+
164
+ /*
165
+ * Public API Surface of nmce-directives
166
+ */
167
+
168
+ /**
169
+ * Generated bundle index. Do not edit.
170
+ */
171
+
172
+ export { AutofocusDirective, CurrencyFormatterDirective, DataComponentDirective, NmceDirectivesModule, ScrollIntoDirective };
173
+ //# sourceMappingURL=nmce-directives.mjs.map