nmce-directives 0.0.6 → 0.0.7
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 +9 -2
- package/_directives/currencyFormatter.directive.d.ts +2 -1
- package/_directives/index.d.ts +1 -3
- package/_directives/scrollInto.directive.d.ts +3 -0
- package/bundles/nmce-directives.umd.js +36 -119
- package/bundles/nmce-directives.umd.js.map +1 -1
- package/bundles/nmce-directives.umd.min.js +1 -1
- package/bundles/nmce-directives.umd.min.js.map +1 -1
- package/esm2015/_directives/autofocus.js +17 -10
- package/esm2015/_directives/currencyFormatter.directive.js +4 -3
- package/esm2015/_directives/directives.module.js +3 -7
- package/esm2015/_directives/index.js +2 -4
- package/esm2015/_directives/scrollInto.directive.js +4 -1
- package/fesm2015/nmce-directives.js +32 -107
- package/fesm2015/nmce-directives.js.map +1 -1
- package/nmce-directives.metadata.json +1 -1
- package/package.json +1 -1
- package/_directives/datetimeFormatter.directive.d.ts +0 -16
- package/_directives/highlight.directive.d.ts +0 -10
- package/esm2015/_directives/datetimeFormatter.directive.js +0 -53
- package/esm2015/_directives/highlight.directive.js +0 -31
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
import { AfterViewInit,
|
|
1
|
+
import { AfterViewInit, DoCheck, ElementRef } 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
|
+
*/
|
|
2
7
|
export declare class AutofocusDirective implements AfterViewInit, DoCheck {
|
|
3
8
|
private el;
|
|
4
|
-
private
|
|
9
|
+
private toFocus;
|
|
10
|
+
private focused;
|
|
5
11
|
private initialised;
|
|
12
|
+
private everFocused;
|
|
6
13
|
constructor(el: ElementRef);
|
|
7
14
|
ngAfterViewInit(): void;
|
|
8
15
|
ngDoCheck(): void;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ElementRef, OnInit } from '@angular/core';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Decorate HTML input for inputing and displaying currency. The input type must not be number and should be text only.
|
|
4
|
+
* If the input type is number, the built-in validator will be fighting against this directive.
|
|
4
5
|
*/
|
|
5
6
|
export declare class CurrencyFormatterDirective implements OnInit {
|
|
6
7
|
private elementRef;
|
package/_directives/index.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
export * from './autofocus';
|
|
2
|
-
export * from './highlight.directive';
|
|
3
2
|
export * from './currencyFormatter.directive';
|
|
4
|
-
export * from './datetimeFormatter.directive';
|
|
5
|
-
export * from './scrollInto.directive';
|
|
6
3
|
export * from './dataComponent.directive';
|
|
4
|
+
export * from './scrollInto.directive';
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { AfterViewInit, ElementRef } from '@angular/core';
|
|
2
|
+
/**
|
|
3
|
+
* Scroll to element attached. And the element may be an Angular Material component too.
|
|
4
|
+
*/
|
|
2
5
|
export declare class ScrollIntoDirective implements AfterViewInit {
|
|
3
6
|
private el;
|
|
4
7
|
constructor(el: ElementRef);
|
|
@@ -1,39 +1,41 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('nmce-func'), require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define('nmce-directives', ['exports', '@angular/core', 'nmce-func', '
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global['nmce-directives'] = {}, global.ng.core, global['nmce-func'], global.
|
|
5
|
-
}(this, (function (exports, core, nmceFunc,
|
|
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
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
12
|
var AutofocusDirective = /** @class */ (function () {
|
|
13
13
|
function AutofocusDirective(el) {
|
|
14
14
|
this.el = el;
|
|
15
|
-
this.
|
|
15
|
+
this.toFocus = false;
|
|
16
|
+
this.focused = false;
|
|
16
17
|
this.initialised = false;
|
|
17
|
-
|
|
18
|
+
this.everFocused = false;
|
|
19
|
+
//console.debug('autofocusDirective created.');
|
|
18
20
|
}
|
|
19
21
|
AutofocusDirective.prototype.ngAfterViewInit = function () {
|
|
20
22
|
this.initialised = true;
|
|
21
23
|
this.ngDoCheck();
|
|
22
24
|
};
|
|
23
25
|
AutofocusDirective.prototype.ngDoCheck = function () {
|
|
24
|
-
var _this = this;
|
|
25
26
|
if (!this.initialised) {
|
|
26
27
|
return;
|
|
27
28
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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.');
|
|
31
34
|
}
|
|
32
|
-
this.lastVisible = visible;
|
|
33
35
|
};
|
|
34
36
|
Object.defineProperty(AutofocusDirective.prototype, "autofocus", {
|
|
35
37
|
set: function (condition) {
|
|
36
|
-
this.
|
|
38
|
+
this.toFocus = condition !== false;
|
|
37
39
|
},
|
|
38
40
|
enumerable: false,
|
|
39
41
|
configurable: true
|
|
@@ -42,7 +44,7 @@
|
|
|
42
44
|
}());
|
|
43
45
|
AutofocusDirective.decorators = [
|
|
44
46
|
{ type: core.Directive, args: [{
|
|
45
|
-
selector: '[autofocus]'
|
|
47
|
+
selector: '[autofocus]'
|
|
46
48
|
},] }
|
|
47
49
|
];
|
|
48
50
|
AutofocusDirective.ctorParameters = function () { return [
|
|
@@ -52,39 +54,9 @@
|
|
|
52
54
|
autofocus: [{ type: core.Input }]
|
|
53
55
|
};
|
|
54
56
|
|
|
55
|
-
var HighlightDirective = /** @class */ (function () {
|
|
56
|
-
function HighlightDirective(el) {
|
|
57
|
-
this.el = el;
|
|
58
|
-
console.debug('HighlightDirective created.');
|
|
59
|
-
}
|
|
60
|
-
HighlightDirective.prototype.onMouseEnter = function () {
|
|
61
|
-
this.highlight(this.highlightColor || this.defaultColor || 'red');
|
|
62
|
-
};
|
|
63
|
-
HighlightDirective.prototype.onMouseLeave = function () {
|
|
64
|
-
this.highlight(undefined);
|
|
65
|
-
};
|
|
66
|
-
HighlightDirective.prototype.highlight = function (color) {
|
|
67
|
-
this.el.nativeElement.style.backgroundColor = color;
|
|
68
|
-
};
|
|
69
|
-
return HighlightDirective;
|
|
70
|
-
}());
|
|
71
|
-
HighlightDirective.decorators = [
|
|
72
|
-
{ type: core.Directive, args: [{
|
|
73
|
-
selector: '[myHighlight]'
|
|
74
|
-
},] }
|
|
75
|
-
];
|
|
76
|
-
HighlightDirective.ctorParameters = function () { return [
|
|
77
|
-
{ type: core.ElementRef }
|
|
78
|
-
]; };
|
|
79
|
-
HighlightDirective.propDecorators = {
|
|
80
|
-
defaultColor: [{ type: core.Input }],
|
|
81
|
-
highlightColor: [{ type: core.Input, args: ['myHighlight',] }],
|
|
82
|
-
onMouseEnter: [{ type: core.HostListener, args: ['mouseenter',] }],
|
|
83
|
-
onMouseLeave: [{ type: core.HostListener, args: ['mouseleave',] }]
|
|
84
|
-
};
|
|
85
|
-
|
|
86
57
|
/**
|
|
87
|
-
*
|
|
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.
|
|
88
60
|
*/
|
|
89
61
|
var CurrencyFormatterDirective = /** @class */ (function () {
|
|
90
62
|
function CurrencyFormatterDirective(elementRef) {
|
|
@@ -114,58 +86,24 @@
|
|
|
114
86
|
onBlur: [{ type: core.HostListener, args: ['blur', ['$event.target.value'],] }]
|
|
115
87
|
};
|
|
116
88
|
|
|
117
|
-
/**
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
var DatetimeFormatterDirective = /** @class */ (function () {
|
|
121
|
-
function DatetimeFormatterDirective(elementRef) {
|
|
122
|
-
this.elementRef = elementRef;
|
|
123
|
-
//@Input('datetimeFormatter')
|
|
124
|
-
this.format = 'DD/MM/YYYY HH:mm';
|
|
125
|
-
this.formats = ['', 'DD/MM/YYYY HH:mm'];
|
|
126
|
-
this.el = this.elementRef.nativeElement;
|
|
89
|
+
var DataComponentDirective = /** @class */ (function () {
|
|
90
|
+
function DataComponentDirective(viewContainerRef) {
|
|
91
|
+
this.viewContainerRef = viewContainerRef;
|
|
127
92
|
}
|
|
128
|
-
|
|
129
|
-
var s = this.parse(this.el.value);
|
|
130
|
-
this.el.value = this.transform(s);
|
|
131
|
-
};
|
|
132
|
-
DatetimeFormatterDirective.prototype.onFocus = function () {
|
|
133
|
-
var s = this.parse(this.el.value);
|
|
134
|
-
this.el.value = this.transform(s);
|
|
135
|
-
};
|
|
136
|
-
DatetimeFormatterDirective.prototype.onBlur = function () {
|
|
137
|
-
this.el.value = this.transform(this.el.value);
|
|
138
|
-
};
|
|
139
|
-
DatetimeFormatterDirective.prototype.transform = function (value) {
|
|
140
|
-
if (!value) {
|
|
141
|
-
return '';
|
|
142
|
-
}
|
|
143
|
-
var s = moment__default['default'](value).format(this.format);
|
|
144
|
-
console.debug("With format " + this.format + " transform to " + s);
|
|
145
|
-
return s;
|
|
146
|
-
};
|
|
147
|
-
DatetimeFormatterDirective.prototype.parse = function (value) {
|
|
148
|
-
if (!value) {
|
|
149
|
-
return null;
|
|
150
|
-
}
|
|
151
|
-
var d = moment__default['default'](value, this.formats).toDate();
|
|
152
|
-
console.debug("parse " + value + " to " + d);
|
|
153
|
-
return d;
|
|
154
|
-
};
|
|
155
|
-
return DatetimeFormatterDirective;
|
|
93
|
+
return DataComponentDirective;
|
|
156
94
|
}());
|
|
157
|
-
|
|
158
|
-
{ type: core.Directive, args: [{
|
|
159
|
-
|
|
95
|
+
DataComponentDirective.decorators = [
|
|
96
|
+
{ type: core.Directive, args: [{
|
|
97
|
+
selector: '[dataComponentHost]',
|
|
98
|
+
},] }
|
|
160
99
|
];
|
|
161
|
-
|
|
162
|
-
{ type: core.
|
|
163
|
-
]; };
|
|
164
|
-
DatetimeFormatterDirective.propDecorators = {
|
|
165
|
-
onFocus: [{ type: core.HostListener, args: ['focus', ['$event.target.value'],] }],
|
|
166
|
-
onBlur: [{ type: core.HostListener, args: ['blur', ['$event.target.value'],] }]
|
|
167
|
-
};
|
|
100
|
+
DataComponentDirective.ctorParameters = function () { return [
|
|
101
|
+
{ type: core.ViewContainerRef }
|
|
102
|
+
]; };
|
|
168
103
|
|
|
104
|
+
/**
|
|
105
|
+
* Scroll to element attached. And the element may be an Angular Material component too.
|
|
106
|
+
*/
|
|
169
107
|
var ScrollIntoDirective = /** @class */ (function () {
|
|
170
108
|
function ScrollIntoDirective(el) {
|
|
171
109
|
this.el = el;
|
|
@@ -191,21 +129,6 @@
|
|
|
191
129
|
scrollInto: [{ type: core.Input }]
|
|
192
130
|
};
|
|
193
131
|
|
|
194
|
-
var DataComponentDirective = /** @class */ (function () {
|
|
195
|
-
function DataComponentDirective(viewContainerRef) {
|
|
196
|
-
this.viewContainerRef = viewContainerRef;
|
|
197
|
-
}
|
|
198
|
-
return DataComponentDirective;
|
|
199
|
-
}());
|
|
200
|
-
DataComponentDirective.decorators = [
|
|
201
|
-
{ type: core.Directive, args: [{
|
|
202
|
-
selector: '[dataComponentHost]',
|
|
203
|
-
},] }
|
|
204
|
-
];
|
|
205
|
-
DataComponentDirective.ctorParameters = function () { return [
|
|
206
|
-
{ type: core.ViewContainerRef }
|
|
207
|
-
]; };
|
|
208
|
-
|
|
209
132
|
/**
|
|
210
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.
|
|
211
134
|
*
|
|
@@ -223,17 +146,13 @@
|
|
|
223
146
|
],
|
|
224
147
|
declarations: [
|
|
225
148
|
AutofocusDirective,
|
|
226
|
-
HighlightDirective,
|
|
227
149
|
CurrencyFormatterDirective,
|
|
228
|
-
DatetimeFormatterDirective,
|
|
229
150
|
ScrollIntoDirective,
|
|
230
151
|
DataComponentDirective,
|
|
231
152
|
],
|
|
232
153
|
exports: [
|
|
233
154
|
AutofocusDirective,
|
|
234
|
-
HighlightDirective,
|
|
235
155
|
CurrencyFormatterDirective,
|
|
236
|
-
DatetimeFormatterDirective,
|
|
237
156
|
ScrollIntoDirective,
|
|
238
157
|
DataComponentDirective,
|
|
239
158
|
]
|
|
@@ -251,8 +170,6 @@
|
|
|
251
170
|
exports.AutofocusDirective = AutofocusDirective;
|
|
252
171
|
exports.CurrencyFormatterDirective = CurrencyFormatterDirective;
|
|
253
172
|
exports.DataComponentDirective = DataComponentDirective;
|
|
254
|
-
exports.DatetimeFormatterDirective = DatetimeFormatterDirective;
|
|
255
|
-
exports.HighlightDirective = HighlightDirective;
|
|
256
173
|
exports.NmceDirectivesModule = NmceDirectivesModule;
|
|
257
174
|
exports.ScrollIntoDirective = ScrollIntoDirective;
|
|
258
175
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nmce-directives.umd.js","sources":["../../../projects/nmce-directives/src/_directives/autofocus.ts","../../../projects/nmce-directives/src/_directives/highlight.directive.ts","../../../projects/nmce-directives/src/_directives/currencyFormatter.directive.ts","../../../projects/nmce-directives/src/_directives/datetimeFormatter.directive.ts","../../../projects/nmce-directives/src/_directives/scrollInto.directive.ts","../../../projects/nmce-directives/src/_directives/dataComponent.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 { Directive, AfterViewInit, ElementRef, DoCheck, Input } from '@angular/core';\r\n\r\n\r\n// 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/\r\n@Directive({\r\n\tselector: '[autofocus]' // using [ ] means selecting attributes\r\n})\r\n\r\nexport class AutofocusDirective implements AfterViewInit, DoCheck {\r\n\tprivate lastVisible = false;\r\n\tprivate initialised = false;\r\n\tconstructor(private el: ElementRef) {\r\n\t\tconsole.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\tconst visible = !!this.el.nativeElement.offsetParent;\r\n\t\tif (visible && !this.lastVisible) {\r\n\t\t\tsetTimeout(() => { this.el.nativeElement.focus(); }, 2); //no need to clearTimeout\r\n\t\t}\r\n\t\tthis.lastVisible = visible;\r\n\t}\r\n\r\n\t@Input() set autofocus(condition: boolean) {\r\n\t\tthis.lastVisible = condition !== false;\r\n\t}\r\n}\r\n","import { Directive, ElementRef, HostListener, Input } from '@angular/core';\r\n@Directive({\r\n\tselector: '[myHighlight]'\r\n})\r\nexport class HighlightDirective {\r\n\tconstructor(private el: ElementRef) {\r\n\t\tconsole.debug('HighlightDirective created.');\r\n\t}\r\n\r\n\t@Input() defaultColor?: string;\r\n\t@Input('myHighlight') highlightColor?: string;\r\n\t@HostListener('mouseenter') onMouseEnter() {\r\n\t\tthis.highlight(this.highlightColor || this.defaultColor || 'red');\r\n\t}\r\n\t@HostListener('mouseleave') onMouseLeave() {\r\n\t\tthis.highlight(undefined);\r\n\t}\r\n\tprivate highlight(color: string | undefined) {\r\n\t\tthis.el.nativeElement.style.backgroundColor = color;\r\n\t}\r\n}\r\n","import { Directive, HostListener, ElementRef, OnInit } from '@angular/core';\r\nimport { CurrencyFunc } from 'nmce-func';\r\n\r\n/**\r\n *\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, HostListener, ElementRef, OnInit } from '@angular/core';\r\nimport moment from 'moment';\r\n\r\n/**\r\n *\r\n */\r\n@Directive({ selector: '[datetimeFormatter]' })//inspired by https://blog.ngconsultant.io/custom-input-formatting-with-simple-directives-for-angular-2-ec792082976\r\nexport class DatetimeFormatterDirective implements OnInit {\r\n\r\n\tprivate el: HTMLInputElement;\r\n\r\n\t//@Input('datetimeFormatter')\r\n\tformat = 'DD/MM/YYYY HH:mm';\r\n\r\n\tformats = ['', 'DD/MM/YYYY HH:mm'];\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\tconst s = this.parse(this.el.value);\r\n\t\tthis.el.value = this.transform(s);\r\n\t}\r\n\r\n\t@HostListener('focus', ['$event.target.value'])\r\n\tonFocus() {\r\n\t\tconst s = this.parse(this.el.value);\r\n\t\tthis.el.value = this.transform(s);\r\n\t}\r\n\r\n\t@HostListener('blur', ['$event.target.value'])\r\n\tonBlur() {\r\n\t\tthis.el.value = this.transform(this.el.value);\r\n\t}\r\n\r\n\ttransform(value: Date | string | null): string {\r\n\t\tif (!value) {\r\n\t\t\treturn '';\r\n\t\t}\r\n\r\n\t\tconst s = moment(value).format(this.format);\r\n\t\tconsole.debug(`With format ${this.format} transform to ${s}`);\r\n\t\treturn s;\r\n\t}\r\n\r\n\tparse(value: string): Date | null {\r\n\t\tif (!value) {\r\n\t\t\treturn null;\r\n\t\t}\r\n\r\n\t\tconst d = moment(value, this.formats).toDate();\r\n\t\tconsole.debug(`parse ${value} to ${d}`);\r\n\t\treturn d;\r\n\t}\r\n\r\n}\r\n\r\n","import { AfterViewInit, Directive, ElementRef, Input } from '@angular/core';\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 { 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 { NgModule } from '@angular/core';\r\nimport { CommonModule } from '@angular/common';\r\nimport { FormsModule } from '@angular/forms';\r\n\r\n\r\nimport {\r\n\tAutofocusDirective, HighlightDirective, CurrencyFormatterDirective, DatetimeFormatterDirective, ScrollIntoDirective, DataComponentDirective,\r\n} from './index';\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\tHighlightDirective,\r\n\t\tCurrencyFormatterDirective,\r\n\t\tDatetimeFormatterDirective,\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\tHighlightDirective,\r\n\t\tCurrencyFormatterDirective,\r\n\t\tDatetimeFormatterDirective,\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","HostListener","CurrencyFunc","moment","ViewContainerRef","NgModule","CommonModule","FormsModule"],"mappings":";;;;;;;;;;IAGA;;QAQC,4BAAoB,EAAc;YAAd,OAAE,GAAF,EAAE,CAAY;YAF1B,gBAAW,GAAG,KAAK,CAAC;YACpB,gBAAW,GAAG,KAAK,CAAC;YAE3B,OAAO,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;SAC7C;QAED,4CAAe,GAAf;YACC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;YACxB,IAAI,CAAC,SAAS,EAAE,CAAC;SACjB;QAED,sCAAS,GAAT;YAAA,iBAOC;YANA,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;gBAAE,OAAO;aAAE;YAClC,IAAM,OAAO,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,aAAa,CAAC,YAAY,CAAC;YACrD,IAAI,OAAO,IAAI,CAAC,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AAqB;iBAC/B;;;gBAJmBM,qBAAgB;;;ICSpC;;;;;QA6BA;;;;;gBAzBCC,aAAQ,SAAC;oBACT,OAAO,EAAE;wBACRC,mBAAY;wBACZC,iBAAW;qBACX;oBAED,YAAY,EAAE;wBACb,kBAAkB;wBAClB,kBAAkB;wBAClB,0BAA0B;wBAC1B,0BAA0B;wBAC1B,mBAAmB;wBACnB,sBAAsB;qBACtB;oBAGD,OAAO,EAAE;wBACR,kBAAkB;wBAClB,kBAAkB;wBAClB,0BAA0B;wBAC1B,0BAA0B;wBAC1B,mBAAmB;wBACnB,sBAAsB;qBACtB;iBACD;;;ICrCD;;;;ICAA;;;;;;;;;;;;;;;;;;"}
|
|
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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AAE,qBAAqB,EAAE;;;;gBAP1BC,eAAU;;;0BAoB5BG,iBAAY,SAAC,OAAO,EAAE,CAAC,qBAAqB,CAAC;yBAK7CA,iBAAY,SAAC,MAAM,EAAE,CAAC,qBAAqB,CAAC;;;;QCnB7C,gCAAmB,gBAAkC;YAAlC,qBAAgB,GAAhB,gBAAgB,CAAkB;SAAK;;;;gBAJ1DJ,cAAS,SAAC;oBACV,QAAQ,EAAE,qBAAqB;iBAC/B;;;gBAJmBK,qBAAgB;;;ICEpC;;;;QAOC,6BAAoB,EAAc;YAAd,OAAE,GAAF,EAAE,CAAY;YAKlC,eAAU,GAAY,KAAK,CAAC;;SAH3B;QAKD,6CAAe,GAAf;YACC,IAAI,IAAI,CAAC,UAAU,EAAE;gBACpB,IAAI,CAAC,EAAE,CAAC,aAAa,CAAC,cAAc,EAAE,CAAC;aACvC;SACD;;;;gBAfDL,cAAS,SAAC;oBACV,QAAQ,EAAE,cAAc;iBACxB;;;gBAPkCC,eAAU;;;6BAa3CC,UAAK;;;ICJP;;;;;QAyBA;;;;;gBArBCI,aAAQ,SAAC;oBACT,OAAO,EAAE;wBACRC,mBAAY;wBACZC,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 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("nmce-func"),require("
|
|
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
2
|
//# sourceMappingURL=nmce-directives.umd.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../projects/nmce-directives/src/_directives/autofocus.ts","../../../projects/nmce-directives/src/_directives/highlight.directive.ts","../../../projects/nmce-directives/src/_directives/currencyFormatter.directive.ts","../../../projects/nmce-directives/src/_directives/datetimeFormatter.directive.ts","../../../projects/nmce-directives/src/_directives/scrollInto.directive.ts","../../../projects/nmce-directives/src/_directives/dataComponent.directive.ts","../../../projects/nmce-directives/src/_directives/directives.module.ts"],"names":["AutofocusDirective","el","this","lastVisible","initialised","console","debug","prototype","ngAfterViewInit","ngDoCheck","_this","visible","nativeElement","offsetParent","setTimeout","focus","Object","defineProperty","condition","Directive","args","selector","ElementRef","Input","HighlightDirective","onMouseEnter","highlight","highlightColor","defaultColor","onMouseLeave","undefined","color","style","backgroundColor","HostListener","CurrencyFormatterDirective","elementRef","ngOnInit","value","CurrencyFunc","transformCurrency","onFocus","parseCurrency","onBlur","DatetimeFormatterDirective","format","formats","s","parse","transform","moment","d","toDate","ScrollIntoDirective","scrollInto","scrollIntoView","viewContainerRef","ViewContainerRef","NgModule","imports","CommonModule","FormsModule","declarations","DataComponentDirective","exports"],"mappings":"4mBAWC,SAAAA,EAAoBC,GAAAC,KAAAD,GAAAA,EAFZC,KAAAC,aAAc,EACdD,KAAAE,aAAc,EAErBC,QAAQC,MAAM,sCAGfN,EAAAO,UAAAC,gBAAA,WACCN,KAAKE,aAAc,EACnBF,KAAKO,aAGNT,EAAAO,UAAAE,UAAA,WAAA,IAAAC,EAAAR,KACC,GAAKA,KAAKE,YAAV,CACA,IAAMO,IAAYT,KAAKD,GAAGW,cAAcC,aACpCF,IAAY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xBpC,EAAAA,UAASC,KAAA,CAAC,CACVC,SAAU,4DAFwBC,EAAAA,kDASjCC,EAAAA,eCHD,SAAmBiC,GAAAtD,KAAAsD,iBAAAA,uBAJnBrC,EAAAA,UAASC,KAAA,CAAC,CACVC,SAAU,mEAHSoC,EAAAA,0BCsCpB,iCAzBCC,EAAAA,SAAQtC,KAAA,CAAC,CACTuC,QAAS,CACRC,EAAAA,aACAC,EAAAA,aAGDC,aAAc,CACb9D,EACAwB,EACAW,EACAS,EACAS,EACAU,GAIDC,QAAS,CACRhE,EACAwB,EACAW,EACAS,EACAS,EACAU","sourcesContent":["import { Directive, AfterViewInit, ElementRef, DoCheck, Input } from '@angular/core';\r\n\r\n\r\n// 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/\r\n@Directive({\r\n\tselector: '[autofocus]' // using [ ] means selecting attributes\r\n})\r\n\r\nexport class AutofocusDirective implements AfterViewInit, DoCheck {\r\n\tprivate lastVisible = false;\r\n\tprivate initialised = false;\r\n\tconstructor(private el: ElementRef) {\r\n\t\tconsole.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\tconst visible = !!this.el.nativeElement.offsetParent;\r\n\t\tif (visible && !this.lastVisible) {\r\n\t\t\tsetTimeout(() => { this.el.nativeElement.focus(); }, 2); //no need to clearTimeout\r\n\t\t}\r\n\t\tthis.lastVisible = visible;\r\n\t}\r\n\r\n\t@Input() set autofocus(condition: boolean) {\r\n\t\tthis.lastVisible = condition !== false;\r\n\t}\r\n}\r\n","import { Directive, ElementRef, HostListener, Input } from '@angular/core';\r\n@Directive({\r\n\tselector: '[myHighlight]'\r\n})\r\nexport class HighlightDirective {\r\n\tconstructor(private el: ElementRef) {\r\n\t\tconsole.debug('HighlightDirective created.');\r\n\t}\r\n\r\n\t@Input() defaultColor?: string;\r\n\t@Input('myHighlight') highlightColor?: string;\r\n\t@HostListener('mouseenter') onMouseEnter() {\r\n\t\tthis.highlight(this.highlightColor || this.defaultColor || 'red');\r\n\t}\r\n\t@HostListener('mouseleave') onMouseLeave() {\r\n\t\tthis.highlight(undefined);\r\n\t}\r\n\tprivate highlight(color: string | undefined) {\r\n\t\tthis.el.nativeElement.style.backgroundColor = color;\r\n\t}\r\n}\r\n","import { Directive, HostListener, ElementRef, OnInit } from '@angular/core';\r\nimport { CurrencyFunc } from 'nmce-func';\r\n\r\n/**\r\n *\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, HostListener, ElementRef, OnInit } from '@angular/core';\r\nimport moment from 'moment';\r\n\r\n/**\r\n *\r\n */\r\n@Directive({ selector: '[datetimeFormatter]' })//inspired by https://blog.ngconsultant.io/custom-input-formatting-with-simple-directives-for-angular-2-ec792082976\r\nexport class DatetimeFormatterDirective implements OnInit {\r\n\r\n\tprivate el: HTMLInputElement;\r\n\r\n\t//@Input('datetimeFormatter')\r\n\tformat = 'DD/MM/YYYY HH:mm';\r\n\r\n\tformats = ['', 'DD/MM/YYYY HH:mm'];\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\tconst s = this.parse(this.el.value);\r\n\t\tthis.el.value = this.transform(s);\r\n\t}\r\n\r\n\t@HostListener('focus', ['$event.target.value'])\r\n\tonFocus() {\r\n\t\tconst s = this.parse(this.el.value);\r\n\t\tthis.el.value = this.transform(s);\r\n\t}\r\n\r\n\t@HostListener('blur', ['$event.target.value'])\r\n\tonBlur() {\r\n\t\tthis.el.value = this.transform(this.el.value);\r\n\t}\r\n\r\n\ttransform(value: Date | string | null): string {\r\n\t\tif (!value) {\r\n\t\t\treturn '';\r\n\t\t}\r\n\r\n\t\tconst s = moment(value).format(this.format);\r\n\t\tconsole.debug(`With format ${this.format} transform to ${s}`);\r\n\t\treturn s;\r\n\t}\r\n\r\n\tparse(value: string): Date | null {\r\n\t\tif (!value) {\r\n\t\t\treturn null;\r\n\t\t}\r\n\r\n\t\tconst d = moment(value, this.formats).toDate();\r\n\t\tconsole.debug(`parse ${value} to ${d}`);\r\n\t\treturn d;\r\n\t}\r\n\r\n}\r\n\r\n","import { AfterViewInit, Directive, ElementRef, Input } from '@angular/core';\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 { 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 { NgModule } from '@angular/core';\r\nimport { CommonModule } from '@angular/common';\r\nimport { FormsModule } from '@angular/forms';\r\n\r\n\r\nimport {\r\n\tAutofocusDirective, HighlightDirective, CurrencyFormatterDirective, DatetimeFormatterDirective, ScrollIntoDirective, DataComponentDirective,\r\n} from './index';\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\tHighlightDirective,\r\n\t\tCurrencyFormatterDirective,\r\n\t\tDatetimeFormatterDirective,\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\tHighlightDirective,\r\n\t\tCurrencyFormatterDirective,\r\n\t\tDatetimeFormatterDirective,\r\n\t\tScrollIntoDirective,\r\n\t\tDataComponentDirective,\r\n\t]\r\n})\r\nexport class NmceDirectivesModule { }\r\n"]}
|
|
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,KAAAC,SAA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AKD,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,11 +1,17 @@
|
|
|
1
1
|
import { Directive, ElementRef, Input } from '@angular/core';
|
|
2
|
-
|
|
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
|
+
*/
|
|
3
7
|
export class AutofocusDirective {
|
|
4
8
|
constructor(el) {
|
|
5
9
|
this.el = el;
|
|
6
|
-
this.
|
|
10
|
+
this.toFocus = false;
|
|
11
|
+
this.focused = false;
|
|
7
12
|
this.initialised = false;
|
|
8
|
-
|
|
13
|
+
this.everFocused = false;
|
|
14
|
+
//console.debug('autofocusDirective created.');
|
|
9
15
|
}
|
|
10
16
|
ngAfterViewInit() {
|
|
11
17
|
this.initialised = true;
|
|
@@ -15,19 +21,20 @@ export class AutofocusDirective {
|
|
|
15
21
|
if (!this.initialised) {
|
|
16
22
|
return;
|
|
17
23
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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.');
|
|
21
29
|
}
|
|
22
|
-
this.lastVisible = visible;
|
|
23
30
|
}
|
|
24
31
|
set autofocus(condition) {
|
|
25
|
-
this.
|
|
32
|
+
this.toFocus = condition !== false;
|
|
26
33
|
}
|
|
27
34
|
}
|
|
28
35
|
AutofocusDirective.decorators = [
|
|
29
36
|
{ type: Directive, args: [{
|
|
30
|
-
selector: '[autofocus]'
|
|
37
|
+
selector: '[autofocus]'
|
|
31
38
|
},] }
|
|
32
39
|
];
|
|
33
40
|
AutofocusDirective.ctorParameters = () => [
|
|
@@ -36,4 +43,4 @@ AutofocusDirective.ctorParameters = () => [
|
|
|
36
43
|
AutofocusDirective.propDecorators = {
|
|
37
44
|
autofocus: [{ type: Input }]
|
|
38
45
|
};
|
|
39
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
46
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXV0b2ZvY3VzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vcHJvamVjdHMvbm1jZS1kaXJlY3RpdmVzL3NyYy9fZGlyZWN0aXZlcy9hdXRvZm9jdXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFpQixTQUFTLEVBQVcsVUFBVSxFQUFFLEtBQUssRUFBRSxNQUFNLGVBQWUsQ0FBQztBQUVyRjs7OztHQUlHO0FBSUgsTUFBTSxPQUFPLGtCQUFrQjtJQUs5QixZQUFvQixFQUFjO1FBQWQsT0FBRSxHQUFGLEVBQUUsQ0FBWTtRQUoxQixZQUFPLEdBQUcsS0FBSyxDQUFDO1FBQ2hCLFlBQU8sR0FBRyxLQUFLLENBQUM7UUFDaEIsZ0JBQVcsR0FBRyxLQUFLLENBQUM7UUFDcEIsZ0JBQVcsR0FBRyxLQUFLLENBQUM7UUFFM0IsK0NBQStDO0lBQ2hELENBQUM7SUFFRCxlQUFlO1FBQ2QsSUFBSSxDQUFDLFdBQVcsR0FBRyxJQUFJLENBQUM7UU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MoKTtcclxuXHRcdFx0dGhpcy5mb2N1c2VkID0gdHJ1ZTtcclxuXHRcdFx0dGhpcy5ldmVyRm9jdXNlZCA9IHRydWU7XHJcblx0XHRcdGNvbnNvbGUuZGVidWcoJ2ZvY3VzZWQgbm93LicpO1xyXG5cdFx0fVxyXG5cdH1cclxuXHJcblx0QElucHV0KCkgc2V0IGF1dG9mb2N1cyhjb25kaXRpb246IGJvb2xlYW4pIHtcclxuXHRcdHRoaXMudG9Gb2N1cyA9IGNvbmRpdGlvbiAhPT0gZmFsc2U7XHJcblx0fVxyXG59XHJcbiJdfQ==
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { Directive,
|
|
1
|
+
import { Directive, ElementRef, HostListener } from '@angular/core';
|
|
2
2
|
import { CurrencyFunc } from 'nmce-func';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
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.
|
|
5
6
|
*/
|
|
6
7
|
export class CurrencyFormatterDirective {
|
|
7
8
|
constructor(elementRef) {
|
|
@@ -29,4 +30,4 @@ CurrencyFormatterDirective.propDecorators = {
|
|
|
29
30
|
onFocus: [{ type: HostListener, args: ['focus', ['$event.target.value'],] }],
|
|
30
31
|
onBlur: [{ type: HostListener, args: ['blur', ['$event.target.value'],] }]
|
|
31
32
|
};
|
|
32
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
33
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY3VycmVuY3lGb3JtYXR0ZXIuZGlyZWN0aXZlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vcHJvamVjdHMvbm1jZS1kaXJlY3RpdmVzL3NyYy9fZGlyZWN0aXZlcy9jdXJyZW5jeUZvcm1hdHRlci5kaXJlY3RpdmUudHMiXSwibmFtZXMiOltdLCJtYXBwa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W5jeSh0aGlzLmVsLnZhbHVlKTtcclxuXHR9XHJcblxyXG5cdEBIb3N0TGlzdGVuZXIoJ2ZvY3VzJywgWyckZXZlbnQudGFyZ2V0LnZhbHVlJ10pXHJcblx0b25Gb2N1cyh2YWx1ZTogc3RyaW5nKSB7XHJcblx0XHR0aGlzLmVsLnZhbHVlID0gQ3VycmVuY3lGdW5jLnBhcnNlQ3VycmVuY3kodmFsdWUpOyAvLyBvcG9zc2l0ZSBvZiB0cmFuc2Zvcm1cclxuXHR9XHJcblxyXG5cdEBIb3N0TGlzdGVuZXIoJ2JsdXInLCBbJyRldmVudC50YXJnZXQudmFsdWUnXSlcclxuXHRvbkJsdXIodmFsdWU6IHN0cmluZykge1xyXG5cdFx0dGhpcy5lbC52YWx1ZSA9IEN1cnJlbmN5RnVuYy50cmFuc2Zvcm1DdXJyZW5jeSh2YWx1ZSk7XHJcblx0fVxyXG5cclxufVxyXG5cclxuIl19
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { NgModule } from '@angular/core';
|
|
2
1
|
import { CommonModule } from '@angular/common';
|
|
2
|
+
import { NgModule } from '@angular/core';
|
|
3
3
|
import { FormsModule } from '@angular/forms';
|
|
4
|
-
import { AutofocusDirective,
|
|
4
|
+
import { AutofocusDirective, CurrencyFormatterDirective, DataComponentDirective, ScrollIntoDirective } from './index';
|
|
5
5
|
/**
|
|
6
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
7
|
*
|
|
@@ -16,20 +16,16 @@ NmceDirectivesModule.decorators = [
|
|
|
16
16
|
],
|
|
17
17
|
declarations: [
|
|
18
18
|
AutofocusDirective,
|
|
19
|
-
HighlightDirective,
|
|
20
19
|
CurrencyFormatterDirective,
|
|
21
|
-
DatetimeFormatterDirective,
|
|
22
20
|
ScrollIntoDirective,
|
|
23
21
|
DataComponentDirective,
|
|
24
22
|
],
|
|
25
23
|
exports: [
|
|
26
24
|
AutofocusDirective,
|
|
27
|
-
HighlightDirective,
|
|
28
25
|
CurrencyFormatterDirective,
|
|
29
|
-
DatetimeFormatterDirective,
|
|
30
26
|
ScrollIntoDirective,
|
|
31
27
|
DataComponentDirective,
|
|
32
28
|
]
|
|
33
29
|
},] }
|
|
34
30
|
];
|
|
35
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
31
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGlyZWN0aXZlcy5tb2R1bGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9wcm9qZWN0cy9ubWNlLWRpcmVjdGl2ZXMvc3JjL19kaXJlY3RpdmVzL2RpcmVjdGl2ZXMubW9kdWxlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxZQUFZLEVBQUUsTUFBTSxpQkFBaUIsQ0FBQztBQUMvQyxPQUFPLEVBQUUsUUFBUSxFQUFFLE1BQU0sZUFBZSxDQUFDO0FBQ3pDLE9BQU8sRUFBRSxXQUFXLEVBQUUsTUFBTSxnQkFBZ0IsQ0FBQztBQUM3QyxPQUFPLEVBQ04sa0JBQWtCLEVBQUUsMEJBQTBCLEVBQUUsc0JBQXNCLEVBQUUsbUJBQW1CLEVBQzNGLE1BQU0sU0FBUyxDQUFDO0FBSWpCOzs7R0FHRztBQXNCSCxNQUFNLE9BQU8sb0JBQW9COzs7WUFyQmhDLFFBQVEsU0FBQztnQkFDVCxPQUFPLEVBQUU7b0JBQ1IsWUFBWTtvQkFDWixXQUFXO2lCQUNYO2dCQUVELFlBQVksRUFBRTtvQkFDYixrQkFBa0I7b0JBQ2xCLDBCQUEwQjtvQkFDMUIsbUJBQW1CO29CQUNuQixzQkFBc0I7aUJBQ3RCO2dCQUdELE9BQU8sRUFBRTtvQkFDUixrQkFBa0I7b0JBQ2xCLDBCQUEwQjtvQkFDMUIsbUJBQW1CO29CQUNuQixzQkFBc0I7a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0XHRDdXJyZW5jeUZvcm1hdHRlckRpcmVjdGl2ZSxcclxuXHRcdFNjcm9sbEludG9EaXJlY3RpdmUsXHJcblx0XHREYXRhQ29tcG9uZW50RGlyZWN0aXZlLFxyXG5cdF1cclxufSlcclxuZXhwb3J0IGNsYXNzIE5tY2VEaXJlY3RpdmVzTW9kdWxlIHsgfVxyXG4iXX0=
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
export * from './autofocus';
|
|
2
|
-
export * from './highlight.directive';
|
|
3
2
|
export * from './currencyFormatter.directive';
|
|
4
|
-
export * from './datetimeFormatter.directive';
|
|
5
|
-
export * from './scrollInto.directive';
|
|
6
3
|
export * from './dataComponent.directive';
|
|
7
|
-
|
|
4
|
+
export * from './scrollInto.directive';
|
|
5
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9wcm9qZWN0cy9ubWNlLWRpcmVjdGl2ZXMvc3JjL19kaXJlY3RpdmVzL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGNBQWMsYUFBYSxDQUFDO0FBQzVCLGNBQWMsK0JBQStCLENBQUM7QUFDOUMsY0FBYywyQkFBMkIsQ0FBQztBQUMxQyxjQUFjLHdCQUF3QixDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0ICogZnJvbSAnLi9hdXRvZm9jdXMnO1xyXG5leHBvcnQgKiBmcm9tICcuL2N1cnJlbmN5Rm9ybWF0dGVyLmRpcmVjdGl2ZSc7XHJcbmV4cG9ydCAqIGZyb20gJy4vZGF0YUNvbXBvbmVudC5kaXJlY3RpdmUnO1xyXG5leHBvcnQgKiBmcm9tICcuL3Njcm9sbEludG8uZGlyZWN0aXZlJztcclxuIl19
|
|
@@ -1,4 +1,7 @@
|
|
|
1
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
|
+
*/
|
|
2
5
|
export class ScrollIntoDirective {
|
|
3
6
|
constructor(el) {
|
|
4
7
|
this.el = el;
|
|
@@ -22,4 +25,4 @@ ScrollIntoDirective.ctorParameters = () => [
|
|
|
22
25
|
ScrollIntoDirective.propDecorators = {
|
|
23
26
|
scrollInto: [{ type: Input }]
|
|
24
27
|
};
|
|
25
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
28
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2Nyb2xsSW50by5kaXJlY3RpdmUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9wcm9qZWN0cy9ubWNlLWRpcmVjdGl2ZXMvc3JjL19kaXJlY3RpdmVzL3Njcm9sbEludG8uZGlyZWN0aXZlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBaUIsU0FBUyxFQUFFLFVBQVUsRUFBRSxLQUFLLEVBQUUsTUFBTSxlQUFlLENBQUM7QUFFNUU7O0dBRUc7QUFJSCxNQUFNLE9BQU8sbUJBQW1CO0lBQy9CLFlBQW9CLEVBQWM7UUFBZCxPQUFFLEdBQUYsRUFBRSxDQUFZO1FBS2xDLGVBQVUsR0FBWSxLQUFLLENBQUM7UUFKM0IsaURBQWlEO0lBQ2xELENBQUM7SUFLRCxlQUFlO1FBQ2QsSUFBSSxJQUFJLENBQUMsVUFBVSxFQUFFO1lBQ3BCLElBQUksQ0FBQyxFQUFFLENBQUMsYUFBYSxDQUFDLGNBQWMsRUFBRSxDQUFDO1NBQ3ZDO0lBQ0YsQ0FBQzs7O1lBZkQsU0FBUyxTQUFDO2dCQUNWLFFBQVEsRUFBRSxjQUFjO2FBQ3hCOzs7WUFQa0MsVUFBVTs7O3lCQWEzQyxLQUFLIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgQWZ0ZXJWaWV3SW5pdCwgRGlyZWN0aXZlLCBFbGVtZW50UmVmLCBJbnB1dCB9IGZyb20gJ0Bhbmd1bGFyL2NvcmUnO1xyXG5cclxuLyoqXHJcbiAqIFNjcm9sbCB0byBlbGVtZW50IGF0dGFjaGVkLiBBbmQgdGhlIGVsZW1lbnQgbWF5IGJlIGFuIEFuZ3VsYXIgTWF0ZXJpYWwgY29tcG9uZW50IHRvby5cclxuICovXHJcbkBEaXJlY3RpdmUoe1xyXG5cdHNlbGVjdG9yOiAnW3Njcm9sbEludG9dJ1xyXG59KVxyXG5leHBvcnQgY2xhc3MgU2Nyb2xsSW50b0RpcmVjdGl2ZSBpbXBsZW1lbnRzIEFmdGVyVmlld0luaXQge1xyXG5cdGNvbnN0cnVjdG9yKHByaXZhdGUgZWw6IEVsZW1lbnRSZWYpIHtcclxuXHRcdC8vXHRjb25zb2xlLmRlYnVnKCdTY3JvbGxJbnRvRGlyZWN0aXZlIGNyZWF0ZWQuJyk7XHJcblx0fVxyXG5cclxuXHRASW5wdXQoKVxyXG5cdHNjcm9sbEludG86IGJvb2xlYW4gPSBmYWxzZTtcclxuXHJcblx0bmdBZnRlclZpZXdJbml0KCkge1xyXG5cdFx0aWYgKHRoaXMuc2Nyb2xsSW50bykge1xyXG5cdFx0XHR0aGlzLmVsLm5hdGl2ZUVsZW1lbnQuc2Nyb2xsSW50b1ZpZXcoKTtcclxuXHRcdH1cclxuXHR9XHJcbn1cclxuIl19
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
import { Directive, ElementRef, Input, HostListener, ViewContainerRef, NgModule } from '@angular/core';
|
|
2
2
|
import { CurrencyFunc } from 'nmce-func';
|
|
3
|
-
import moment from 'moment';
|
|
4
3
|
import { CommonModule } from '@angular/common';
|
|
5
4
|
import { FormsModule } from '@angular/forms';
|
|
6
5
|
|
|
7
|
-
|
|
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
|
+
*/
|
|
8
11
|
class AutofocusDirective {
|
|
9
12
|
constructor(el) {
|
|
10
13
|
this.el = el;
|
|
11
|
-
this.
|
|
14
|
+
this.toFocus = false;
|
|
15
|
+
this.focused = false;
|
|
12
16
|
this.initialised = false;
|
|
13
|
-
|
|
17
|
+
this.everFocused = false;
|
|
18
|
+
//console.debug('autofocusDirective created.');
|
|
14
19
|
}
|
|
15
20
|
ngAfterViewInit() {
|
|
16
21
|
this.initialised = true;
|
|
@@ -20,19 +25,20 @@ class AutofocusDirective {
|
|
|
20
25
|
if (!this.initialised) {
|
|
21
26
|
return;
|
|
22
27
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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.');
|
|
26
33
|
}
|
|
27
|
-
this.lastVisible = visible;
|
|
28
34
|
}
|
|
29
35
|
set autofocus(condition) {
|
|
30
|
-
this.
|
|
36
|
+
this.toFocus = condition !== false;
|
|
31
37
|
}
|
|
32
38
|
}
|
|
33
39
|
AutofocusDirective.decorators = [
|
|
34
40
|
{ type: Directive, args: [{
|
|
35
|
-
selector: '[autofocus]'
|
|
41
|
+
selector: '[autofocus]'
|
|
36
42
|
},] }
|
|
37
43
|
];
|
|
38
44
|
AutofocusDirective.ctorParameters = () => [
|
|
@@ -42,38 +48,9 @@ AutofocusDirective.propDecorators = {
|
|
|
42
48
|
autofocus: [{ type: Input }]
|
|
43
49
|
};
|
|
44
50
|
|
|
45
|
-
class HighlightDirective {
|
|
46
|
-
constructor(el) {
|
|
47
|
-
this.el = el;
|
|
48
|
-
console.debug('HighlightDirective created.');
|
|
49
|
-
}
|
|
50
|
-
onMouseEnter() {
|
|
51
|
-
this.highlight(this.highlightColor || this.defaultColor || 'red');
|
|
52
|
-
}
|
|
53
|
-
onMouseLeave() {
|
|
54
|
-
this.highlight(undefined);
|
|
55
|
-
}
|
|
56
|
-
highlight(color) {
|
|
57
|
-
this.el.nativeElement.style.backgroundColor = color;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
HighlightDirective.decorators = [
|
|
61
|
-
{ type: Directive, args: [{
|
|
62
|
-
selector: '[myHighlight]'
|
|
63
|
-
},] }
|
|
64
|
-
];
|
|
65
|
-
HighlightDirective.ctorParameters = () => [
|
|
66
|
-
{ type: ElementRef }
|
|
67
|
-
];
|
|
68
|
-
HighlightDirective.propDecorators = {
|
|
69
|
-
defaultColor: [{ type: Input }],
|
|
70
|
-
highlightColor: [{ type: Input, args: ['myHighlight',] }],
|
|
71
|
-
onMouseEnter: [{ type: HostListener, args: ['mouseenter',] }],
|
|
72
|
-
onMouseLeave: [{ type: HostListener, args: ['mouseleave',] }]
|
|
73
|
-
};
|
|
74
|
-
|
|
75
51
|
/**
|
|
76
|
-
*
|
|
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.
|
|
77
54
|
*/
|
|
78
55
|
class CurrencyFormatterDirective {
|
|
79
56
|
constructor(elementRef) {
|
|
@@ -102,57 +79,23 @@ CurrencyFormatterDirective.propDecorators = {
|
|
|
102
79
|
onBlur: [{ type: HostListener, args: ['blur', ['$event.target.value'],] }]
|
|
103
80
|
};
|
|
104
81
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
class DatetimeFormatterDirective {
|
|
109
|
-
constructor(elementRef) {
|
|
110
|
-
this.elementRef = elementRef;
|
|
111
|
-
//@Input('datetimeFormatter')
|
|
112
|
-
this.format = 'DD/MM/YYYY HH:mm';
|
|
113
|
-
this.formats = ['', 'DD/MM/YYYY HH:mm'];
|
|
114
|
-
this.el = this.elementRef.nativeElement;
|
|
115
|
-
}
|
|
116
|
-
ngOnInit() {
|
|
117
|
-
const s = this.parse(this.el.value);
|
|
118
|
-
this.el.value = this.transform(s);
|
|
119
|
-
}
|
|
120
|
-
onFocus() {
|
|
121
|
-
const s = this.parse(this.el.value);
|
|
122
|
-
this.el.value = this.transform(s);
|
|
123
|
-
}
|
|
124
|
-
onBlur() {
|
|
125
|
-
this.el.value = this.transform(this.el.value);
|
|
126
|
-
}
|
|
127
|
-
transform(value) {
|
|
128
|
-
if (!value) {
|
|
129
|
-
return '';
|
|
130
|
-
}
|
|
131
|
-
const s = moment(value).format(this.format);
|
|
132
|
-
console.debug(`With format ${this.format} transform to ${s}`);
|
|
133
|
-
return s;
|
|
134
|
-
}
|
|
135
|
-
parse(value) {
|
|
136
|
-
if (!value) {
|
|
137
|
-
return null;
|
|
138
|
-
}
|
|
139
|
-
const d = moment(value, this.formats).toDate();
|
|
140
|
-
console.debug(`parse ${value} to ${d}`);
|
|
141
|
-
return d;
|
|
82
|
+
class DataComponentDirective {
|
|
83
|
+
constructor(viewContainerRef) {
|
|
84
|
+
this.viewContainerRef = viewContainerRef;
|
|
142
85
|
}
|
|
143
86
|
}
|
|
144
|
-
|
|
145
|
-
{ type: Directive, args: [{
|
|
146
|
-
|
|
147
|
-
]
|
|
148
|
-
DatetimeFormatterDirective.ctorParameters = () => [
|
|
149
|
-
{ type: ElementRef }
|
|
87
|
+
DataComponentDirective.decorators = [
|
|
88
|
+
{ type: Directive, args: [{
|
|
89
|
+
selector: '[dataComponentHost]',
|
|
90
|
+
},] }
|
|
150
91
|
];
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
};
|
|
92
|
+
DataComponentDirective.ctorParameters = () => [
|
|
93
|
+
{ type: ViewContainerRef }
|
|
94
|
+
];
|
|
155
95
|
|
|
96
|
+
/**
|
|
97
|
+
* Scroll to element attached. And the element may be an Angular Material component too.
|
|
98
|
+
*/
|
|
156
99
|
class ScrollIntoDirective {
|
|
157
100
|
constructor(el) {
|
|
158
101
|
this.el = el;
|
|
@@ -177,20 +120,6 @@ ScrollIntoDirective.propDecorators = {
|
|
|
177
120
|
scrollInto: [{ type: Input }]
|
|
178
121
|
};
|
|
179
122
|
|
|
180
|
-
class DataComponentDirective {
|
|
181
|
-
constructor(viewContainerRef) {
|
|
182
|
-
this.viewContainerRef = viewContainerRef;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
DataComponentDirective.decorators = [
|
|
186
|
-
{ type: Directive, args: [{
|
|
187
|
-
selector: '[dataComponentHost]',
|
|
188
|
-
},] }
|
|
189
|
-
];
|
|
190
|
-
DataComponentDirective.ctorParameters = () => [
|
|
191
|
-
{ type: ViewContainerRef }
|
|
192
|
-
];
|
|
193
|
-
|
|
194
123
|
/**
|
|
195
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.
|
|
196
125
|
*
|
|
@@ -205,17 +134,13 @@ NmceDirectivesModule.decorators = [
|
|
|
205
134
|
],
|
|
206
135
|
declarations: [
|
|
207
136
|
AutofocusDirective,
|
|
208
|
-
HighlightDirective,
|
|
209
137
|
CurrencyFormatterDirective,
|
|
210
|
-
DatetimeFormatterDirective,
|
|
211
138
|
ScrollIntoDirective,
|
|
212
139
|
DataComponentDirective,
|
|
213
140
|
],
|
|
214
141
|
exports: [
|
|
215
142
|
AutofocusDirective,
|
|
216
|
-
HighlightDirective,
|
|
217
143
|
CurrencyFormatterDirective,
|
|
218
|
-
DatetimeFormatterDirective,
|
|
219
144
|
ScrollIntoDirective,
|
|
220
145
|
DataComponentDirective,
|
|
221
146
|
]
|
|
@@ -230,5 +155,5 @@ NmceDirectivesModule.decorators = [
|
|
|
230
155
|
* Generated bundle index. Do not edit.
|
|
231
156
|
*/
|
|
232
157
|
|
|
233
|
-
export { AutofocusDirective, CurrencyFormatterDirective, DataComponentDirective,
|
|
158
|
+
export { AutofocusDirective, CurrencyFormatterDirective, DataComponentDirective, NmceDirectivesModule, ScrollIntoDirective };
|
|
234
159
|
//# sourceMappingURL=nmce-directives.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nmce-directives.js","sources":["../../../projects/nmce-directives/src/_directives/autofocus.ts","../../../projects/nmce-directives/src/_directives/highlight.directive.ts","../../../projects/nmce-directives/src/_directives/currencyFormatter.directive.ts","../../../projects/nmce-directives/src/_directives/datetimeFormatter.directive.ts","../../../projects/nmce-directives/src/_directives/scrollInto.directive.ts","../../../projects/nmce-directives/src/_directives/dataComponent.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 { Directive, AfterViewInit, ElementRef, DoCheck, Input } from '@angular/core';\r\n\r\n\r\n// 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/\r\n@Directive({\r\n\tselector: '[autofocus]' // using [ ] means selecting attributes\r\n})\r\n\r\nexport class AutofocusDirective implements AfterViewInit, DoCheck {\r\n\tprivate lastVisible = false;\r\n\tprivate initialised = false;\r\n\tconstructor(private el: ElementRef) {\r\n\t\tconsole.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\tconst visible = !!this.el.nativeElement.offsetParent;\r\n\t\tif (visible && !this.lastVisible) {\r\n\t\t\tsetTimeout(() => { this.el.nativeElement.focus(); }, 2); //no need to clearTimeout\r\n\t\t}\r\n\t\tthis.lastVisible = visible;\r\n\t}\r\n\r\n\t@Input() set autofocus(condition: boolean) {\r\n\t\tthis.lastVisible = condition !== false;\r\n\t}\r\n}\r\n","import { Directive, ElementRef, HostListener, Input } from '@angular/core';\r\n@Directive({\r\n\tselector: '[myHighlight]'\r\n})\r\nexport class HighlightDirective {\r\n\tconstructor(private el: ElementRef) {\r\n\t\tconsole.debug('HighlightDirective created.');\r\n\t}\r\n\r\n\t@Input() defaultColor?: string;\r\n\t@Input('myHighlight') highlightColor?: string;\r\n\t@HostListener('mouseenter') onMouseEnter() {\r\n\t\tthis.highlight(this.highlightColor || this.defaultColor || 'red');\r\n\t}\r\n\t@HostListener('mouseleave') onMouseLeave() {\r\n\t\tthis.highlight(undefined);\r\n\t}\r\n\tprivate highlight(color: string | undefined) {\r\n\t\tthis.el.nativeElement.style.backgroundColor = color;\r\n\t}\r\n}\r\n","import { Directive, HostListener, ElementRef, OnInit } from '@angular/core';\r\nimport { CurrencyFunc } from 'nmce-func';\r\n\r\n/**\r\n *\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, HostListener, ElementRef, OnInit } from '@angular/core';\r\nimport moment from 'moment';\r\n\r\n/**\r\n *\r\n */\r\n@Directive({ selector: '[datetimeFormatter]' })//inspired by https://blog.ngconsultant.io/custom-input-formatting-with-simple-directives-for-angular-2-ec792082976\r\nexport class DatetimeFormatterDirective implements OnInit {\r\n\r\n\tprivate el: HTMLInputElement;\r\n\r\n\t//@Input('datetimeFormatter')\r\n\tformat = 'DD/MM/YYYY HH:mm';\r\n\r\n\tformats = ['', 'DD/MM/YYYY HH:mm'];\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\tconst s = this.parse(this.el.value);\r\n\t\tthis.el.value = this.transform(s);\r\n\t}\r\n\r\n\t@HostListener('focus', ['$event.target.value'])\r\n\tonFocus() {\r\n\t\tconst s = this.parse(this.el.value);\r\n\t\tthis.el.value = this.transform(s);\r\n\t}\r\n\r\n\t@HostListener('blur', ['$event.target.value'])\r\n\tonBlur() {\r\n\t\tthis.el.value = this.transform(this.el.value);\r\n\t}\r\n\r\n\ttransform(value: Date | string | null): string {\r\n\t\tif (!value) {\r\n\t\t\treturn '';\r\n\t\t}\r\n\r\n\t\tconst s = moment(value).format(this.format);\r\n\t\tconsole.debug(`With format ${this.format} transform to ${s}`);\r\n\t\treturn s;\r\n\t}\r\n\r\n\tparse(value: string): Date | null {\r\n\t\tif (!value) {\r\n\t\t\treturn null;\r\n\t\t}\r\n\r\n\t\tconst d = moment(value, this.formats).toDate();\r\n\t\tconsole.debug(`parse ${value} to ${d}`);\r\n\t\treturn d;\r\n\t}\r\n\r\n}\r\n\r\n","import { AfterViewInit, Directive, ElementRef, Input } from '@angular/core';\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 { 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 { NgModule } from '@angular/core';\r\nimport { CommonModule } from '@angular/common';\r\nimport { FormsModule } from '@angular/forms';\r\n\r\n\r\nimport {\r\n\tAutofocusDirective, HighlightDirective, CurrencyFormatterDirective, DatetimeFormatterDirective, ScrollIntoDirective, DataComponentDirective,\r\n} from './index';\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\tHighlightDirective,\r\n\t\tCurrencyFormatterDirective,\r\n\t\tDatetimeFormatterDirective,\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\tHighlightDirective,\r\n\t\tCurrencyFormatterDirective,\r\n\t\tDatetimeFormatterDirective,\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":";;;;;;AAGA;MAKa,kBAAkB;IAG9B,YAAoB,EAAc;QAAd,OAAE,GAAF,EAAE,CAAY;QAF1B,gBAAW,GAAG,KAAK,CAAC;QACpB,gBAAW,GAAG,KAAK,CAAC;QAE3B,OAAO,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;KAC7C;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;QA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AqB;aAC/B;;;YAJmB,gBAAgB;;;ACSpC;;;;MA6Ba,oBAAoB;;;YAzBhC,QAAQ,SAAC;gBACT,OAAO,EAAE;oBACR,YAAY;oBACZ,WAAW;iBACX;gBAED,YAAY,EAAE;oBACb,kBAAkB;oBAClB,kBAAkB;oBAClB,0BAA0B;oBAC1B,0BAA0B;oBAC1B,mBAAmB;oBACnB,sBAAsB;iBACtB;gBAGD,OAAO,EAAE;oBACR,kBAAkB;oBAClB,kBAAkB;oBAClB,0BAA0B;oBAC1B,0BAA0B;oBAC1B,mBAAmB;oBACnB,sBAAsB;iBACtB;aACD;;;ACrCD;;;;ACAA;;;;;;"}
|
|
1
|
+
{"version":3,"file":"nmce-directives.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":[],"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,SAA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;;MCpBjC,sBAAsB;IAClC,YAAmB,gBAAkC;QAAlC,qBAAgB,GAAhB,gBAAgB,CAAkB;KAAK;;;YAJ1D,SAAS,SAAC;gBACV,QAAQ,EAAE,qBAAqB;aAC/B;;;YAJmB,gBAAgB;;;ACEpC;;;MAMa,mBAAmB;IAC/B,YAAoB,EAAc;QAAd,OAAE,GAAF,EAAE,CAAY;QAKlC,eAAU,GAAY,KAAK,CAAC;;KAH3B;IAKD,eAAe;QACd,IAAI,IAAI,CAAC,UAAU,EAAE;YACpB,IAAI,CAAC,EAAE,CAAC,aAAa,CAAC,cAAc,EAAE,CAAC;SACvC;KACD;;;YAfD,SAAS,SAAC;gBACV,QAAQ,EAAE,cAAc;aACxB;;;YAPkC,UAAU;;;yBAa3C,KAAK;;;ACJP;;;;MAyBa,oBAAoB;;;YArBhC,QAAQ,SAAC;gBACT,OAAO,EAAE;oBACR,YAAY;oBACZ,WAAW;iBACX;gBAED,YAAY,EAAE;oBACb,kBAAkB;oBAClB,0BAA0B;oBAC1B,mBAAmB;oBACnB,sBAAsB;iBACtB;gBAGD,OAAO,EAAE;oBACR,kBAAkB;oBAClB,0BAA0B;oBAC1B,mBAAmB;oBACnB,sBAAsB;iBACtB;aACD;;;ACjCD;;;;ACAA;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"__symbolic":"module","version":4,"metadata":{"AutofocusDirective":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Directive","line":
|
|
1
|
+
{"__symbolic":"module","version":4,"metadata":{"AutofocusDirective":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Directive","line":7,"character":1},"arguments":[{"selector":"[autofocus]"}]}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/core","name":"ElementRef","line":15,"character":25}]}],"ngAfterViewInit":[{"__symbolic":"method"}],"ngDoCheck":[{"__symbolic":"method"}],"autofocus":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":34,"character":2}}]}]}},"CurrencyFormatterDirective":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Directive","line":7,"character":1},"arguments":[{"selector":"[currencyFormatter]"}]}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/core","name":"ElementRef","line":12,"character":33}]}],"ngOnInit":[{"__symbolic":"method"}],"onFocus":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"HostListener","line":20,"character":2},"arguments":["focus",["$event.target.value"]]}]}],"onBlur":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"HostListener","line":25,"character":2},"arguments":["blur",["$event.target.value"]]}]}]}},"DataComponentDirective":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Directive","line":2,"character":1},"arguments":[{"selector":"[dataComponentHost]"}]}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/core","name":"ViewContainerRef","line":6,"character":38}]}]}},"ScrollIntoDirective":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Directive","line":5,"character":1},"arguments":[{"selector":"[scrollInto]"}]}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/core","name":"ElementRef","line":9,"character":25}]}],"scrollInto":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":13,"character":2}}]}],"ngAfterViewInit":[{"__symbolic":"method"}]}},"NmceDirectivesModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule","line":13,"character":1},"arguments":[{"imports":[{"__symbolic":"reference","module":"@angular/common","name":"CommonModule","line":15,"character":2},{"__symbolic":"reference","module":"@angular/forms","name":"FormsModule","line":16,"character":2}],"declarations":[{"__symbolic":"reference","name":"AutofocusDirective"},{"__symbolic":"reference","name":"CurrencyFormatterDirective"},{"__symbolic":"reference","name":"ScrollIntoDirective"},{"__symbolic":"reference","name":"DataComponentDirective"}],"exports":[{"__symbolic":"reference","name":"AutofocusDirective"},{"__symbolic":"reference","name":"CurrencyFormatterDirective"},{"__symbolic":"reference","name":"ScrollIntoDirective"},{"__symbolic":"reference","name":"DataComponentDirective"}]}]}],"members":{}}},"origins":{"AutofocusDirective":"./_directives/autofocus","CurrencyFormatterDirective":"./_directives/currencyFormatter.directive","DataComponentDirective":"./_directives/dataComponent.directive","ScrollIntoDirective":"./_directives/scrollInto.directive","NmceDirectivesModule":"./_directives/directives.module"},"importAs":"nmce-directives"}
|
package/package.json
CHANGED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { ElementRef, OnInit } from '@angular/core';
|
|
2
|
-
/**
|
|
3
|
-
*
|
|
4
|
-
*/
|
|
5
|
-
export declare class DatetimeFormatterDirective implements OnInit {
|
|
6
|
-
private elementRef;
|
|
7
|
-
private el;
|
|
8
|
-
format: string;
|
|
9
|
-
formats: string[];
|
|
10
|
-
constructor(elementRef: ElementRef);
|
|
11
|
-
ngOnInit(): void;
|
|
12
|
-
onFocus(): void;
|
|
13
|
-
onBlur(): void;
|
|
14
|
-
transform(value: Date | string | null): string;
|
|
15
|
-
parse(value: string): Date | null;
|
|
16
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { Directive, HostListener, ElementRef } from '@angular/core';
|
|
2
|
-
import moment from 'moment';
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
*/
|
|
6
|
-
export class DatetimeFormatterDirective {
|
|
7
|
-
constructor(elementRef) {
|
|
8
|
-
this.elementRef = elementRef;
|
|
9
|
-
//@Input('datetimeFormatter')
|
|
10
|
-
this.format = 'DD/MM/YYYY HH:mm';
|
|
11
|
-
this.formats = ['', 'DD/MM/YYYY HH:mm'];
|
|
12
|
-
this.el = this.elementRef.nativeElement;
|
|
13
|
-
}
|
|
14
|
-
ngOnInit() {
|
|
15
|
-
const s = this.parse(this.el.value);
|
|
16
|
-
this.el.value = this.transform(s);
|
|
17
|
-
}
|
|
18
|
-
onFocus() {
|
|
19
|
-
const s = this.parse(this.el.value);
|
|
20
|
-
this.el.value = this.transform(s);
|
|
21
|
-
}
|
|
22
|
-
onBlur() {
|
|
23
|
-
this.el.value = this.transform(this.el.value);
|
|
24
|
-
}
|
|
25
|
-
transform(value) {
|
|
26
|
-
if (!value) {
|
|
27
|
-
return '';
|
|
28
|
-
}
|
|
29
|
-
const s = moment(value).format(this.format);
|
|
30
|
-
console.debug(`With format ${this.format} transform to ${s}`);
|
|
31
|
-
return s;
|
|
32
|
-
}
|
|
33
|
-
parse(value) {
|
|
34
|
-
if (!value) {
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
const d = moment(value, this.formats).toDate();
|
|
38
|
-
console.debug(`parse ${value} to ${d}`);
|
|
39
|
-
return d;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
DatetimeFormatterDirective.decorators = [
|
|
43
|
-
{ type: Directive, args: [{ selector: '[datetimeFormatter]' }, //inspired by https://blog.ngconsultant.io/custom-input-formatting-with-simple-directives-for-angular-2-ec792082976
|
|
44
|
-
] }
|
|
45
|
-
];
|
|
46
|
-
DatetimeFormatterDirective.ctorParameters = () => [
|
|
47
|
-
{ type: ElementRef }
|
|
48
|
-
];
|
|
49
|
-
DatetimeFormatterDirective.propDecorators = {
|
|
50
|
-
onFocus: [{ type: HostListener, args: ['focus', ['$event.target.value'],] }],
|
|
51
|
-
onBlur: [{ type: HostListener, args: ['blur', ['$event.target.value'],] }]
|
|
52
|
-
};
|
|
53
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLC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 -1,31 +0,0 @@
|
|
|
1
|
-
import { Directive, ElementRef, HostListener, Input } from '@angular/core';
|
|
2
|
-
export class HighlightDirective {
|
|
3
|
-
constructor(el) {
|
|
4
|
-
this.el = el;
|
|
5
|
-
console.debug('HighlightDirective created.');
|
|
6
|
-
}
|
|
7
|
-
onMouseEnter() {
|
|
8
|
-
this.highlight(this.highlightColor || this.defaultColor || 'red');
|
|
9
|
-
}
|
|
10
|
-
onMouseLeave() {
|
|
11
|
-
this.highlight(undefined);
|
|
12
|
-
}
|
|
13
|
-
highlight(color) {
|
|
14
|
-
this.el.nativeElement.style.backgroundColor = color;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
HighlightDirective.decorators = [
|
|
18
|
-
{ type: Directive, args: [{
|
|
19
|
-
selector: '[myHighlight]'
|
|
20
|
-
},] }
|
|
21
|
-
];
|
|
22
|
-
HighlightDirective.ctorParameters = () => [
|
|
23
|
-
{ type: ElementRef }
|
|
24
|
-
];
|
|
25
|
-
HighlightDirective.propDecorators = {
|
|
26
|
-
defaultColor: [{ type: Input }],
|
|
27
|
-
highlightColor: [{ type: Input, args: ['myHighlight',] }],
|
|
28
|
-
onMouseEnter: [{ type: HostListener, args: ['mouseenter',] }],
|
|
29
|
-
onMouseLeave: [{ type: HostListener, args: ['mouseleave',] }]
|
|
30
|
-
};
|
|
31
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaGlnaGxpZ2h0LmRpcmVjdGl2ZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3Byb2plY3RzL25tY2UtZGlyZWN0aXZlcy9zcmMvX2RpcmVjdGl2ZXMvaGlnaGxpZ2h0LmRpcmVjdGl2ZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsU0FBUyxFQUFFLFVBQVUsRUFBRSxZQUFZLEVBQUUsS0FBSyxFQUFF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