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.
- package/_directives/autofocus.d.ts +3 -0
- package/_directives/currencyFormatter.directive.d.ts +3 -0
- package/_directives/dataComponent.directive.d.ts +3 -0
- package/_directives/directives.module.d.ts +10 -0
- package/_directives/scrollInto.directive.d.ts +3 -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/{esm2015/_directives/index.js → esm2020/_directives/index.mjs} +0 -0
- package/esm2020/_directives/scrollInto.directive.mjs +28 -0
- package/{esm2015/nmce-directives.js → esm2020/nmce-directives.mjs} +0 -0
- package/{esm2015/public-api.js → esm2020/public-api.mjs} +0 -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 +1 -0
- package/package.json +22 -10
- package/bundles/nmce-directives.umd.js +0 -179
- package/bundles/nmce-directives.umd.js.map +0 -1
- package/bundles/nmce-directives.umd.min.js +0 -2
- package/bundles/nmce-directives.umd.min.js.map +0 -1
- package/esm2015/_directives/autofocus.js +0 -46
- package/esm2015/_directives/currencyFormatter.directive.js +0 -33
- package/esm2015/_directives/dataComponent.directive.js +0 -15
- package/esm2015/_directives/directives.module.js +0 -31
- package/esm2015/_directives/scrollInto.directive.js +0 -28
- package/fesm2015/nmce-directives.js +0 -159
- package/fesm2015/nmce-directives.js.map +0 -1
- package/nmce-directives.metadata.json +0 -1
|
@@ -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;kBAH9B,SAA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AC;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/nmce-directives.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nmce-directives",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "Z"
|
|
6
6
|
},
|
|
@@ -10,18 +10,30 @@
|
|
|
10
10
|
"url": "https://github.com/zijianhuang/nmce"
|
|
11
11
|
},
|
|
12
12
|
"peerDependencies": {
|
|
13
|
-
"@angular/common": "^
|
|
14
|
-
"@angular/core": "^
|
|
13
|
+
"@angular/common": "^13.1.1",
|
|
14
|
+
"@angular/core": "^13.1.1"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"tslib": "^2.
|
|
17
|
+
"tslib": "^2.3.1"
|
|
18
18
|
},
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"fesm2015": "fesm2015/nmce-directives.
|
|
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
24
|
"typings": "nmce-directives.d.ts",
|
|
25
|
-
"
|
|
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
|
+
},
|
|
26
38
|
"sideEffects": false
|
|
27
39
|
}
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('nmce-func'), require('@angular/common'), require('@angular/forms')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define('nmce-directives', ['exports', '@angular/core', 'nmce-func', '@angular/common', '@angular/forms'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global['nmce-directives'] = {}, global.ng.core, global['nmce-func'], global.ng.common, global.ng.forms));
|
|
5
|
-
}(this, (function (exports, core, nmceFunc, common, forms) { 'use strict';
|
|
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
|
-
var AutofocusDirective = /** @class */ (function () {
|
|
13
|
-
function AutofocusDirective(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
|
-
AutofocusDirective.prototype.ngAfterViewInit = function () {
|
|
22
|
-
this.initialised = true;
|
|
23
|
-
this.ngDoCheck();
|
|
24
|
-
};
|
|
25
|
-
AutofocusDirective.prototype.ngDoCheck = function () {
|
|
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
|
-
Object.defineProperty(AutofocusDirective.prototype, "autofocus", {
|
|
37
|
-
set: function (condition) {
|
|
38
|
-
this.toFocus = condition !== false;
|
|
39
|
-
},
|
|
40
|
-
enumerable: false,
|
|
41
|
-
configurable: true
|
|
42
|
-
});
|
|
43
|
-
return AutofocusDirective;
|
|
44
|
-
}());
|
|
45
|
-
AutofocusDirective.decorators = [
|
|
46
|
-
{ type: core.Directive, args: [{
|
|
47
|
-
selector: '[autofocus]'
|
|
48
|
-
},] }
|
|
49
|
-
];
|
|
50
|
-
AutofocusDirective.ctorParameters = function () { return [
|
|
51
|
-
{ type: core.ElementRef }
|
|
52
|
-
]; };
|
|
53
|
-
AutofocusDirective.propDecorators = {
|
|
54
|
-
autofocus: [{ type: core.Input }]
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Decorate HTML input for inputing and displaying currency. The input type must not be number and should be text only.
|
|
59
|
-
* If the input type is number, the built-in validator will be fighting against this directive.
|
|
60
|
-
*/
|
|
61
|
-
var CurrencyFormatterDirective = /** @class */ (function () {
|
|
62
|
-
function CurrencyFormatterDirective(elementRef) {
|
|
63
|
-
this.elementRef = elementRef;
|
|
64
|
-
this.el = this.elementRef.nativeElement;
|
|
65
|
-
}
|
|
66
|
-
CurrencyFormatterDirective.prototype.ngOnInit = function () {
|
|
67
|
-
this.el.value = nmceFunc.CurrencyFunc.transformCurrency(this.el.value);
|
|
68
|
-
};
|
|
69
|
-
CurrencyFormatterDirective.prototype.onFocus = function (value) {
|
|
70
|
-
this.el.value = nmceFunc.CurrencyFunc.parseCurrency(value); // opossite of transform
|
|
71
|
-
};
|
|
72
|
-
CurrencyFormatterDirective.prototype.onBlur = function (value) {
|
|
73
|
-
this.el.value = nmceFunc.CurrencyFunc.transformCurrency(value);
|
|
74
|
-
};
|
|
75
|
-
return CurrencyFormatterDirective;
|
|
76
|
-
}());
|
|
77
|
-
CurrencyFormatterDirective.decorators = [
|
|
78
|
-
{ type: core.Directive, args: [{ selector: '[currencyFormatter]' }, //inspired by https://blog.ngconsultant.io/custom-input-formatting-with-simple-directives-for-angular-2-ec792082976
|
|
79
|
-
] }
|
|
80
|
-
];
|
|
81
|
-
CurrencyFormatterDirective.ctorParameters = function () { return [
|
|
82
|
-
{ type: core.ElementRef }
|
|
83
|
-
]; };
|
|
84
|
-
CurrencyFormatterDirective.propDecorators = {
|
|
85
|
-
onFocus: [{ type: core.HostListener, args: ['focus', ['$event.target.value'],] }],
|
|
86
|
-
onBlur: [{ type: core.HostListener, args: ['blur', ['$event.target.value'],] }]
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
var DataComponentDirective = /** @class */ (function () {
|
|
90
|
-
function DataComponentDirective(viewContainerRef) {
|
|
91
|
-
this.viewContainerRef = viewContainerRef;
|
|
92
|
-
}
|
|
93
|
-
return DataComponentDirective;
|
|
94
|
-
}());
|
|
95
|
-
DataComponentDirective.decorators = [
|
|
96
|
-
{ type: core.Directive, args: [{
|
|
97
|
-
selector: '[dataComponentHost]',
|
|
98
|
-
},] }
|
|
99
|
-
];
|
|
100
|
-
DataComponentDirective.ctorParameters = function () { return [
|
|
101
|
-
{ type: core.ViewContainerRef }
|
|
102
|
-
]; };
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Scroll to element attached. And the element may be an Angular Material component too.
|
|
106
|
-
*/
|
|
107
|
-
var ScrollIntoDirective = /** @class */ (function () {
|
|
108
|
-
function ScrollIntoDirective(el) {
|
|
109
|
-
this.el = el;
|
|
110
|
-
this.scrollInto = false;
|
|
111
|
-
// console.debug('ScrollIntoDirective created.');
|
|
112
|
-
}
|
|
113
|
-
ScrollIntoDirective.prototype.ngAfterViewInit = function () {
|
|
114
|
-
if (this.scrollInto) {
|
|
115
|
-
this.el.nativeElement.scrollIntoView();
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
return ScrollIntoDirective;
|
|
119
|
-
}());
|
|
120
|
-
ScrollIntoDirective.decorators = [
|
|
121
|
-
{ type: core.Directive, args: [{
|
|
122
|
-
selector: '[scrollInto]'
|
|
123
|
-
},] }
|
|
124
|
-
];
|
|
125
|
-
ScrollIntoDirective.ctorParameters = function () { return [
|
|
126
|
-
{ type: core.ElementRef }
|
|
127
|
-
]; };
|
|
128
|
-
ScrollIntoDirective.propDecorators = {
|
|
129
|
-
scrollInto: [{ type: core.Input }]
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* 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.
|
|
134
|
-
*
|
|
135
|
-
*/
|
|
136
|
-
var NmceDirectivesModule = /** @class */ (function () {
|
|
137
|
-
function NmceDirectivesModule() {
|
|
138
|
-
}
|
|
139
|
-
return NmceDirectivesModule;
|
|
140
|
-
}());
|
|
141
|
-
NmceDirectivesModule.decorators = [
|
|
142
|
-
{ type: core.NgModule, args: [{
|
|
143
|
-
imports: [
|
|
144
|
-
common.CommonModule,
|
|
145
|
-
forms.FormsModule,
|
|
146
|
-
],
|
|
147
|
-
declarations: [
|
|
148
|
-
AutofocusDirective,
|
|
149
|
-
CurrencyFormatterDirective,
|
|
150
|
-
ScrollIntoDirective,
|
|
151
|
-
DataComponentDirective,
|
|
152
|
-
],
|
|
153
|
-
exports: [
|
|
154
|
-
AutofocusDirective,
|
|
155
|
-
CurrencyFormatterDirective,
|
|
156
|
-
ScrollIntoDirective,
|
|
157
|
-
DataComponentDirective,
|
|
158
|
-
]
|
|
159
|
-
},] }
|
|
160
|
-
];
|
|
161
|
-
|
|
162
|
-
/*
|
|
163
|
-
* Public API Surface of nmce-directives
|
|
164
|
-
*/
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Generated bundle index. Do not edit.
|
|
168
|
-
*/
|
|
169
|
-
|
|
170
|
-
exports.AutofocusDirective = AutofocusDirective;
|
|
171
|
-
exports.CurrencyFormatterDirective = CurrencyFormatterDirective;
|
|
172
|
-
exports.DataComponentDirective = DataComponentDirective;
|
|
173
|
-
exports.NmceDirectivesModule = NmceDirectivesModule;
|
|
174
|
-
exports.ScrollIntoDirective = ScrollIntoDirective;
|
|
175
|
-
|
|
176
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
177
|
-
|
|
178
|
-
})));
|
|
179
|
-
//# sourceMappingURL=nmce-directives.umd.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nmce-directives.umd.js","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":["Directive","ElementRef","Input","CurrencyFunc","HostListener","ViewContainerRef","NgModule","CommonModule","FormsModule"],"mappings":";;;;;;IAEA;;;;;;QAaC,4BAAoB,EAAc;YAAd,OAAE,GAAF,EAAE,CAAY;YAJ1B,YAAO,GAAG,KAAK,CAAC;YAChB,YAAO,GAAG,KAAK,CAAC;YAChB,gBAAW,GAAG,KAAK,CAAC;YACpB,gBAAW,GAAG,KAAK,CAAC;;SAG3B;QAED,4CAAe,GAAf;YACC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;YACxB,IAAI,CAAC,SAAS,EAAE,CAAC;SACjB;QAED,sCAAS,GAAT;YACC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;gBAAE,OAAO;aAAE;YAClC,IAAI,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;gBACvD,IAAI,CAAC,EAAE,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;gBAC9B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;gBACpB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;gBACxB,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;aAC9B;SACD;QAED,sBAAa,yCAAS;iBAAtB,UAAuB,SAAkB;gBACxC,IAAI,CAAC,OAAO,GAAG,SAAS,KAAK,KAAK,CAAC;aACnC;;;WAAA;;;;gBA7BDA,cAAS,SAAC;oBACV,QAAQ,EAAE,aAAa;iBACvB;;;gBAT2CC,eAAU;;;4BAkCpDC,UAAK;;;IC/BP;;;;;QASC,oCAAoB,UAAsB;YAAtB,eAAU,GAA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C,iBAAW;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;;;ICjCD;;;;ICAA;;;;;;;;;;;;;;;;"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("nmce-func"),require("@angular/common"),require("@angular/forms")):"function"==typeof define&&define.amd?define("nmce-directives",["exports","@angular/core","nmce-func","@angular/common","@angular/forms"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["nmce-directives"]={},e.ng.core,e["nmce-func"],e.ng.common,e.ng.forms)}(this,(function(e,t,o,r,n){"use strict";var i=function(){function e(e){this.el=e,this.toFocus=!1,this.focused=!1,this.initialised=!1,this.everFocused=!1}return e.prototype.ngAfterViewInit=function(){this.initialised=!0,this.ngDoCheck()},e.prototype.ngDoCheck=function(){this.initialised&&(!this.toFocus||this.everFocused||this.focused||(this.el.nativeElement.focus(),this.focused=!0,this.everFocused=!0,console.debug("focused now.")))},Object.defineProperty(e.prototype,"autofocus",{set:function(e){this.toFocus=!1!==e},enumerable:!1,configurable:!0}),e}();i.decorators=[{type:t.Directive,args:[{selector:"[autofocus]"}]}],i.ctorParameters=function(){return[{type:t.ElementRef}]},i.propDecorators={autofocus:[{type:t.Input}]};var c=function(){function e(e){this.elementRef=e,this.el=this.elementRef.nativeElement}return e.prototype.ngOnInit=function(){this.el.value=o.CurrencyFunc.transformCurrency(this.el.value)},e.prototype.onFocus=function(e){this.el.value=o.CurrencyFunc.parseCurrency(e)},e.prototype.onBlur=function(e){this.el.value=o.CurrencyFunc.transformCurrency(e)},e}();c.decorators=[{type:t.Directive,args:[{selector:"[currencyFormatter]"}]}],c.ctorParameters=function(){return[{type:t.ElementRef}]},c.propDecorators={onFocus:[{type:t.HostListener,args:["focus",["$event.target.value"]]}],onBlur:[{type:t.HostListener,args:["blur",["$event.target.value"]]}]};var s=function(e){this.viewContainerRef=e};s.decorators=[{type:t.Directive,args:[{selector:"[dataComponentHost]"}]}],s.ctorParameters=function(){return[{type:t.ViewContainerRef}]};var u=function(){function e(e){this.el=e,this.scrollInto=!1}return e.prototype.ngAfterViewInit=function(){this.scrollInto&&this.el.nativeElement.scrollIntoView()},e}();u.decorators=[{type:t.Directive,args:[{selector:"[scrollInto]"}]}],u.ctorParameters=function(){return[{type:t.ElementRef}]},u.propDecorators={scrollInto:[{type:t.Input}]};var a=function(){};a.decorators=[{type:t.NgModule,args:[{imports:[r.CommonModule,n.FormsModule],declarations:[i,c,u,s],exports:[i,c,u,s]}]}],e.AutofocusDirective=i,e.CurrencyFormatterDirective=c,e.DataComponentDirective=s,e.NmceDirectivesModule=a,e.ScrollIntoDirective=u,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
2
|
-
//# sourceMappingURL=nmce-directives.umd.min.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"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"],"names":["AutofocusDirective","el","this","toFocus","focused","initialised","everFocused","prototype","ngAfterViewInit","ngDoCheck","nativeElement","focus","console","debug","Object","defineProperty","condition","Directive","args","selector","ElementRef","Input","CurrencyFormatterDirective","elementRef","ngOnInit","value","CurrencyFunc","transformCurrency","onFocus","parseCurrency","onBlur","HostListener","viewContainerRef","ViewContainerRef","ScrollIntoDirective","scrollInto","scrollIntoView","NgModule","imports","CommonModule","FormsModule","declarations","DataComponentDirective","exports"],"mappings":"ufAeC,SAAAA,EAAoBC,GAAAC,KAAAD,GAAAA,EAJZC,KAA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RjC,KAAKD,GAAGS,cAAc0B,2CAbxBnB,EAAAA,UAASC,KAAA,CAAC,CACVC,SAAU,4DANwBC,EAAAA,kDAajCC,EAAAA,eCqBF,iCArBCgB,EAAAA,SAAQnB,KAAA,CAAC,CACToB,QAAS,CACRC,EAAAA,aACAC,EAAAA,aAGDC,aAAc,CACbzC,EACAsB,EACAY,EACAQ,GAIDC,QAAS,CACR3C,EACAsB,EACAY,EACAQ","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"]}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { Directive, ElementRef, Input } from '@angular/core';
|
|
2
|
-
/**
|
|
3
|
-
* Use as a parametered input parameter in html element.
|
|
4
|
-
* When used inside a material dialog, this directive may be at odd against the autofocus config parameter of MatDialogConfig,
|
|
5
|
-
* if the autofocus config is not false. Generally speaking, no need to use this directive in a component presented in a mateiral dialog.
|
|
6
|
-
*/
|
|
7
|
-
export class AutofocusDirective {
|
|
8
|
-
constructor(el) {
|
|
9
|
-
this.el = el;
|
|
10
|
-
this.toFocus = false;
|
|
11
|
-
this.focused = false;
|
|
12
|
-
this.initialised = false;
|
|
13
|
-
this.everFocused = false;
|
|
14
|
-
//console.debug('autofocusDirective created.');
|
|
15
|
-
}
|
|
16
|
-
ngAfterViewInit() {
|
|
17
|
-
this.initialised = true;
|
|
18
|
-
this.ngDoCheck();
|
|
19
|
-
}
|
|
20
|
-
ngDoCheck() {
|
|
21
|
-
if (!this.initialised) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
if (this.toFocus && !this.everFocused && !this.focused) {
|
|
25
|
-
this.el.nativeElement.focus();
|
|
26
|
-
this.focused = true;
|
|
27
|
-
this.everFocused = true;
|
|
28
|
-
console.debug('focused now.');
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
set autofocus(condition) {
|
|
32
|
-
this.toFocus = condition !== false;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
AutofocusDirective.decorators = [
|
|
36
|
-
{ type: Directive, args: [{
|
|
37
|
-
selector: '[autofocus]'
|
|
38
|
-
},] }
|
|
39
|
-
];
|
|
40
|
-
AutofocusDirective.ctorParameters = () => [
|
|
41
|
-
{ type: ElementRef }
|
|
42
|
-
];
|
|
43
|
-
AutofocusDirective.propDecorators = {
|
|
44
|
-
autofocus: [{ type: Input }]
|
|
45
|
-
};
|
|
46
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXV0b2ZvY3VzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vcHJvamVjdHMvbm1jZS1kaXJlY3RpdmVzL3NyYy9fZGlyZWN0aXZlcy9hdXRvZm9jdXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFpQixTQUFTLEVBQVcsVUFBVSxFQUFFLEtBQUssRUFBRSxNQUFNLGVBQWUsQ0FBQztBQUVyRjs7OztHQUlHO0FBSUgsTUFBTSxPQUFPLGtCQUFrQjtJQUs5QixZQUFvQixFQUFjO1FBQWQsT0FBRSxHQUFGLEVBQUUsQ0FBWTtRQUoxQixZQUFPLEdBQUcsS0FBSyxDQUFDO1FBQ2hCLFlBQU8sR0FBRyxLQUFLLENBQUM7UUFDaEIsZ0JBQVcsR0FBRyxLQUFLLENBQUM7UUFDcEIsZ0JBQVcsR0FBRyxLQUFLLENBQUM7UUFFM0IsK0NBQStDO0lBQ2hELENBQUM7SUFFRCxlQUFlO1FBQ2QsSUFBSSxDQUFDLFdBQVcsR0FBRyxJQUFJLENBQUM7UUFDeEIsSUFBSSxDQUFDLFNBQVMsRUFBRSxDQUFDO0lBQ2xCLENBQUM7SUFFRCxTQUFTO1FBQ1IsSUFBSSxDQUFDLElBQUksQ0FBQyxXQUFXLEVBQUU7WUFBRSxPQUFPO1NBQUU7U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LicpO1xyXG5cdFx0fVxyXG5cdH1cclxuXHJcblx0QElucHV0KCkgc2V0IGF1dG9mb2N1cyhjb25kaXRpb246IGJvb2xlYW4pIHtcclxuXHRcdHRoaXMudG9Gb2N1cyA9IGNvbmRpdGlvbiAhPT0gZmFsc2U7XHJcblx0fVxyXG59XHJcbiJdfQ==
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { Directive, ElementRef, HostListener } from '@angular/core';
|
|
2
|
-
import { CurrencyFunc } from 'nmce-func';
|
|
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 class CurrencyFormatterDirective {
|
|
8
|
-
constructor(elementRef) {
|
|
9
|
-
this.elementRef = elementRef;
|
|
10
|
-
this.el = this.elementRef.nativeElement;
|
|
11
|
-
}
|
|
12
|
-
ngOnInit() {
|
|
13
|
-
this.el.value = CurrencyFunc.transformCurrency(this.el.value);
|
|
14
|
-
}
|
|
15
|
-
onFocus(value) {
|
|
16
|
-
this.el.value = CurrencyFunc.parseCurrency(value); // opossite of transform
|
|
17
|
-
}
|
|
18
|
-
onBlur(value) {
|
|
19
|
-
this.el.value = CurrencyFunc.transformCurrency(value);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
CurrencyFormatterDirective.decorators = [
|
|
23
|
-
{ type: Directive, args: [{ selector: '[currencyFormatter]' }, //inspired by https://blog.ngconsultant.io/custom-input-formatting-with-simple-directives-for-angular-2-ec792082976
|
|
24
|
-
] }
|
|
25
|
-
];
|
|
26
|
-
CurrencyFormatterDirective.ctorParameters = () => [
|
|
27
|
-
{ type: ElementRef }
|
|
28
|
-
];
|
|
29
|
-
CurrencyFormatterDirective.propDecorators = {
|
|
30
|
-
onFocus: [{ type: HostListener, args: ['focus', ['$event.target.value'],] }],
|
|
31
|
-
onBlur: [{ type: HostListener, args: ['blur', ['$event.target.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ge1xyXG5cclxuXHRwcml2YXRlIGVsOiBIVE1MSW5wdXRFbGVtZW50O1xyXG5cclxuXHRjb25zdHJ1Y3Rvcihwcml2YXRlIGVsZW1lbnRSZWY6IEVsZW1lbnRSZWYpIHtcclxuXHRcdHRoaXMuZWwgPSB0aGlzLmVsZW1lbnRSZWYubmF0aXZlRWxlbWVudDtcclxuXHR9XHJcblxyXG5cdG5nT25Jbml0KCkge1xyXG5cdFx0dGhpcy5lbC52YWx1ZSA9IEN1cnJlbmN5RnVuYy50cmFuc2Zvcm1DdXJyZW5jeSh0aGlzLmVsLnZhbHVlKTtcclxuXHR9XHJcblxyXG5cdEBIb3N0TGlzdGVuZXIoJ2ZvY3VzJywgWyckZXZlbnQudGFyZ2V0LnZhbHVlJ10pXHJcblx0b25Gb2N1cyh2YWx1ZTogc3RyaW5nKSB7XHJcblx0XHR0aGlzLmVsLnZhbHVlID0gQ3VycmVuY3lGdW5jLnBhcnNlQ3VycmVuY3kodmFsdWUpOyAvLyBvcG9zc2l0ZSBvZiB0cmFuc2Zvcm1cclxuXHR9XHJcblxyXG5cdEBIb3N0TGlzdGVuZXIoJ2JsdXInLCBbJyRldmVudC50YXJnZXQudmFsdWUnXSlcclxuXHRvbkJsdXIodmFsdWU6IHN0cmluZykge1xyXG5cdFx0dGhpcy5lbC52YWx1ZSA9IEN1cnJlbmN5RnVuYy50cmFuc2Zvcm1DdXJyZW5jeSh2YWx1ZSk7XHJcblx0fVxyXG5cclxufVxyXG5cclxuIl19
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Directive, ViewContainerRef } from '@angular/core';
|
|
2
|
-
export class DataComponentDirective {
|
|
3
|
-
constructor(viewContainerRef) {
|
|
4
|
-
this.viewContainerRef = viewContainerRef;
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
|
-
DataComponentDirective.decorators = [
|
|
8
|
-
{ type: Directive, args: [{
|
|
9
|
-
selector: '[dataComponentHost]',
|
|
10
|
-
},] }
|
|
11
|
-
];
|
|
12
|
-
DataComponentDirective.ctorParameters = () => [
|
|
13
|
-
{ type: ViewContainerRef }
|
|
14
|
-
];
|
|
15
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGF0YUNvbXBvbmVudC5kaXJlY3RpdmUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9wcm9qZWN0cy9ubWNlLWRpcmVjdGl2ZXMvc3JjL19kaXJlY3RpdmVzL2RhdGFDb21wb25lbnQuZGlyZWN0aXZlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxTQUFTLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSxlQUFlLENBQUM7QUFLNUQsTUFBTSxPQUFPLHNCQUFzQjtJQUNsQyxZQUFtQixnQkFBa0M7UUFBbEMscUJBQWdCLEdBQWhCLGdCQUFnQixDQUFrQjtJQUFJLENBQUM7OztZQUoxRCxTQUFTLFNBQUM7Z0JBQ1YsUUFBUSxFQUFFLHFCQUFxQjthQUMvQjs7O1lBSm1CLGdCQUFnQiIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IERpcmVjdGl2ZSwgVmlld0NvbnRhaW5lclJlZiB9IGZyb20gJ0Bhbmd1bGFyL2NvcmUnO1xyXG5cclxuQERpcmVjdGl2ZSh7XHJcblx0c2VsZWN0b3I6ICdbZGF0YUNvbXBvbmVudEhvc3RdJyxcclxufSlcclxuZXhwb3J0IGNsYXNzIERhdGFDb21wb25lbnREaXJlY3RpdmUge1xyXG5cdGNvbnN0cnVjdG9yKHB1YmxpYyB2aWV3Q29udGFpbmVyUmVmOiBWaWV3Q29udGFpbmVyUmVmKSB7IH1cclxufVxyXG4iXX0=
|
|
@@ -1,31 +0,0 @@
|
|
|
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
|
-
/**
|
|
6
|
-
* 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.
|
|
7
|
-
*
|
|
8
|
-
*/
|
|
9
|
-
export class NmceDirectivesModule {
|
|
10
|
-
}
|
|
11
|
-
NmceDirectivesModule.decorators = [
|
|
12
|
-
{ type: NgModule, args: [{
|
|
13
|
-
imports: [
|
|
14
|
-
CommonModule,
|
|
15
|
-
FormsModule,
|
|
16
|
-
],
|
|
17
|
-
declarations: [
|
|
18
|
-
AutofocusDirective,
|
|
19
|
-
CurrencyFormatterDirective,
|
|
20
|
-
ScrollIntoDirective,
|
|
21
|
-
DataComponentDirective,
|
|
22
|
-
],
|
|
23
|
-
exports: [
|
|
24
|
-
AutofocusDirective,
|
|
25
|
-
CurrencyFormatterDirective,
|
|
26
|
-
ScrollIntoDirective,
|
|
27
|
-
DataComponentDirective,
|
|
28
|
-
]
|
|
29
|
-
},] }
|
|
30
|
-
];
|
|
31
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGlyZWN0aXZlcy5tb2R1bGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9wcm9qZWN0cy9ubWNlLWRpcmVjdGl2ZXMvc3JjL19kaXJlY3RpdmVzL2RpcmVjdGl2ZXMubW9kdWxlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxZQUFZLEVBQUUsTUFBTSxpQkFBaUIsQ0FBQztBQUMvQyxPQUFPLEVBQUUsUUFBUSxFQUFFLE1BQU0sZUFBZSxDQUFDO0FBQ3pDLE9BQU8sRUFBRSxXQUFXLEVBQUUsTUFBTSxnQkFBZ0IsQ0FBQztBQUM3QyxPQUFPLEVBQ04sa0JBQWtCLEVBQUUsMEJBQTBCLEVB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clxuICpcclxuICovXHJcbkBOZ01vZHVsZSh7XHJcblx0aW1wb3J0czogW1xyXG5cdFx0Q29tbW9uTW9kdWxlLFxyXG5cdFx0Rm9ybXNNb2R1bGUsXHJcblx0XSxcclxuXHJcblx0ZGVjbGFyYXRpb25zOiBbXHJcblx0XHRBdXRvZm9jdXNEaXJlY3RpdmUsXHJcblx0XHRDdXJyZW5jeUZvcm1hdHRlckRpcmVjdGl2ZSxcclxuXHRcdFNjcm9sbEludG9EaXJlY3RpdmUsXHJcblx0XHREYXRhQ29tcG9uZW50RGlyZWN0aXZlLFxyXG5cdF0sXHJcblxyXG5cclxuXHRleHBvcnRzOiBbXHJcblx0XHRBdXRvZm9jdXNEaXJlY3RpdmUsXHJcblx0XHRDdXJyZW5jeUZvcm1hdHRlckRpcmVjdGl2ZSxcclxuXHRcdFNjcm9sbEludG9EaXJlY3RpdmUsXHJcblx0XHREYXRhQ29tcG9uZW50RGlyZWN0aXZlLFxyXG5cdF1cclxufSlcclxuZXhwb3J0IGNsYXNzIE5tY2VEaXJlY3RpdmVzTW9kdWxlIHsgfVxyXG4iXX0=
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { Directive, ElementRef, Input } from '@angular/core';
|
|
2
|
-
/**
|
|
3
|
-
* Scroll to element attached. And the element may be an Angular Material component too.
|
|
4
|
-
*/
|
|
5
|
-
export class ScrollIntoDirective {
|
|
6
|
-
constructor(el) {
|
|
7
|
-
this.el = el;
|
|
8
|
-
this.scrollInto = false;
|
|
9
|
-
// console.debug('ScrollIntoDirective created.');
|
|
10
|
-
}
|
|
11
|
-
ngAfterViewInit() {
|
|
12
|
-
if (this.scrollInto) {
|
|
13
|
-
this.el.nativeElement.scrollIntoView();
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
ScrollIntoDirective.decorators = [
|
|
18
|
-
{ type: Directive, args: [{
|
|
19
|
-
selector: '[scrollInto]'
|
|
20
|
-
},] }
|
|
21
|
-
];
|
|
22
|
-
ScrollIntoDirective.ctorParameters = () => [
|
|
23
|
-
{ type: ElementRef }
|
|
24
|
-
];
|
|
25
|
-
ScrollIntoDirective.propDecorators = {
|
|
26
|
-
scrollInto: [{ type: Input }]
|
|
27
|
-
};
|
|
28
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2Nyb2xsSW50by5kaXJlY3RpdmUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9wcm9qZWN0cy9ubWNlLWRpcmVjdGl2ZXMvc3JjL19kaXJlY3RpdmVzL3Njcm9sbEludG8uZGlyZWN0aXZlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBaUIsU0FBUyxFQUFFLFVBQVUsRUFBRSxLQUFLLEVBQUUsTUFBTSxlQUFlLENBQUM7QUFFNUU7O0dBRUc7QUFJSCxNQUFNLE9BQU8sbUJBQW1CO0lBQy9CLFlBQW9CLEVBQWM7UUFBZCxPQUFFLEdBQUYsRUFBRSxDQUFZO1FBS2xDLGVBQVUsR0FBWSxLQUFLLENBQUM7UUFKM0IsaURBQWlEO0lBQ2xELENBQUM7SUFLRCxlQUFlO1FBQ2QsSUFBSSxJQUFJLENBQUMsVUFBVSxFQUFFO1lBQ3BCLElBQUksQ0FBQyxFQUFFLENBQUMsYUFBYSxDQUFDLGNBQWMsRUFBRSxDQUFDO1NBQ3ZDO0lBQ0YsQ0FBQzs7O1lBZkQsU0FBUyxTQUFDO2dCQUNWLFFBQVEsRUFBRSxjQUFjO2FBQ3hCOzs7WUFQa0MsVUFBVTs7O3lCQWEzQyxLQUFLIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgQWZ0ZXJWaWV3SW5pdCwgRGlyZWN0aXZlLCBFbGVtZW50UmVmLCBJbnB1dCB9IGZyb20gJ0Bhbmd1bGFyL2NvcmUnO1xyXG5cclxuLyoqXHJcbiAqIFNjcm9sbCB0byBlbGVtZW50IGF0dGFjaGVkLiBBbmQgdGhlIGVsZW1lbnQgbWF5IGJlIGFuIEFuZ3VsYXIgTWF0ZXJpYWwgY29tcG9uZW50IHRvby5cclxuICovXHJcbkBEaXJlY3RpdmUoe1xyXG5cdHNlbGVjdG9yOiAnW3Njcm9sbEludG9dJ1xyXG59KVxyXG5leHBvcnQgY2xhc3MgU2Nyb2xsSW50b0RpcmVjdGl2ZSBpbXBsZW1lbnRzIEFmdGVyVmlld0luaXQge1xyXG5cdGNvbnN0cnVjdG9yKHByaXZhdGUgZWw6IEVsZW1lbnRSZWYpIHtcclxuXHRcdC8vXHRjb25zb2xlLmRlYnVnKCdTY3JvbGxJbnRvRGlyZWN0aXZlIGNyZWF0ZWQuJyk7XHJcblx0fVxyXG5cclxuXHRASW5wdXQoKVxyXG5cdHNjcm9sbEludG86IGJvb2xlYW4gPSBmYWxzZTtcclxuXHJcblx0bmdBZnRlclZpZXdJbml0KCkge1xyXG5cdFx0aWYgKHRoaXMuc2Nyb2xsSW50bykge1xyXG5cdFx0XHR0aGlzLmVsLm5hdGl2ZUVsZW1lbnQuc2Nyb2xsSW50b1ZpZXcoKTtcclxuXHRcdH1cclxuXHR9XHJcbn1cclxuIl19
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import { Directive, ElementRef, Input, HostListener, ViewContainerRef, NgModule } from '@angular/core';
|
|
2
|
-
import { CurrencyFunc } from 'nmce-func';
|
|
3
|
-
import { CommonModule } from '@angular/common';
|
|
4
|
-
import { FormsModule } from '@angular/forms';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Use as a parametered input parameter in html element.
|
|
8
|
-
* When used inside a material dialog, this directive may be at odd against the autofocus config parameter of MatDialogConfig,
|
|
9
|
-
* if the autofocus config is not false. Generally speaking, no need to use this directive in a component presented in a mateiral dialog.
|
|
10
|
-
*/
|
|
11
|
-
class AutofocusDirective {
|
|
12
|
-
constructor(el) {
|
|
13
|
-
this.el = el;
|
|
14
|
-
this.toFocus = false;
|
|
15
|
-
this.focused = false;
|
|
16
|
-
this.initialised = false;
|
|
17
|
-
this.everFocused = false;
|
|
18
|
-
//console.debug('autofocusDirective created.');
|
|
19
|
-
}
|
|
20
|
-
ngAfterViewInit() {
|
|
21
|
-
this.initialised = true;
|
|
22
|
-
this.ngDoCheck();
|
|
23
|
-
}
|
|
24
|
-
ngDoCheck() {
|
|
25
|
-
if (!this.initialised) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
if (this.toFocus && !this.everFocused && !this.focused) {
|
|
29
|
-
this.el.nativeElement.focus();
|
|
30
|
-
this.focused = true;
|
|
31
|
-
this.everFocused = true;
|
|
32
|
-
console.debug('focused now.');
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
set autofocus(condition) {
|
|
36
|
-
this.toFocus = condition !== false;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
AutofocusDirective.decorators = [
|
|
40
|
-
{ type: Directive, args: [{
|
|
41
|
-
selector: '[autofocus]'
|
|
42
|
-
},] }
|
|
43
|
-
];
|
|
44
|
-
AutofocusDirective.ctorParameters = () => [
|
|
45
|
-
{ type: ElementRef }
|
|
46
|
-
];
|
|
47
|
-
AutofocusDirective.propDecorators = {
|
|
48
|
-
autofocus: [{ 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.decorators = [
|
|
71
|
-
{ type: Directive, args: [{ selector: '[currencyFormatter]' }, //inspired by https://blog.ngconsultant.io/custom-input-formatting-with-simple-directives-for-angular-2-ec792082976
|
|
72
|
-
] }
|
|
73
|
-
];
|
|
74
|
-
CurrencyFormatterDirective.ctorParameters = () => [
|
|
75
|
-
{ type: ElementRef }
|
|
76
|
-
];
|
|
77
|
-
CurrencyFormatterDirective.propDecorators = {
|
|
78
|
-
onFocus: [{ type: HostListener, args: ['focus', ['$event.target.value'],] }],
|
|
79
|
-
onBlur: [{ type: HostListener, args: ['blur', ['$event.target.value'],] }]
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
class DataComponentDirective {
|
|
83
|
-
constructor(viewContainerRef) {
|
|
84
|
-
this.viewContainerRef = viewContainerRef;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
DataComponentDirective.decorators = [
|
|
88
|
-
{ type: Directive, args: [{
|
|
89
|
-
selector: '[dataComponentHost]',
|
|
90
|
-
},] }
|
|
91
|
-
];
|
|
92
|
-
DataComponentDirective.ctorParameters = () => [
|
|
93
|
-
{ type: ViewContainerRef }
|
|
94
|
-
];
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Scroll to element attached. And the element may be an Angular Material component too.
|
|
98
|
-
*/
|
|
99
|
-
class ScrollIntoDirective {
|
|
100
|
-
constructor(el) {
|
|
101
|
-
this.el = el;
|
|
102
|
-
this.scrollInto = false;
|
|
103
|
-
// console.debug('ScrollIntoDirective created.');
|
|
104
|
-
}
|
|
105
|
-
ngAfterViewInit() {
|
|
106
|
-
if (this.scrollInto) {
|
|
107
|
-
this.el.nativeElement.scrollIntoView();
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
ScrollIntoDirective.decorators = [
|
|
112
|
-
{ type: Directive, args: [{
|
|
113
|
-
selector: '[scrollInto]'
|
|
114
|
-
},] }
|
|
115
|
-
];
|
|
116
|
-
ScrollIntoDirective.ctorParameters = () => [
|
|
117
|
-
{ type: ElementRef }
|
|
118
|
-
];
|
|
119
|
-
ScrollIntoDirective.propDecorators = {
|
|
120
|
-
scrollInto: [{ 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.decorators = [
|
|
130
|
-
{ type: NgModule, args: [{
|
|
131
|
-
imports: [
|
|
132
|
-
CommonModule,
|
|
133
|
-
FormsModule,
|
|
134
|
-
],
|
|
135
|
-
declarations: [
|
|
136
|
-
AutofocusDirective,
|
|
137
|
-
CurrencyFormatterDirective,
|
|
138
|
-
ScrollIntoDirective,
|
|
139
|
-
DataComponentDirective,
|
|
140
|
-
],
|
|
141
|
-
exports: [
|
|
142
|
-
AutofocusDirective,
|
|
143
|
-
CurrencyFormatterDirective,
|
|
144
|
-
ScrollIntoDirective,
|
|
145
|
-
DataComponentDirective,
|
|
146
|
-
]
|
|
147
|
-
},] }
|
|
148
|
-
];
|
|
149
|
-
|
|
150
|
-
/*
|
|
151
|
-
* Public API Surface of nmce-directives
|
|
152
|
-
*/
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* Generated bundle index. Do not edit.
|
|
156
|
-
*/
|
|
157
|
-
|
|
158
|
-
export { AutofocusDirective, CurrencyFormatterDirective, DataComponentDirective, NmceDirectivesModule, ScrollIntoDirective };
|
|
159
|
-
//# sourceMappingURL=nmce-directives.js.map
|