nmce-directives 0.0.3 → 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.
- package/_directives/autofocus.d.ts +20 -0
- package/_directives/currencyFormatter.directive.d.ts +16 -0
- package/_directives/dataComponent.directive.d.ts +8 -0
- package/_directives/directives.module.d.ts +16 -0
- package/_directives/index.d.ts +4 -0
- package/_directives/scrollInto.directive.d.ts +13 -0
- package/esm2020/_directives/autofocus.mjs +46 -0
- package/esm2020/_directives/currencyFormatter.directive.mjs +35 -0
- package/esm2020/_directives/dataComponent.directive.mjs +16 -0
- package/esm2020/_directives/directives.module.mjs +46 -0
- package/esm2020/_directives/index.mjs +5 -0
- package/esm2020/_directives/scrollInto.directive.mjs +28 -0
- package/esm2020/nmce-directives.mjs +5 -0
- package/esm2020/public-api.mjs +6 -0
- package/fesm2015/nmce-directives.mjs +173 -0
- package/fesm2015/nmce-directives.mjs.map +1 -0
- package/fesm2020/nmce-directives.mjs +173 -0
- package/fesm2020/nmce-directives.mjs.map +1 -0
- package/nmce-directives.d.ts +5 -0
- package/package.json +33 -5
- package/{src/public-api.ts → public-api.d.ts} +2 -7
- package/karma.conf.js +0 -44
- package/ng-package.json +0 -11
- package/src/_directives/autofocus.ts +0 -33
- package/src/_directives/currencyFormatter.directive.ts +0 -31
- package/src/_directives/dataComponent.directive.ts +0 -8
- package/src/_directives/datetimeFormatter.directive.ts +0 -58
- package/src/_directives/directives.module.ts +0 -39
- package/src/_directives/highlight.directive.ts +0 -21
- package/src/_directives/index.ts +0 -6
- package/src/_directives/scrollInto.directive.ts +0 -18
- package/src/test.ts +0 -26
- package/tsconfig.lib.json +0 -25
- package/tsconfig.lib.prod.json +0 -10
- package/tsconfig.spec.json +0 -17
- package/tslint.json +0 -17
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AfterViewInit, DoCheck, ElementRef } 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 declare class AutofocusDirective implements AfterViewInit, DoCheck {
|
|
9
|
+
private el;
|
|
10
|
+
private toFocus;
|
|
11
|
+
private focused;
|
|
12
|
+
private initialised;
|
|
13
|
+
private everFocused;
|
|
14
|
+
constructor(el: ElementRef);
|
|
15
|
+
ngAfterViewInit(): void;
|
|
16
|
+
ngDoCheck(): void;
|
|
17
|
+
set autofocus(condition: boolean);
|
|
18
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AutofocusDirective, never>;
|
|
19
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<AutofocusDirective, "[autofocus]", never, { "autofocus": "autofocus"; }, {}, never>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ElementRef, OnInit } from '@angular/core';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
/**
|
|
4
|
+
* Decorate HTML input for inputing and displaying currency. The input type must not be number and should be text only.
|
|
5
|
+
* If the input type is number, the built-in validator will be fighting against this directive.
|
|
6
|
+
*/
|
|
7
|
+
export declare class CurrencyFormatterDirective implements OnInit {
|
|
8
|
+
private elementRef;
|
|
9
|
+
private el;
|
|
10
|
+
constructor(elementRef: ElementRef);
|
|
11
|
+
ngOnInit(): void;
|
|
12
|
+
onFocus(value: string): void;
|
|
13
|
+
onBlur(value: string): void;
|
|
14
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<CurrencyFormatterDirective, never>;
|
|
15
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<CurrencyFormatterDirective, "[currencyFormatter]", never, {}, {}, never>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ViewContainerRef } from '@angular/core';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
export declare class DataComponentDirective {
|
|
4
|
+
viewContainerRef: ViewContainerRef;
|
|
5
|
+
constructor(viewContainerRef: ViewContainerRef);
|
|
6
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<DataComponentDirective, never>;
|
|
7
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<DataComponentDirective, "[dataComponentHost]", never, {}, {}, never>;
|
|
8
|
+
}
|
|
@@ -0,0 +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";
|
|
8
|
+
/**
|
|
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.
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
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>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AfterViewInit, ElementRef } from '@angular/core';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
/**
|
|
4
|
+
* Scroll to element attached. And the element may be an Angular Material component too.
|
|
5
|
+
*/
|
|
6
|
+
export declare class ScrollIntoDirective implements AfterViewInit {
|
|
7
|
+
private el;
|
|
8
|
+
constructor(el: ElementRef);
|
|
9
|
+
scrollInto: boolean;
|
|
10
|
+
ngAfterViewInit(): void;
|
|
11
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ScrollIntoDirective, never>;
|
|
12
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<ScrollIntoDirective, "[scrollInto]", never, { "scrollInto": "scrollInto"; }, {}, never>;
|
|
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXV0b2ZvY3VzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vcHJvamVjdHMvbm1jZS1kaXJlY3RpdmVzL3NyYy9fZGlyZWN0aXZlcy9hdXRvZm9jdXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFpQixTQUFTLEVBQXVCLEtBQUssRUFBRSxNQUFNLGVBQWUsQ0FBQzs7QUFFckY7Ozs7R0FJRztBQUlILE1BQU0sT0FBTyxrQkFBa0I7SUFLOUIsWUFBb0IsRUFBYztRQUFkLE9BQUUsR0FBRixFQUFFLENBQVk7UUFKMUIsWUFBTyxHQUFHLEtBQUssQ0FBQztRQUNoQixZQUFPLEdBQUcsS0FBSyxDQUFDO1FBQ2hCLGdCQUFXLEdBQUcsS0FBSyxDQUFDO1FBQ3BCLGdCQUFXLEdBQUcsS0FBSyxDQUFDO1FBRTNCLCtDQUErQztJQUNo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dFx0aWYgKHRoaXMudG9Gb2N1cyAmJiAhdGhpcy5ldmVyRm9jdXNlZCAmJiAhdGhpcy5mb2N1c2VkKSB7XHJcblx0XHRcdHRoaXMuZWwubmF0aXZlRWxlbWVudC5mb2N1cygpO1xyXG5cdFx0XHR0aGlzLmZvY3VzZWQgPSB0cnVlO1xyXG5cdFx0XHR0aGlzLmV2ZXJGb2N1c2VkID0gdHJ1ZTtcclxuXHRcdFx0Y29uc29sZS5kZWJ1ZygnZm9jdXNlZCBub3cuJyk7XHJcblx0XHR9XHJcblx0fVxyXG5cclxuXHRASW5wdXQoKSBzZXQgYXV0b2ZvY3VzKGNvbmRpdGlvbjogYm9vbGVhbikge1xyXG5cdFx0dGhpcy50b0ZvY3VzID0gY29uZGl0aW9uICE9PSBmYWxzZTtcclxuXHR9XHJcbn1cclxuIl19
|
|
@@ -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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY3VycmVuY3lGb3JtYXR0ZXIuZGlyZWN0aXZlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vcHJvamVjdHMvbm1jZS1kaXJlY3RpdmVzL3NyYy9fZGlyZWN0aXZlcy9jdXJyZW5jeUZvcm1hdHRlci5kaXJlY3RpdmUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFNBQVMsRUFBYyxZQUFZLEVBQVUsTUFBTSxlQUFlLENBQUM7QUFDNUUsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLFdBQVcsQ0FBQzs7QUFFekM7OztHQUdHO0FBRUgsTUFBTSxPQUFPLDBCQUEwQjtJQUl0QyxZQUFvQixVQUFzQjtRQUF0Qixl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gPSBDdXJyZW5jeUZ1bmMucGFyc2VDdXJyZW5jeSh2YWx1ZSk7IC8vIG9wb3NzaXRlIG9mIHRyYW5zZm9ybVxyXG5cdH1cclxuXHJcblx0QEhvc3RMaXN0ZW5lcignYmx1cicsIFsnJGV2ZW50LnRhcmdldC52YWx1ZSddKVxyXG5cdG9uQmx1cih2YWx1ZTogc3RyaW5nKSB7XHJcblx0XHR0aGlzLmVsLnZhbHVlID0gQ3VycmVuY3lGdW5jLnRyYW5zZm9ybUN1cnJlbmN5KHZhbHVlKTtcclxuXHR9XHJcblxyXG59XHJcblxyXG4iXX0=
|
|
@@ -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
|
+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dGFDb21wb25lbnREaXJlY3RpdmUsXHJcblx0XSxcclxuXHJcblxyXG5cdGV4cG9ydHM6IFtcclxuXHRcdEF1dG9mb2N1c0RpcmVjdGl2ZSxcclxuXHRcdEN1cnJlbmN5Rm9ybWF0dGVyRGlyZWN0aXZlLFxyXG5cdFx0U2Nyb2xsSW50b0RpcmVjdGl2ZSxcclxuXHRcdERhdGFDb21wb25lbnREaXJlY3RpdmUsXHJcblx0XVxyXG59KVxyXG5leHBvcnQgY2xhc3MgTm1jZURpcmVjdGl2ZXNNb2R1bGUgeyB9XHJcbiJdfQ==
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export * from './autofocus';
|
|
2
|
+
export * from './currencyFormatter.directive';
|
|
3
|
+
export * from './dataComponent.directive';
|
|
4
|
+
export * from './scrollInto.directive';
|
|
5
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9wcm9qZWN0cy9ubWNlLWRpcmVjdGl2ZXMvc3JjL19kaXJlY3RpdmVzL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGNBQWMsYUFBYSxDQUFDO0FBQzVCLGNBQWMsK0JBQStCLENBQUM7QUFDOUMsY0FBYywyQkFBMkIsQ0FBQztBQUMxQyxjQUFjLHdCQUF3QixDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0ICogZnJvbSAnLi9hdXRvZm9jdXMnO1xyXG5leHBvcnQgKiBmcm9tICcuL2N1cnJlbmN5Rm9ybWF0dGVyLmRpcmVjdGl2ZSc7XHJcbmV4cG9ydCAqIGZyb20gJy4vZGF0YUNvbXBvbmVudC5kaXJlY3RpdmUnO1xyXG5leHBvcnQgKiBmcm9tICcuL3Njcm9sbEludG8uZGlyZWN0aXZlJztcclxuIl19
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Directive, Input } from '@angular/core';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
/**
|
|
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2Nyb2xsSW50by5kaXJlY3RpdmUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9wcm9qZWN0cy9ubWNlLWRpcmVjdGl2ZXMvc3JjL19kaXJlY3RpdmVzL3Njcm9s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UgZWw6IEVsZW1lbnRSZWYpIHtcclxuXHRcdC8vXHRjb25zb2xlLmRlYnVnKCdTY3JvbGxJbnRvRGlyZWN0aXZlIGNyZWF0ZWQuJyk7XHJcblx0fVxyXG5cclxuXHRASW5wdXQoKVxyXG5cdHNjcm9sbEludG86IGJvb2xlYW4gPSBmYWxzZTtcclxuXHJcblx0bmdBZnRlclZpZXdJbml0KCkge1xyXG5cdFx0aWYgKHRoaXMuc2Nyb2xsSW50bykge1xyXG5cdFx0XHR0aGlzLmVsLm5hdGl2ZUVsZW1lbnQuc2Nyb2xsSW50b1ZpZXcoKTtcclxuXHRcdH1cclxuXHR9XHJcbn1cclxuIl19
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated bundle index. Do not edit.
|
|
3
|
+
*/
|
|
4
|
+
export * from './public-api';
|
|
5
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibm1jZS1kaXJlY3RpdmVzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vcHJvamVjdHMvbm1jZS1kaXJlY3RpdmVzL3NyYy9ubWNlLWRpcmVjdGl2ZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7O0dBRUc7QUFFSCxjQUFjLGNBQWMsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogR2VuZXJhdGVkIGJ1bmRsZSBpbmRleC4gRG8gbm90IGVkaXQuXG4gKi9cblxuZXhwb3J0ICogZnJvbSAnLi9wdWJsaWMtYXBpJztcbiJdfQ==
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Public API Surface of nmce-directives
|
|
3
|
+
*/
|
|
4
|
+
export * from './_directives/index';
|
|
5
|
+
export * from './_directives/directives.module';
|
|
6
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljLWFwaS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3Byb2plY3RzL25tY2UtZGlyZWN0aXZlcy9zcmMvcHVibGljLWFwaS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7R0FFRztBQUVILGNBQWMscUJBQXFCLENBQUM7QUFDcEMsY0FBYyxpQ0FBaUMsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qXG4gKiBQdWJsaWMgQVBJIFN1cmZhY2Ugb2Ygbm1jZS1kaXJlY3RpdmVzXG4gKi9cblxuZXhwb3J0ICogZnJvbSAnLi9fZGlyZWN0aXZlcy9pbmRleCc7XG5leHBvcnQgKiBmcm9tICcuL19kaXJlY3RpdmVzL2RpcmVjdGl2ZXMubW9kdWxlJztcblxuIl19
|
|
@@ -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;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|
|
@@ -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,CAAC,SAAkB;QACxC,IAAI,CAAC,OAAO,GAAG,SAAS,KAAK,KAAK,CAAC;KACnC;;+GA1BW,kBAAkB;mGAAlB,kBAAkB;2FAAlB,kBAAkB;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Ac,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;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nmce-directives",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
|
+
"author": {
|
|
5
|
+
"name": "Z"
|
|
6
|
+
},
|
|
7
|
+
"description": "Common simple Angular directives used in business applications.",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"repository": {
|
|
10
|
+
"url": "https://github.com/zijianhuang/nmce"
|
|
11
|
+
},
|
|
4
12
|
"peerDependencies": {
|
|
5
|
-
"@angular/common": "^
|
|
6
|
-
"@angular/core": "^
|
|
13
|
+
"@angular/common": "^13.1.1",
|
|
14
|
+
"@angular/core": "^13.1.1"
|
|
7
15
|
},
|
|
8
16
|
"dependencies": {
|
|
9
|
-
"tslib": "^2.
|
|
10
|
-
}
|
|
17
|
+
"tslib": "^2.3.1"
|
|
18
|
+
},
|
|
19
|
+
"module": "fesm2015/nmce-directives.mjs",
|
|
20
|
+
"es2020": "fesm2020/nmce-directives.mjs",
|
|
21
|
+
"esm2020": "esm2020/nmce-directives.mjs",
|
|
22
|
+
"fesm2020": "fesm2020/nmce-directives.mjs",
|
|
23
|
+
"fesm2015": "fesm2015/nmce-directives.mjs",
|
|
24
|
+
"typings": "nmce-directives.d.ts",
|
|
25
|
+
"exports": {
|
|
26
|
+
"./package.json": {
|
|
27
|
+
"default": "./package.json"
|
|
28
|
+
},
|
|
29
|
+
".": {
|
|
30
|
+
"types": "./nmce-directives.d.ts",
|
|
31
|
+
"esm2020": "./esm2020/nmce-directives.mjs",
|
|
32
|
+
"es2020": "./fesm2020/nmce-directives.mjs",
|
|
33
|
+
"es2015": "./fesm2015/nmce-directives.mjs",
|
|
34
|
+
"node": "./fesm2015/nmce-directives.mjs",
|
|
35
|
+
"default": "./fesm2020/nmce-directives.mjs"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"sideEffects": false
|
|
11
39
|
}
|
package/karma.conf.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
// Karma configuration file, see link for more information
|
|
2
|
-
// https://karma-runner.github.io/1.0/config/configuration-file.html
|
|
3
|
-
|
|
4
|
-
module.exports = function (config) {
|
|
5
|
-
config.set({
|
|
6
|
-
basePath: '',
|
|
7
|
-
frameworks: ['jasmine', '@angular-devkit/build-angular'],
|
|
8
|
-
plugins: [
|
|
9
|
-
require('karma-jasmine'),
|
|
10
|
-
require('karma-chrome-launcher'),
|
|
11
|
-
require('karma-jasmine-html-reporter'),
|
|
12
|
-
require('karma-coverage'),
|
|
13
|
-
require('@angular-devkit/build-angular/plugins/karma')
|
|
14
|
-
],
|
|
15
|
-
client: {
|
|
16
|
-
jasmine: {
|
|
17
|
-
// you can add configuration options for Jasmine here
|
|
18
|
-
// the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
|
|
19
|
-
// for example, you can disable the random execution with `random: false`
|
|
20
|
-
// or set a specific seed with `seed: 4321`
|
|
21
|
-
},
|
|
22
|
-
clearContext: false // leave Jasmine Spec Runner output visible in browser
|
|
23
|
-
},
|
|
24
|
-
jasmineHtmlReporter: {
|
|
25
|
-
suppressAll: true // removes the duplicated traces
|
|
26
|
-
},
|
|
27
|
-
coverageReporter: {
|
|
28
|
-
dir: require('path').join(__dirname, '../../coverage/nmce-directives'),
|
|
29
|
-
subdir: '.',
|
|
30
|
-
reporters: [
|
|
31
|
-
{ type: 'html' },
|
|
32
|
-
{ type: 'text-summary' }
|
|
33
|
-
]
|
|
34
|
-
},
|
|
35
|
-
reporters: ['progress', 'kjhtml'],
|
|
36
|
-
port: 9876,
|
|
37
|
-
colors: true,
|
|
38
|
-
logLevel: config.LOG_INFO,
|
|
39
|
-
autoWatch: true,
|
|
40
|
-
browsers: ['Chrome'],
|
|
41
|
-
singleRun: false,
|
|
42
|
-
restartOnFileChange: true
|
|
43
|
-
});
|
|
44
|
-
};
|
package/ng-package.json
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { Directive, AfterViewInit, ElementRef, DoCheck, Input } from '@angular/core';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
// Simple example directive that fixes autofocus problem with multiple views, source: https://www.picnet.com.au/blogs/guido/post/2016/09/20/angular2-ng2-focus-directive/
|
|
5
|
-
@Directive({
|
|
6
|
-
selector: '[autofocus]' // using [ ] means selecting attributes
|
|
7
|
-
})
|
|
8
|
-
|
|
9
|
-
export class AutofocusDirective implements AfterViewInit, DoCheck {
|
|
10
|
-
private lastVisible = false;
|
|
11
|
-
private initialised = false;
|
|
12
|
-
constructor(private el: ElementRef) {
|
|
13
|
-
console.debug('autofocusDirective created.');
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
ngAfterViewInit() {
|
|
17
|
-
this.initialised = true;
|
|
18
|
-
this.ngDoCheck();
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
ngDoCheck() {
|
|
22
|
-
if (!this.initialised) { return; }
|
|
23
|
-
const visible = !!this.el.nativeElement.offsetParent;
|
|
24
|
-
if (visible && !this.lastVisible) {
|
|
25
|
-
setTimeout(() => { this.el.nativeElement.focus(); }, 2); //no need to clearTimeout
|
|
26
|
-
}
|
|
27
|
-
this.lastVisible = visible;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
@Input() set autofocus(condition: boolean) {
|
|
31
|
-
this.lastVisible = condition !== false;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { Directive, HostListener, ElementRef, OnInit } from '@angular/core';
|
|
2
|
-
import { CurrencyFunc } from 'nmce-func';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
*
|
|
6
|
-
*/
|
|
7
|
-
@Directive({ selector: '[currencyFormatter]' })//inspired by https://blog.ngconsultant.io/custom-input-formatting-with-simple-directives-for-angular-2-ec792082976
|
|
8
|
-
export class CurrencyFormatterDirective implements OnInit {
|
|
9
|
-
|
|
10
|
-
private el: HTMLInputElement;
|
|
11
|
-
|
|
12
|
-
constructor(private elementRef: ElementRef) {
|
|
13
|
-
this.el = this.elementRef.nativeElement;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
ngOnInit() {
|
|
17
|
-
this.el.value = CurrencyFunc.transformCurrency(this.el.value);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
@HostListener('focus', ['$event.target.value'])
|
|
21
|
-
onFocus(value: string) {
|
|
22
|
-
this.el.value = CurrencyFunc.parseCurrency(value); // opossite of transform
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
@HostListener('blur', ['$event.target.value'])
|
|
26
|
-
onBlur(value: string) {
|
|
27
|
-
this.el.value = CurrencyFunc.transformCurrency(value);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { Directive, HostListener, ElementRef, OnInit } from '@angular/core';
|
|
2
|
-
import moment from 'moment';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
*
|
|
6
|
-
*/
|
|
7
|
-
@Directive({ selector: '[datetimeFormatter]' })//inspired by https://blog.ngconsultant.io/custom-input-formatting-with-simple-directives-for-angular-2-ec792082976
|
|
8
|
-
export class DatetimeFormatterDirective implements OnInit {
|
|
9
|
-
|
|
10
|
-
private el: HTMLInputElement;
|
|
11
|
-
|
|
12
|
-
//@Input('datetimeFormatter')
|
|
13
|
-
format = 'DD/MM/YYYY HH:mm';
|
|
14
|
-
|
|
15
|
-
formats = ['', 'DD/MM/YYYY HH:mm'];
|
|
16
|
-
|
|
17
|
-
constructor(private elementRef: ElementRef) {
|
|
18
|
-
this.el = this.elementRef.nativeElement;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
ngOnInit() {
|
|
22
|
-
const s = this.parse(this.el.value);
|
|
23
|
-
this.el.value = this.transform(s);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
@HostListener('focus', ['$event.target.value'])
|
|
27
|
-
onFocus() {
|
|
28
|
-
const s = this.parse(this.el.value);
|
|
29
|
-
this.el.value = this.transform(s);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
@HostListener('blur', ['$event.target.value'])
|
|
33
|
-
onBlur() {
|
|
34
|
-
this.el.value = this.transform(this.el.value);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
transform(value: Date | string | null): string {
|
|
38
|
-
if (!value) {
|
|
39
|
-
return '';
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const s = moment(value).format(this.format);
|
|
43
|
-
console.debug(`With format ${this.format} transform to ${s}`);
|
|
44
|
-
return s;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
parse(value: string): Date | null {
|
|
48
|
-
if (!value) {
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const d = moment(value, this.formats).toDate();
|
|
53
|
-
console.debug(`parse ${value} to ${d}`);
|
|
54
|
-
return d;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { NgModule } from '@angular/core';
|
|
2
|
-
import { CommonModule } from '@angular/common';
|
|
3
|
-
import { FormsModule } from '@angular/forms';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
AutofocusDirective, HighlightDirective, CurrencyFormatterDirective, DatetimeFormatterDirective, ScrollIntoDirective, DataComponentDirective,
|
|
8
|
-
} from './index';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* 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.
|
|
12
|
-
*
|
|
13
|
-
*/
|
|
14
|
-
@NgModule({
|
|
15
|
-
imports: [
|
|
16
|
-
CommonModule,
|
|
17
|
-
FormsModule,
|
|
18
|
-
],
|
|
19
|
-
|
|
20
|
-
declarations: [
|
|
21
|
-
AutofocusDirective,
|
|
22
|
-
HighlightDirective,
|
|
23
|
-
CurrencyFormatterDirective,
|
|
24
|
-
DatetimeFormatterDirective,
|
|
25
|
-
ScrollIntoDirective,
|
|
26
|
-
DataComponentDirective,
|
|
27
|
-
],
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
exports: [
|
|
31
|
-
AutofocusDirective,
|
|
32
|
-
HighlightDirective,
|
|
33
|
-
CurrencyFormatterDirective,
|
|
34
|
-
DatetimeFormatterDirective,
|
|
35
|
-
ScrollIntoDirective,
|
|
36
|
-
DataComponentDirective,
|
|
37
|
-
]
|
|
38
|
-
})
|
|
39
|
-
export class NmceDirectivesModule { }
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Directive, ElementRef, HostListener, Input } from '@angular/core';
|
|
2
|
-
@Directive({
|
|
3
|
-
selector: '[myHighlight]'
|
|
4
|
-
})
|
|
5
|
-
export class HighlightDirective {
|
|
6
|
-
constructor(private el: ElementRef) {
|
|
7
|
-
console.debug('HighlightDirective created.');
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
@Input() defaultColor?: string;
|
|
11
|
-
@Input('myHighlight') highlightColor?: string;
|
|
12
|
-
@HostListener('mouseenter') onMouseEnter() {
|
|
13
|
-
this.highlight(this.highlightColor || this.defaultColor || 'red');
|
|
14
|
-
}
|
|
15
|
-
@HostListener('mouseleave') onMouseLeave() {
|
|
16
|
-
this.highlight(undefined);
|
|
17
|
-
}
|
|
18
|
-
private highlight(color: string | undefined) {
|
|
19
|
-
this.el.nativeElement.style.backgroundColor = color;
|
|
20
|
-
}
|
|
21
|
-
}
|
package/src/_directives/index.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { AfterViewInit, Directive, ElementRef, Input } from '@angular/core';
|
|
2
|
-
@Directive({
|
|
3
|
-
selector: '[scrollInto]'
|
|
4
|
-
})
|
|
5
|
-
export class ScrollIntoDirective implements AfterViewInit {
|
|
6
|
-
constructor(private el: ElementRef) {
|
|
7
|
-
// console.debug('ScrollIntoDirective created.');
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
@Input()
|
|
11
|
-
scrollInto: boolean = false;
|
|
12
|
-
|
|
13
|
-
ngAfterViewInit() {
|
|
14
|
-
if (this.scrollInto) {
|
|
15
|
-
this.el.nativeElement.scrollIntoView();
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
package/src/test.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
|
|
2
|
-
|
|
3
|
-
import 'zone.js/dist/zone';
|
|
4
|
-
import 'zone.js/dist/zone-testing';
|
|
5
|
-
import { getTestBed } from '@angular/core/testing';
|
|
6
|
-
import {
|
|
7
|
-
BrowserDynamicTestingModule,
|
|
8
|
-
platformBrowserDynamicTesting
|
|
9
|
-
} from '@angular/platform-browser-dynamic/testing';
|
|
10
|
-
|
|
11
|
-
declare const require: {
|
|
12
|
-
context(path: string, deep?: boolean, filter?: RegExp): {
|
|
13
|
-
keys(): string[];
|
|
14
|
-
<T>(id: string): T;
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
// First, initialize the Angular testing environment.
|
|
19
|
-
getTestBed().initTestEnvironment(
|
|
20
|
-
BrowserDynamicTestingModule,
|
|
21
|
-
platformBrowserDynamicTesting()
|
|
22
|
-
);
|
|
23
|
-
// Then we find all the tests.
|
|
24
|
-
const context = require.context('./', true, /\.spec\.ts$/);
|
|
25
|
-
// And load the modules.
|
|
26
|
-
context.keys().map(context);
|
package/tsconfig.lib.json
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/* To learn more about this file see: https://angular.io/config/tsconfig. */
|
|
2
|
-
{
|
|
3
|
-
"extends": "../../tsconfig.json",
|
|
4
|
-
"compilerOptions": {
|
|
5
|
-
"outDir": "../../out-tsc/lib",
|
|
6
|
-
"target": "es2015",
|
|
7
|
-
"declaration": true,
|
|
8
|
-
"declarationMap": true,
|
|
9
|
-
"inlineSources": true,
|
|
10
|
-
"types": [],
|
|
11
|
-
"lib": [
|
|
12
|
-
"dom",
|
|
13
|
-
"es2018"
|
|
14
|
-
]
|
|
15
|
-
},
|
|
16
|
-
"angularCompilerOptions": {
|
|
17
|
-
"skipTemplateCodegen": true,
|
|
18
|
-
"strictMetadataEmit": true,
|
|
19
|
-
"enableResourceInlining": true
|
|
20
|
-
},
|
|
21
|
-
"exclude": [
|
|
22
|
-
"src/test.ts",
|
|
23
|
-
"**/*.spec.ts"
|
|
24
|
-
]
|
|
25
|
-
}
|
package/tsconfig.lib.prod.json
DELETED
package/tsconfig.spec.json
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/* To learn more about this file see: https://angular.io/config/tsconfig. */
|
|
2
|
-
{
|
|
3
|
-
"extends": "../../tsconfig.json",
|
|
4
|
-
"compilerOptions": {
|
|
5
|
-
"outDir": "../../out-tsc/spec",
|
|
6
|
-
"types": [
|
|
7
|
-
"jasmine"
|
|
8
|
-
]
|
|
9
|
-
},
|
|
10
|
-
"files": [
|
|
11
|
-
"src/test.ts"
|
|
12
|
-
],
|
|
13
|
-
"include": [
|
|
14
|
-
"**/*.spec.ts",
|
|
15
|
-
"**/*.d.ts"
|
|
16
|
-
]
|
|
17
|
-
}
|