@skyux/autonumeric 5.0.1 → 5.5.0-beta.0
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/README.md +4 -67
- package/bundles/skyux-autonumeric.umd.js +27 -52
- package/documentation.json +112 -80
- package/esm2015/index.js +7 -0
- package/esm2015/index.js.map +1 -0
- package/esm2015/lib/modules/autonumeric/autonumeric-options-provider.js +24 -0
- package/esm2015/lib/modules/autonumeric/autonumeric-options-provider.js.map +1 -0
- package/esm2015/lib/modules/autonumeric/autonumeric-options.js +2 -0
- package/esm2015/lib/modules/autonumeric/autonumeric-options.js.map +1 -0
- package/esm2015/lib/modules/autonumeric/autonumeric.directive.js +171 -0
- package/esm2015/lib/modules/autonumeric/autonumeric.directive.js.map +1 -0
- package/esm2015/lib/modules/autonumeric/autonumeric.module.js +19 -0
- package/esm2015/lib/modules/autonumeric/autonumeric.module.js.map +1 -0
- package/esm2015/skyux-autonumeric.js +2 -2
- package/esm2015/skyux-autonumeric.js.map +1 -0
- package/fesm2015/skyux-autonumeric.js +24 -49
- package/fesm2015/skyux-autonumeric.js.map +1 -1
- package/index.d.ts +4 -0
- package/{modules → lib/modules}/autonumeric/autonumeric-options-provider.d.ts +0 -0
- package/{modules → lib/modules}/autonumeric/autonumeric-options.d.ts +0 -0
- package/{modules → lib/modules}/autonumeric/autonumeric.directive.d.ts +2 -3
- package/{modules → lib/modules}/autonumeric/autonumeric.module.d.ts +0 -0
- package/package.json +18 -4
- package/skyux-autonumeric.d.ts +1 -1
- package/LICENSE +0 -21
- package/bundles/skyux-autonumeric.umd.js.map +0 -1
- package/esm2015/modules/autonumeric/autonumeric-options-provider.js +0 -24
- package/esm2015/modules/autonumeric/autonumeric-options.js +0 -2
- package/esm2015/modules/autonumeric/autonumeric.directive.js +0 -181
- package/esm2015/modules/autonumeric/autonumeric.module.js +0 -33
- package/esm2015/public-api.js +0 -7
- package/public-api.d.ts +0 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autonumeric-options.js","sourceRoot":"","sources":["../../../../../../../../libs/components/autonumeric/src/lib/modules/autonumeric/autonumeric-options.ts"],"names":[],"mappings":"","sourcesContent":["import AutoNumeric from 'autonumeric';\n\n/**\n * Specifies custom options to provide directly to the underlying [autoNumeric utility](https://github.com/autoNumeric/autoNumeric).\n * The value can be set to `string`, which is an alias that represents\n * a [set of predefined set of options](https://github.com/autoNumeric/autoNumeric#predefined-options)\n * for a currency or language, or `Options`, which is a\n * [custom set of options](https://github.com/autoNumeric/autoNumeric#options)\n * that override any default options that the `skyAutonumeric` attribute specifies.\n */\nexport type SkyAutonumericOptions =\n | string\n | keyof AutoNumeric.PredefinedOptions\n | AutoNumeric.Options;\n"]}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { ChangeDetectorRef, Directive, ElementRef, forwardRef, HostListener, Input, Renderer2, } from '@angular/core';
|
|
2
|
+
import { NG_VALIDATORS, NG_VALUE_ACCESSOR, } from '@angular/forms';
|
|
3
|
+
import AutoNumeric from 'autonumeric';
|
|
4
|
+
import { fromEvent, Subject } from 'rxjs';
|
|
5
|
+
import { takeUntil } from 'rxjs/operators';
|
|
6
|
+
import { SkyAutonumericOptionsProvider } from './autonumeric-options-provider';
|
|
7
|
+
import * as i0 from "@angular/core";
|
|
8
|
+
import * as i1 from "./autonumeric-options-provider";
|
|
9
|
+
// tslint:disable:no-forward-ref no-use-before-declare
|
|
10
|
+
const SKY_AUTONUMERIC_VALUE_ACCESSOR = {
|
|
11
|
+
provide: NG_VALUE_ACCESSOR,
|
|
12
|
+
useExisting: forwardRef(() => SkyAutonumericDirective),
|
|
13
|
+
multi: true,
|
|
14
|
+
};
|
|
15
|
+
const SKY_AUTONUMERIC_VALIDATOR = {
|
|
16
|
+
provide: NG_VALIDATORS,
|
|
17
|
+
useExisting: forwardRef(() => SkyAutonumericDirective),
|
|
18
|
+
multi: true,
|
|
19
|
+
};
|
|
20
|
+
// tslint:enable
|
|
21
|
+
/**
|
|
22
|
+
* Wraps the [autoNumeric utility](https://github.com/autoNumeric/autoNumeric) to format
|
|
23
|
+
* any type of number, including currency.
|
|
24
|
+
*/
|
|
25
|
+
export class SkyAutonumericDirective {
|
|
26
|
+
constructor(elementRef, globalConfig, renderer, changeDetector) {
|
|
27
|
+
this.elementRef = elementRef;
|
|
28
|
+
this.globalConfig = globalConfig;
|
|
29
|
+
this.renderer = renderer;
|
|
30
|
+
this.changeDetector = changeDetector;
|
|
31
|
+
this.isFirstChange = true;
|
|
32
|
+
this.ngUnsubscribe = new Subject();
|
|
33
|
+
/* istanbul ignore next */
|
|
34
|
+
this.onChange = (_) => { };
|
|
35
|
+
/* istanbul ignore next */
|
|
36
|
+
this.onTouched = () => { };
|
|
37
|
+
this.autonumericInstance = new AutoNumeric(this.elementRef.nativeElement);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Assigns the name of a property from `SkyAutonumericOptionsProvider`.
|
|
41
|
+
*/
|
|
42
|
+
set skyAutonumeric(value) {
|
|
43
|
+
this.autonumericOptions = this.mergeOptions(value);
|
|
44
|
+
this.updateAutonumericInstance();
|
|
45
|
+
}
|
|
46
|
+
ngOnInit() {
|
|
47
|
+
// Ensure that we set the global config even if no local config has been given.
|
|
48
|
+
if (!this.autonumericOptions) {
|
|
49
|
+
this.autonumericOptions = this.globalConfig.getConfig();
|
|
50
|
+
}
|
|
51
|
+
this.updateAutonumericInstance();
|
|
52
|
+
fromEvent(this.elementRef.nativeElement, 'input')
|
|
53
|
+
.pipe(takeUntil(this.ngUnsubscribe))
|
|
54
|
+
.subscribe(() => {
|
|
55
|
+
const numericValue = this.getNumericValue();
|
|
56
|
+
/* istanbul ignore else */
|
|
57
|
+
if (this.value !== numericValue) {
|
|
58
|
+
this.value = numericValue;
|
|
59
|
+
this.onChange(numericValue);
|
|
60
|
+
}
|
|
61
|
+
/* istanbul ignore else */
|
|
62
|
+
if (this.control && !this.control.dirty) {
|
|
63
|
+
this.control.markAsDirty();
|
|
64
|
+
}
|
|
65
|
+
this.changeDetector.markForCheck();
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
ngOnDestroy() {
|
|
69
|
+
this.ngUnsubscribe.next();
|
|
70
|
+
this.ngUnsubscribe.complete();
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Implemented as part of ControlValueAccessor.
|
|
74
|
+
*/
|
|
75
|
+
setDisabledState(value) {
|
|
76
|
+
this.renderer.setProperty(this.elementRef.nativeElement, 'disabled', value);
|
|
77
|
+
}
|
|
78
|
+
writeValue(value) {
|
|
79
|
+
if (this.value !== value) {
|
|
80
|
+
this.value = value;
|
|
81
|
+
this.onChange(value);
|
|
82
|
+
// Mark the control as "pristine" if it is initialized with a value.
|
|
83
|
+
const initializedWithValue = this.isFirstChange && this.control && this.value !== null;
|
|
84
|
+
if (initializedWithValue) {
|
|
85
|
+
this.isFirstChange = false;
|
|
86
|
+
this.control.markAsPristine();
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (typeof value === 'number') {
|
|
90
|
+
this.autonumericInstance.set(value);
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
this.autonumericInstance.clear();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
validate(control) {
|
|
97
|
+
const noErrors = null; // tslint:disable-line: no-null-keyword
|
|
98
|
+
if (!this.control) {
|
|
99
|
+
this.control = control;
|
|
100
|
+
}
|
|
101
|
+
if (control.value === null || control.value === undefined) {
|
|
102
|
+
return noErrors;
|
|
103
|
+
}
|
|
104
|
+
if (typeof control.value !== 'number') {
|
|
105
|
+
return {
|
|
106
|
+
notTypeOfNumber: { value: control.value },
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
return noErrors;
|
|
110
|
+
}
|
|
111
|
+
registerOnChange(fn) {
|
|
112
|
+
this.onChange = fn;
|
|
113
|
+
}
|
|
114
|
+
registerOnTouched(fn) {
|
|
115
|
+
this.onTouched = fn;
|
|
116
|
+
}
|
|
117
|
+
onBlur() {
|
|
118
|
+
this.onTouched();
|
|
119
|
+
}
|
|
120
|
+
getNumericValue() {
|
|
121
|
+
const inputValue = this.getInputValue();
|
|
122
|
+
return inputValue && !this.isInputValueTheCurrencySymbol(inputValue)
|
|
123
|
+
? this.autonumericInstance.getNumber()
|
|
124
|
+
: undefined;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Due to AutoNumeric's hover logic - when AutoNumeric has a currency symbol the value
|
|
128
|
+
* that we get back on empty fields will be the currency symbol.
|
|
129
|
+
* The following logic ensures that we don't accidentally set
|
|
130
|
+
* a form value when the only input was the programatically-added currency symbol.
|
|
131
|
+
*/
|
|
132
|
+
isInputValueTheCurrencySymbol(inputValue) {
|
|
133
|
+
var _a, _b;
|
|
134
|
+
/* istanbul ignore next */
|
|
135
|
+
const currencySymbol = ((_b = (_a = this.autonumericOptions) === null || _a === void 0 ? void 0 : _a.currencySymbol) !== null && _b !== void 0 ? _b : '').trim();
|
|
136
|
+
return !!currencySymbol && inputValue === currencySymbol;
|
|
137
|
+
}
|
|
138
|
+
getInputValue() {
|
|
139
|
+
return this.elementRef.nativeElement.value;
|
|
140
|
+
}
|
|
141
|
+
updateAutonumericInstance() {
|
|
142
|
+
this.autonumericInstance.update(this.autonumericOptions);
|
|
143
|
+
}
|
|
144
|
+
mergeOptions(value) {
|
|
145
|
+
const globalOptions = this.globalConfig.getConfig();
|
|
146
|
+
let newOptions;
|
|
147
|
+
if (typeof value === 'string') {
|
|
148
|
+
const predefinedOptions = AutoNumeric.getPredefinedOptions();
|
|
149
|
+
newOptions = predefinedOptions[value];
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
newOptions = value;
|
|
153
|
+
}
|
|
154
|
+
return Object.assign({}, globalOptions, newOptions);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
SkyAutonumericDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyAutonumericDirective, deps: [{ token: i0.ElementRef }, { token: i1.SkyAutonumericOptionsProvider }, { token: i0.Renderer2 }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
158
|
+
SkyAutonumericDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: SkyAutonumericDirective, selector: "input[skyAutonumeric]", inputs: { skyAutonumeric: "skyAutonumeric" }, host: { listeners: { "blur": "onBlur()" } }, providers: [SKY_AUTONUMERIC_VALUE_ACCESSOR, SKY_AUTONUMERIC_VALIDATOR], ngImport: i0 });
|
|
159
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyAutonumericDirective, decorators: [{
|
|
160
|
+
type: Directive,
|
|
161
|
+
args: [{
|
|
162
|
+
selector: 'input[skyAutonumeric]',
|
|
163
|
+
providers: [SKY_AUTONUMERIC_VALUE_ACCESSOR, SKY_AUTONUMERIC_VALIDATOR],
|
|
164
|
+
}]
|
|
165
|
+
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i1.SkyAutonumericOptionsProvider }, { type: i0.Renderer2 }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { skyAutonumeric: [{
|
|
166
|
+
type: Input
|
|
167
|
+
}], onBlur: [{
|
|
168
|
+
type: HostListener,
|
|
169
|
+
args: ['blur']
|
|
170
|
+
}] } });
|
|
171
|
+
//# sourceMappingURL=autonumeric.directive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autonumeric.directive.js","sourceRoot":"","sources":["../../../../../../../../libs/components/autonumeric/src/lib/modules/autonumeric/autonumeric.directive.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,SAAS,EACT,UAAU,EACV,UAAU,EACV,YAAY,EACZ,KAAK,EAGL,SAAS,GACV,MAAM,eAAe,CAAC;AAEvB,OAAO,EAGL,aAAa,EACb,iBAAiB,GAG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AE,CAAC,8BAA8B,EAAE,yBAAyB,CAAC;iBACvE;qMAQY,cAAc;sBADxB,KAAK;gBAgHC,MAAM;sBADZ,YAAY;uBAAC,MAAM","sourcesContent":["import {\n ChangeDetectorRef,\n Directive,\n ElementRef,\n forwardRef,\n HostListener,\n Input,\n OnDestroy,\n OnInit,\n Renderer2,\n} from '@angular/core';\n\nimport {\n AbstractControl,\n ControlValueAccessor,\n NG_VALIDATORS,\n NG_VALUE_ACCESSOR,\n ValidationErrors,\n Validator,\n} from '@angular/forms';\n\nimport AutoNumeric from 'autonumeric';\n\nimport { fromEvent, Subject } from 'rxjs';\n\nimport { takeUntil } from 'rxjs/operators';\n\nimport { SkyAutonumericOptions } from './autonumeric-options';\n\nimport { SkyAutonumericOptionsProvider } from './autonumeric-options-provider';\n\n// tslint:disable:no-forward-ref no-use-before-declare\nconst SKY_AUTONUMERIC_VALUE_ACCESSOR = {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => SkyAutonumericDirective),\n multi: true,\n};\n\nconst SKY_AUTONUMERIC_VALIDATOR = {\n provide: NG_VALIDATORS,\n useExisting: forwardRef(() => SkyAutonumericDirective),\n multi: true,\n};\n// tslint:enable\n\n/**\n * Wraps the [autoNumeric utility](https://github.com/autoNumeric/autoNumeric) to format\n * any type of number, including currency.\n */\n@Directive({\n selector: 'input[skyAutonumeric]',\n providers: [SKY_AUTONUMERIC_VALUE_ACCESSOR, SKY_AUTONUMERIC_VALIDATOR],\n})\nexport class SkyAutonumericDirective\n implements OnInit, OnDestroy, ControlValueAccessor, Validator\n{\n /**\n * Assigns the name of a property from `SkyAutonumericOptionsProvider`.\n */\n @Input()\n public set skyAutonumeric(value: SkyAutonumericOptions) {\n this.autonumericOptions = this.mergeOptions(value);\n this.updateAutonumericInstance();\n }\n\n private autonumericInstance: AutoNumeric;\n private autonumericOptions: SkyAutonumericOptions | undefined;\n private control: AbstractControl | undefined;\n private isFirstChange = true;\n private value: number | undefined;\n\n private ngUnsubscribe = new Subject<void>();\n\n constructor(\n private elementRef: ElementRef,\n private globalConfig: SkyAutonumericOptionsProvider,\n private renderer: Renderer2,\n private changeDetector: ChangeDetectorRef\n ) {\n this.autonumericInstance = new AutoNumeric(this.elementRef.nativeElement);\n }\n\n public ngOnInit(): void {\n // Ensure that we set the global config even if no local config has been given.\n if (!this.autonumericOptions) {\n this.autonumericOptions = this.globalConfig.getConfig();\n }\n this.updateAutonumericInstance();\n\n fromEvent(this.elementRef.nativeElement, 'input')\n .pipe(takeUntil(this.ngUnsubscribe))\n .subscribe(() => {\n const numericValue: number | undefined = this.getNumericValue();\n\n /* istanbul ignore else */\n if (this.value !== numericValue) {\n this.value = numericValue;\n this.onChange(numericValue);\n }\n\n /* istanbul ignore else */\n if (this.control && !this.control.dirty) {\n this.control.markAsDirty();\n }\n\n this.changeDetector.markForCheck();\n });\n }\n\n public ngOnDestroy(): void {\n this.ngUnsubscribe.next();\n this.ngUnsubscribe.complete();\n }\n\n /**\n * Implemented as part of ControlValueAccessor.\n */\n public setDisabledState(value: boolean): void {\n this.renderer.setProperty(this.elementRef.nativeElement, 'disabled', value);\n }\n\n public writeValue(value: number | undefined): void {\n if (this.value !== value) {\n this.value = value;\n this.onChange(value);\n\n // Mark the control as \"pristine\" if it is initialized with a value.\n const initializedWithValue =\n this.isFirstChange && this.control && this.value !== null;\n if (initializedWithValue) {\n this.isFirstChange = false;\n this.control!.markAsPristine();\n }\n }\n\n if (typeof value === 'number') {\n this.autonumericInstance.set(value);\n } else {\n this.autonumericInstance.clear();\n }\n }\n\n public validate(control: AbstractControl): ValidationErrors | null {\n const noErrors: null = null; // tslint:disable-line: no-null-keyword\n\n if (!this.control) {\n this.control = control;\n }\n\n if (control.value === null || control.value === undefined) {\n return noErrors;\n }\n\n if (typeof control.value !== 'number') {\n return {\n notTypeOfNumber: { value: control.value },\n };\n }\n\n return noErrors;\n }\n\n public registerOnChange(fn: (value: number | undefined) => void): void {\n this.onChange = fn;\n }\n\n public registerOnTouched(fn: () => void): void {\n this.onTouched = fn;\n }\n\n @HostListener('blur')\n public onBlur(): void {\n this.onTouched();\n }\n\n private getNumericValue(): number | undefined {\n const inputValue = this.getInputValue();\n return inputValue && !this.isInputValueTheCurrencySymbol(inputValue)\n ? <number>this.autonumericInstance.getNumber()\n : undefined;\n }\n\n /**\n * Due to AutoNumeric's hover logic - when AutoNumeric has a currency symbol the value\n * that we get back on empty fields will be the currency symbol.\n * The following logic ensures that we don't accidentally set\n * a form value when the only input was the programatically-added currency symbol.\n */\n private isInputValueTheCurrencySymbol(inputValue: string): boolean {\n /* istanbul ignore next */\n const currencySymbol = (\n (this.autonumericOptions as AutoNumeric.Options)?.currencySymbol ?? ''\n ).trim();\n return !!currencySymbol && inputValue === currencySymbol;\n }\n\n private getInputValue(): string {\n return this.elementRef.nativeElement.value;\n }\n\n private updateAutonumericInstance(): void {\n this.autonumericInstance.update(\n this.autonumericOptions as AutoNumeric.Options\n );\n }\n\n private mergeOptions(value: SkyAutonumericOptions): SkyAutonumericOptions {\n const globalOptions = this.globalConfig.getConfig();\n\n let newOptions: SkyAutonumericOptions;\n if (typeof value === 'string') {\n const predefinedOptions = AutoNumeric.getPredefinedOptions();\n newOptions = predefinedOptions[\n value as keyof AutoNumeric.Options\n ] as AutoNumeric.Options;\n } else {\n newOptions = value;\n }\n\n return Object.assign({}, globalOptions, newOptions);\n }\n\n /* istanbul ignore next */\n private onChange = (_: number | undefined) => {};\n /* istanbul ignore next */\n private onTouched = () => {};\n}\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { CommonModule } from '@angular/common';
|
|
2
|
+
import { NgModule } from '@angular/core';
|
|
3
|
+
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
4
|
+
import { SkyAutonumericDirective } from './autonumeric.directive';
|
|
5
|
+
import * as i0 from "@angular/core";
|
|
6
|
+
export class SkyAutonumericModule {
|
|
7
|
+
}
|
|
8
|
+
SkyAutonumericModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyAutonumericModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
9
|
+
SkyAutonumericModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyAutonumericModule, declarations: [SkyAutonumericDirective], imports: [CommonModule, FormsModule, ReactiveFormsModule], exports: [SkyAutonumericDirective] });
|
|
10
|
+
SkyAutonumericModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyAutonumericModule, imports: [[CommonModule, FormsModule, ReactiveFormsModule]] });
|
|
11
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyAutonumericModule, decorators: [{
|
|
12
|
+
type: NgModule,
|
|
13
|
+
args: [{
|
|
14
|
+
declarations: [SkyAutonumericDirective],
|
|
15
|
+
imports: [CommonModule, FormsModule, ReactiveFormsModule],
|
|
16
|
+
exports: [SkyAutonumericDirective],
|
|
17
|
+
}]
|
|
18
|
+
}] });
|
|
19
|
+
//# sourceMappingURL=autonumeric.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autonumeric.module.js","sourceRoot":"","sources":["../../../../../../../../libs/components/autonumeric/src/lib/modules/autonumeric/autonumeric.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAElE,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;;AAOlE,MAAM,OAAO,oBAAoB;;kHAApB,oBAAoB;mHAApB,oBAAoB,iBAJhB,uBAAuB,aAC5B,YAAY,EAAE,WAAW,EAAE,mBAAmB,aAC9C,uBAAuB;mHAEtB,oBAAoB,YAHtB,CAAC,YAAY,EAAE,WAAW,EAAE,mBAAmB,CAAC;4FAG9C,oBAAoB;kBALhC,QAAQ;mBAAC;oBACR,YAAY,EAAE,CAAC,uBAAuB,CAAC;oBACvC,OAAO,EAAE,CAAC,YAAY,EAAE,WAAW,EAAE,mBAAmB,CAAC;oBACzD,OAAO,EAAE,CAAC,uBAAuB,CAAC;iBACnC","sourcesContent":["import { CommonModule } from '@angular/common';\n\nimport { NgModule } from '@angular/core';\n\nimport { FormsModule, ReactiveFormsModule } from '@angular/forms';\n\nimport { SkyAutonumericDirective } from './autonumeric.directive';\n\n@NgModule({\n declarations: [SkyAutonumericDirective],\n imports: [CommonModule, FormsModule, ReactiveFormsModule],\n exports: [SkyAutonumericDirective],\n})\nexport class SkyAutonumericModule {}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Generated bundle index. Do not edit.
|
|
3
3
|
*/
|
|
4
|
-
export * from './
|
|
5
|
-
//# sourceMappingURL=
|
|
4
|
+
export * from './index';
|
|
5
|
+
//# sourceMappingURL=skyux-autonumeric.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skyux-autonumeric.js","sourceRoot":"","sources":["../../../../../libs/components/autonumeric/src/skyux-autonumeric.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,SAAS,CAAC","sourcesContent":["/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"]}
|
|
@@ -2,9 +2,9 @@ import * as i0 from '@angular/core';
|
|
|
2
2
|
import { Injectable, forwardRef, Directive, Input, HostListener, NgModule } from '@angular/core';
|
|
3
3
|
import { CommonModule } from '@angular/common';
|
|
4
4
|
import { NG_VALUE_ACCESSOR, NG_VALIDATORS, FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
5
|
+
import AutoNumeric from 'autonumeric';
|
|
5
6
|
import { Subject, fromEvent } from 'rxjs';
|
|
6
7
|
import { takeUntil } from 'rxjs/operators';
|
|
7
|
-
import AutoNumeric from 'autonumeric';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Provides options to the underlying [autoNumeric utility](https://github.com/autoNumeric/autoNumeric).
|
|
@@ -19,12 +19,12 @@ class SkyAutonumericOptionsProvider {
|
|
|
19
19
|
return {};
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
-
SkyAutonumericOptionsProvider.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.
|
|
23
|
-
SkyAutonumericOptionsProvider.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.
|
|
24
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
|
22
|
+
SkyAutonumericOptionsProvider.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyAutonumericOptionsProvider, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
23
|
+
SkyAutonumericOptionsProvider.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyAutonumericOptionsProvider, providedIn: 'root' });
|
|
24
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyAutonumericOptionsProvider, decorators: [{
|
|
25
25
|
type: Injectable,
|
|
26
26
|
args: [{
|
|
27
|
-
providedIn: 'root'
|
|
27
|
+
providedIn: 'root',
|
|
28
28
|
}]
|
|
29
29
|
}] });
|
|
30
30
|
|
|
@@ -32,12 +32,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImpo
|
|
|
32
32
|
const SKY_AUTONUMERIC_VALUE_ACCESSOR = {
|
|
33
33
|
provide: NG_VALUE_ACCESSOR,
|
|
34
34
|
useExisting: forwardRef(() => SkyAutonumericDirective),
|
|
35
|
-
multi: true
|
|
35
|
+
multi: true,
|
|
36
36
|
};
|
|
37
37
|
const SKY_AUTONUMERIC_VALIDATOR = {
|
|
38
38
|
provide: NG_VALIDATORS,
|
|
39
39
|
useExisting: forwardRef(() => SkyAutonumericDirective),
|
|
40
|
-
multi: true
|
|
40
|
+
multi: true,
|
|
41
41
|
};
|
|
42
42
|
// tslint:enable
|
|
43
43
|
/**
|
|
@@ -56,7 +56,7 @@ class SkyAutonumericDirective {
|
|
|
56
56
|
this.onChange = (_) => { };
|
|
57
57
|
/* istanbul ignore next */
|
|
58
58
|
this.onTouched = () => { };
|
|
59
|
-
this.
|
|
59
|
+
this.autonumericInstance = new AutoNumeric(this.elementRef.nativeElement);
|
|
60
60
|
}
|
|
61
61
|
/**
|
|
62
62
|
* Assigns the name of a property from `SkyAutonumericOptionsProvider`.
|
|
@@ -108,8 +108,7 @@ class SkyAutonumericDirective {
|
|
|
108
108
|
this.control.markAsPristine();
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
|
-
|
|
112
|
-
if (isNumber) {
|
|
111
|
+
if (typeof value === 'number') {
|
|
113
112
|
this.autonumericInstance.set(value);
|
|
114
113
|
}
|
|
115
114
|
else {
|
|
@@ -126,7 +125,7 @@ class SkyAutonumericDirective {
|
|
|
126
125
|
}
|
|
127
126
|
if (typeof control.value !== 'number') {
|
|
128
127
|
return {
|
|
129
|
-
|
|
128
|
+
notTypeOfNumber: { value: control.value },
|
|
130
129
|
};
|
|
131
130
|
}
|
|
132
131
|
return noErrors;
|
|
@@ -142,10 +141,9 @@ class SkyAutonumericDirective {
|
|
|
142
141
|
}
|
|
143
142
|
getNumericValue() {
|
|
144
143
|
const inputValue = this.getInputValue();
|
|
145
|
-
|
|
144
|
+
return inputValue && !this.isInputValueTheCurrencySymbol(inputValue)
|
|
146
145
|
? this.autonumericInstance.getNumber()
|
|
147
146
|
: undefined;
|
|
148
|
-
return numericValue;
|
|
149
147
|
}
|
|
150
148
|
/**
|
|
151
149
|
* Due to AutoNumeric's hover logic - when AutoNumeric has a currency symbol the value
|
|
@@ -157,20 +155,17 @@ class SkyAutonumericDirective {
|
|
|
157
155
|
var _a, _b;
|
|
158
156
|
/* istanbul ignore next */
|
|
159
157
|
const currencySymbol = ((_b = (_a = this.autonumericOptions) === null || _a === void 0 ? void 0 : _a.currencySymbol) !== null && _b !== void 0 ? _b : '').trim();
|
|
160
|
-
return
|
|
158
|
+
return !!currencySymbol && inputValue === currencySymbol;
|
|
161
159
|
}
|
|
162
160
|
getInputValue() {
|
|
163
161
|
return this.elementRef.nativeElement.value;
|
|
164
162
|
}
|
|
165
|
-
createAutonumericInstance() {
|
|
166
|
-
this.autonumericInstance = new AutoNumeric(this.elementRef.nativeElement);
|
|
167
|
-
}
|
|
168
163
|
updateAutonumericInstance() {
|
|
169
164
|
this.autonumericInstance.update(this.autonumericOptions);
|
|
170
165
|
}
|
|
171
166
|
mergeOptions(value) {
|
|
172
167
|
const globalOptions = this.globalConfig.getConfig();
|
|
173
|
-
let newOptions
|
|
168
|
+
let newOptions;
|
|
174
169
|
if (typeof value === 'string') {
|
|
175
170
|
const predefinedOptions = AutoNumeric.getPredefinedOptions();
|
|
176
171
|
newOptions = predefinedOptions[value];
|
|
@@ -181,19 +176,13 @@ class SkyAutonumericDirective {
|
|
|
181
176
|
return Object.assign({}, globalOptions, newOptions);
|
|
182
177
|
}
|
|
183
178
|
}
|
|
184
|
-
SkyAutonumericDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.
|
|
185
|
-
SkyAutonumericDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.
|
|
186
|
-
|
|
187
|
-
SKY_AUTONUMERIC_VALIDATOR
|
|
188
|
-
], ngImport: i0 });
|
|
189
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: SkyAutonumericDirective, decorators: [{
|
|
179
|
+
SkyAutonumericDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyAutonumericDirective, deps: [{ token: i0.ElementRef }, { token: SkyAutonumericOptionsProvider }, { token: i0.Renderer2 }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
180
|
+
SkyAutonumericDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: SkyAutonumericDirective, selector: "input[skyAutonumeric]", inputs: { skyAutonumeric: "skyAutonumeric" }, host: { listeners: { "blur": "onBlur()" } }, providers: [SKY_AUTONUMERIC_VALUE_ACCESSOR, SKY_AUTONUMERIC_VALIDATOR], ngImport: i0 });
|
|
181
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyAutonumericDirective, decorators: [{
|
|
190
182
|
type: Directive,
|
|
191
183
|
args: [{
|
|
192
184
|
selector: 'input[skyAutonumeric]',
|
|
193
|
-
providers: [
|
|
194
|
-
SKY_AUTONUMERIC_VALUE_ACCESSOR,
|
|
195
|
-
SKY_AUTONUMERIC_VALIDATOR
|
|
196
|
-
]
|
|
185
|
+
providers: [SKY_AUTONUMERIC_VALUE_ACCESSOR, SKY_AUTONUMERIC_VALIDATOR],
|
|
197
186
|
}]
|
|
198
187
|
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: SkyAutonumericOptionsProvider }, { type: i0.Renderer2 }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { skyAutonumeric: [{
|
|
199
188
|
type: Input
|
|
@@ -204,29 +193,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImpo
|
|
|
204
193
|
|
|
205
194
|
class SkyAutonumericModule {
|
|
206
195
|
}
|
|
207
|
-
SkyAutonumericModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.
|
|
208
|
-
SkyAutonumericModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
SkyAutonumericModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: SkyAutonumericModule, imports: [[
|
|
212
|
-
CommonModule,
|
|
213
|
-
FormsModule,
|
|
214
|
-
ReactiveFormsModule
|
|
215
|
-
]] });
|
|
216
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: SkyAutonumericModule, decorators: [{
|
|
196
|
+
SkyAutonumericModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyAutonumericModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
197
|
+
SkyAutonumericModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyAutonumericModule, declarations: [SkyAutonumericDirective], imports: [CommonModule, FormsModule, ReactiveFormsModule], exports: [SkyAutonumericDirective] });
|
|
198
|
+
SkyAutonumericModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyAutonumericModule, imports: [[CommonModule, FormsModule, ReactiveFormsModule]] });
|
|
199
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyAutonumericModule, decorators: [{
|
|
217
200
|
type: NgModule,
|
|
218
201
|
args: [{
|
|
219
|
-
declarations: [
|
|
220
|
-
|
|
221
|
-
],
|
|
222
|
-
imports: [
|
|
223
|
-
CommonModule,
|
|
224
|
-
FormsModule,
|
|
225
|
-
ReactiveFormsModule
|
|
226
|
-
],
|
|
227
|
-
exports: [
|
|
228
|
-
SkyAutonumericDirective
|
|
229
|
-
]
|
|
202
|
+
declarations: [SkyAutonumericDirective],
|
|
203
|
+
imports: [CommonModule, FormsModule, ReactiveFormsModule],
|
|
204
|
+
exports: [SkyAutonumericDirective],
|
|
230
205
|
}]
|
|
231
206
|
}] });
|
|
232
207
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skyux-autonumeric.js","sources":["../../../projects/sky-autonumeric/src/modules/autonumeric/autonumeric-options-provider.ts","../../../projects/sky-autonumeric/src/modules/autonumeric/autonumeric.directive.ts","../../../projects/sky-autonumeric/src/modules/autonumeric/autonumeric.module.ts","../../../projects/sky-autonumeric/src/skyux-autonumeric.ts"],"sourcesContent":["import {\n Injectable\n} from '@angular/core';\n\nimport {\n SkyAutonumericOptions\n} from './autonumeric-options';\n\n/**\n * Provides options to the underlying [autoNumeric utility](https://github.com/autoNumeric/autoNumeric).\n * This can set global options on multiple input fields.\n */\n@Injectable({\n providedIn: 'root'\n})\nexport class SkyAutonumericOptionsProvider {\n\n /**\n * Specifies the value for a settings object to pass to the autoNumeric utility.\n * This overrides any default options specified by the `skyAutonumeric` attribute.\n */\n public getConfig(): SkyAutonumericOptions {\n return {};\n }\n\n}\n","import {\n ChangeDetectorRef,\n Directive,\n ElementRef,\n forwardRef,\n HostListener,\n Input,\n OnDestroy,\n OnInit,\n Renderer2\n} from '@angular/core';\n\nimport {\n fromEvent,\n Subject\n} from 'rxjs';\n\nimport {\n takeUntil\n} from 'rxjs/operators';\n\nimport {\n AbstractControl,\n ControlValueAccessor,\n NG_VALIDATORS,\n NG_VALUE_ACCESSOR,\n ValidationErrors,\n Validator\n} from '@angular/forms';\n\nimport {\n SkyAutonumericOptions\n} from './autonumeric-options';\n\nimport {\n SkyAutonumericOptionsProvider\n} from './autonumeric-options-provider';\n\nimport AutoNumeric from 'autonumeric';\n\n// tslint:disable:no-forward-ref no-use-before-declare\nconst SKY_AUTONUMERIC_VALUE_ACCESSOR = {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => SkyAutonumericDirective),\n multi: true\n};\n\nconst SKY_AUTONUMERIC_VALIDATOR = {\n provide: NG_VALIDATORS,\n useExisting: forwardRef(() => SkyAutonumericDirective),\n multi: true\n};\n// tslint:enable\n\n /**\n * Wraps the [autoNumeric utility](https://github.com/autoNumeric/autoNumeric) to format\n * any type of number, including currency.\n */\n @Directive({\n selector: 'input[skyAutonumeric]',\n providers: [\n SKY_AUTONUMERIC_VALUE_ACCESSOR,\n SKY_AUTONUMERIC_VALIDATOR\n ]\n})\nexport class SkyAutonumericDirective implements OnInit, OnDestroy, ControlValueAccessor, Validator {\n\n /**\n * Assigns the name of a property from `SkyAutonumericOptionsProvider`.\n */\n @Input()\n public set skyAutonumeric(value: SkyAutonumericOptions) {\n this.autonumericOptions = this.mergeOptions(value);\n this.updateAutonumericInstance();\n }\n\n private autonumericInstance: AutoNumeric;\n private autonumericOptions: SkyAutonumericOptions;\n private control: AbstractControl;\n private isFirstChange = true;\n private value: number;\n\n private ngUnsubscribe = new Subject<void>();\n\n constructor(\n private elementRef: ElementRef,\n private globalConfig: SkyAutonumericOptionsProvider,\n private renderer: Renderer2,\n private changeDetector: ChangeDetectorRef\n ) {\n this.createAutonumericInstance();\n }\n\n public ngOnInit(): void {\n // Ensure that we set the global config even if no local config has been given.\n if (!this.autonumericOptions) {\n this.autonumericOptions = this.globalConfig.getConfig();\n }\n this.updateAutonumericInstance();\n\n fromEvent(this.elementRef.nativeElement, 'input')\n .pipe(takeUntil(this.ngUnsubscribe))\n .subscribe(() => {\n const numericValue: number | undefined = this.getNumericValue();\n\n /* istanbul ignore else */\n if (this.value !== numericValue) {\n this.value = numericValue;\n this.onChange(numericValue);\n }\n\n /* istanbul ignore else */\n if (this.control && !this.control.dirty) {\n this.control.markAsDirty();\n }\n\n this.changeDetector.markForCheck();\n });\n }\n\n public ngOnDestroy(): void {\n this.ngUnsubscribe.next();\n this.ngUnsubscribe.complete();\n }\n\n /**\n * Implemented as part of ControlValueAccessor.\n */\n public setDisabledState(value: boolean): void {\n this.renderer.setProperty(this.elementRef.nativeElement, 'disabled', value);\n }\n\n public writeValue(value: number): void {\n\n if (this.value !== value) {\n this.value = value;\n this.onChange(value);\n\n // Mark the control as \"pristine\" if it is initialized with a value.\n const initializedWithValue = this.isFirstChange && this.control && this.value !== null;\n if (initializedWithValue) {\n this.isFirstChange = false;\n this.control.markAsPristine();\n }\n }\n\n const isNumber = typeof value === 'number' && value !== null && value !== undefined;\n if (isNumber) {\n this.autonumericInstance.set(value);\n } else {\n this.autonumericInstance.clear();\n }\n }\n\n public validate(control: AbstractControl): ValidationErrors | null {\n const noErrors: null = null; // tslint:disable-line: no-null-keyword\n\n if (!this.control) {\n this.control = control;\n }\n\n if (control.value === null || control.value === undefined) {\n return noErrors;\n }\n\n if (typeof control.value !== 'number') {\n return {\n 'notTypeOfNumber': { value: control.value }\n };\n }\n\n return noErrors;\n }\n\n public registerOnChange(fn: (value: number) => void): void {\n this.onChange = fn;\n }\n\n public registerOnTouched(fn: () => void): void {\n this.onTouched = fn;\n }\n\n @HostListener('blur')\n public onBlur(): void {\n this.onTouched();\n }\n\n private getNumericValue(): number | undefined {\n const inputValue = this.getInputValue();\n const numericValue = (inputValue && !this.isInputValueTheCurrencySymbol(inputValue))\n ? this.autonumericInstance.getNumber()\n : undefined;\n\n return numericValue;\n }\n\n /**\n * Due to AutoNumeric's hover logic - when AutoNumeric has a currency symbol the value\n * that we get back on empty fields will be the currency symbol.\n * The following logic ensures that we don't accidentally set\n * a form value when the only input was the programatically-added currency symbol.\n */\n private isInputValueTheCurrencySymbol(inputValue: string): boolean {\n /* istanbul ignore next */\n const currencySymbol = ((this.autonumericOptions as AutoNumeric.Options)?.currencySymbol ?? '').trim();\n return (currencySymbol && inputValue === currencySymbol);\n }\n\n private getInputValue(): string {\n return this.elementRef.nativeElement.value;\n }\n\n private createAutonumericInstance(): void {\n this.autonumericInstance = new AutoNumeric(this.elementRef.nativeElement);\n }\n\n private updateAutonumericInstance(): void {\n this.autonumericInstance.update(this.autonumericOptions as AutoNumeric.Options);\n }\n\n private mergeOptions(value: SkyAutonumericOptions): SkyAutonumericOptions {\n const globalOptions = this.globalConfig.getConfig();\n\n let newOptions: SkyAutonumericOptions = {};\n if (typeof value === 'string') {\n const predefinedOptions = AutoNumeric.getPredefinedOptions();\n newOptions = predefinedOptions[value as keyof AutoNumeric.Options] as AutoNumeric.Options;\n } else {\n newOptions = value;\n }\n\n return Object.assign(\n {},\n globalOptions,\n newOptions\n );\n }\n\n /* istanbul ignore next */\n private onChange = (_: number) => { };\n /* istanbul ignore next */\n private onTouched = () => { };\n}\n","import {\n CommonModule\n} from '@angular/common';\n\nimport {\n NgModule\n} from '@angular/core';\n\nimport {\n FormsModule,\n ReactiveFormsModule\n} from '@angular/forms';\n\nimport {\n SkyAutonumericDirective\n} from './autonumeric.directive';\n\n@NgModule({\n declarations: [\n SkyAutonumericDirective\n ],\n imports: [\n CommonModule,\n FormsModule,\n ReactiveFormsModule\n ],\n exports: [\n SkyAutonumericDirective\n ]\n})\nexport class SkyAutonumericModule { }\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;AAQA;;;;MAOa,6BAA6B;;;;;IAMjC,SAAS;QACd,OAAO,EAAE,CAAC;KACX;;2HARU,6BAA6B;+HAA7B,6BAA6B,cAF5B,MAAM;4FAEP,6BAA6B;kBAHzC,UAAU;mBAAC;oBACV,UAAU,EAAE,MAAM;iBACnB;;;AC0BD;AACA,MAAM,8BAA8B,GAAG;IACrC,OAAO,EAAE,iBAAiB;IAC1B,WAAW,EAAE,UAAU,CAAC,MAAM,uBAAuB,CAAC;IACtD,KAAK,EAAE,IAAI;CACZ,CAAC;AAEF,MAAM,yBAAyB,GAAG;IAChC,OAAO,EAAE,aAAa;IACtB,WAAW,EAAE,UAAU,CAAC,MAAM,uBAAuB,CAAC;IACtD,KAAK,EAAE,IAAI;CACZ,CAAC;AACF;AAEE;;;;MAWW,uBAAuB;IAmBlC,YACU,UAAsB,EACtB,YAA2C,EAC3C,QAAmB,EACnB,cAAiC;QAHjC,eAAU,GAAV,UAAU,CAAY;QACtB,iBAAY,GAAZ,YAAY,CAA+B;QAC3C,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G,WAAW,CAAC,oBAAoB,EAAE,CAAC;YAC7D,UAAU,GAAG,iBAAiB,CAAC,KAAkC,CAAwB,CAAC;SAC3F;aAAM;YACL,UAAU,GAAG,KAAK,CAAC;SACpB;QAED,OAAO,MAAM,CAAC,MAAM,CAClB,EAAE,EACF,aAAa,EACb,UAAU,CACX,CAAC;KACH;;qHA3KU,uBAAuB;yGAAvB,uBAAuB,2IALvB;QACT,8BAA8B;QAC9B,yBAAyB;KAC1B;4FAEU,uBAAuB;kBAPjC,SAAS;mBAAC;oBACX,QAAQ,EAAE,uBAAuB;oBACjC,SAAS,EAAE;wBACT,8BAA8B;wBAC9B,yBAAyB;qBAC1B;iBACF;kMAOY,cAAc;sBADxB,KAAK;gBAiHC,MAAM;sBADZ,YAAY;uBAAC,MAAM;;;MCxJT,oBAAoB;;kHAApB,oBAAoB;mHAApB,oBAAoB,iBAX7B,uBAAuB,aAGvB,YAAY;QACZ,WAAW;QACX,mBAAmB,aAGnB,uBAAuB;mHAGd,oBAAoB,YATtB;YACP,YAAY;YACZ,WAAW;YACX,mBAAmB;SACpB;4FAKU,oBAAoB;kBAbhC,QAAQ;mBAAC;oBACR,YAAY,EAAE;wBACZ,uBAAuB;qBACxB;oBACD,OAAO,EAAE;wBACP,YAAY;wBACZ,WAAW;wBACX,mBAAmB;qBACpB;oBACD,OAAO,EAAE;wBACP,uBAAuB;qBACxB;iBACF;;;AC7BD;;;;;;"}
|
|
1
|
+
{"version":3,"file":"skyux-autonumeric.js","sources":["../../../../../libs/components/autonumeric/src/lib/modules/autonumeric/autonumeric-options-provider.ts","../../../../../libs/components/autonumeric/src/lib/modules/autonumeric/autonumeric.directive.ts","../../../../../libs/components/autonumeric/src/lib/modules/autonumeric/autonumeric.module.ts","../../../../../libs/components/autonumeric/src/skyux-autonumeric.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\n\nimport { SkyAutonumericOptions } from './autonumeric-options';\n\n/**\n * Provides options to the underlying [autoNumeric utility](https://github.com/autoNumeric/autoNumeric).\n * This can set global options on multiple input fields.\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class SkyAutonumericOptionsProvider {\n /**\n * Specifies the value for a settings object to pass to the autoNumeric utility.\n * This overrides any default options specified by the `skyAutonumeric` attribute.\n */\n public getConfig(): SkyAutonumericOptions {\n return {};\n }\n}\n","import {\n ChangeDetectorRef,\n Directive,\n ElementRef,\n forwardRef,\n HostListener,\n Input,\n OnDestroy,\n OnInit,\n Renderer2,\n} from '@angular/core';\n\nimport {\n AbstractControl,\n ControlValueAccessor,\n NG_VALIDATORS,\n NG_VALUE_ACCESSOR,\n ValidationErrors,\n Validator,\n} from '@angular/forms';\n\nimport AutoNumeric from 'autonumeric';\n\nimport { fromEvent, Subject } from 'rxjs';\n\nimport { takeUntil } from 'rxjs/operators';\n\nimport { SkyAutonumericOptions } from './autonumeric-options';\n\nimport { SkyAutonumericOptionsProvider } from './autonumeric-options-provider';\n\n// tslint:disable:no-forward-ref no-use-before-declare\nconst SKY_AUTONUMERIC_VALUE_ACCESSOR = {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => SkyAutonumericDirective),\n multi: true,\n};\n\nconst SKY_AUTONUMERIC_VALIDATOR = {\n provide: NG_VALIDATORS,\n useExisting: forwardRef(() => SkyAutonumericDirective),\n multi: true,\n};\n// tslint:enable\n\n/**\n * Wraps the [autoNumeric utility](https://github.com/autoNumeric/autoNumeric) to format\n * any type of number, including currency.\n */\n@Directive({\n selector: 'input[skyAutonumeric]',\n providers: [SKY_AUTONUMERIC_VALUE_ACCESSOR, SKY_AUTONUMERIC_VALIDATOR],\n})\nexport class SkyAutonumericDirective\n implements OnInit, OnDestroy, ControlValueAccessor, Validator\n{\n /**\n * Assigns the name of a property from `SkyAutonumericOptionsProvider`.\n */\n @Input()\n public set skyAutonumeric(value: SkyAutonumericOptions) {\n this.autonumericOptions = this.mergeOptions(value);\n this.updateAutonumericInstance();\n }\n\n private autonumericInstance: AutoNumeric;\n private autonumericOptions: SkyAutonumericOptions | undefined;\n private control: AbstractControl | undefined;\n private isFirstChange = true;\n private value: number | undefined;\n\n private ngUnsubscribe = new Subject<void>();\n\n constructor(\n private elementRef: ElementRef,\n private globalConfig: SkyAutonumericOptionsProvider,\n private renderer: Renderer2,\n private changeDetector: ChangeDetectorRef\n ) {\n this.autonumericInstance = new AutoNumeric(this.elementRef.nativeElement);\n }\n\n public ngOnInit(): void {\n // Ensure that we set the global config even if no local config has been given.\n if (!this.autonumericOptions) {\n this.autonumericOptions = this.globalConfig.getConfig();\n }\n this.updateAutonumericInstance();\n\n fromEvent(this.elementRef.nativeElement, 'input')\n .pipe(takeUntil(this.ngUnsubscribe))\n .subscribe(() => {\n const numericValue: number | undefined = this.getNumericValue();\n\n /* istanbul ignore else */\n if (this.value !== numericValue) {\n this.value = numericValue;\n this.onChange(numericValue);\n }\n\n /* istanbul ignore else */\n if (this.control && !this.control.dirty) {\n this.control.markAsDirty();\n }\n\n this.changeDetector.markForCheck();\n });\n }\n\n public ngOnDestroy(): void {\n this.ngUnsubscribe.next();\n this.ngUnsubscribe.complete();\n }\n\n /**\n * Implemented as part of ControlValueAccessor.\n */\n public setDisabledState(value: boolean): void {\n this.renderer.setProperty(this.elementRef.nativeElement, 'disabled', value);\n }\n\n public writeValue(value: number | undefined): void {\n if (this.value !== value) {\n this.value = value;\n this.onChange(value);\n\n // Mark the control as \"pristine\" if it is initialized with a value.\n const initializedWithValue =\n this.isFirstChange && this.control && this.value !== null;\n if (initializedWithValue) {\n this.isFirstChange = false;\n this.control!.markAsPristine();\n }\n }\n\n if (typeof value === 'number') {\n this.autonumericInstance.set(value);\n } else {\n this.autonumericInstance.clear();\n }\n }\n\n public validate(control: AbstractControl): ValidationErrors | null {\n const noErrors: null = null; // tslint:disable-line: no-null-keyword\n\n if (!this.control) {\n this.control = control;\n }\n\n if (control.value === null || control.value === undefined) {\n return noErrors;\n }\n\n if (typeof control.value !== 'number') {\n return {\n notTypeOfNumber: { value: control.value },\n };\n }\n\n return noErrors;\n }\n\n public registerOnChange(fn: (value: number | undefined) => void): void {\n this.onChange = fn;\n }\n\n public registerOnTouched(fn: () => void): void {\n this.onTouched = fn;\n }\n\n @HostListener('blur')\n public onBlur(): void {\n this.onTouched();\n }\n\n private getNumericValue(): number | undefined {\n const inputValue = this.getInputValue();\n return inputValue && !this.isInputValueTheCurrencySymbol(inputValue)\n ? <number>this.autonumericInstance.getNumber()\n : undefined;\n }\n\n /**\n * Due to AutoNumeric's hover logic - when AutoNumeric has a currency symbol the value\n * that we get back on empty fields will be the currency symbol.\n * The following logic ensures that we don't accidentally set\n * a form value when the only input was the programatically-added currency symbol.\n */\n private isInputValueTheCurrencySymbol(inputValue: string): boolean {\n /* istanbul ignore next */\n const currencySymbol = (\n (this.autonumericOptions as AutoNumeric.Options)?.currencySymbol ?? ''\n ).trim();\n return !!currencySymbol && inputValue === currencySymbol;\n }\n\n private getInputValue(): string {\n return this.elementRef.nativeElement.value;\n }\n\n private updateAutonumericInstance(): void {\n this.autonumericInstance.update(\n this.autonumericOptions as AutoNumeric.Options\n );\n }\n\n private mergeOptions(value: SkyAutonumericOptions): SkyAutonumericOptions {\n const globalOptions = this.globalConfig.getConfig();\n\n let newOptions: SkyAutonumericOptions;\n if (typeof value === 'string') {\n const predefinedOptions = AutoNumeric.getPredefinedOptions();\n newOptions = predefinedOptions[\n value as keyof AutoNumeric.Options\n ] as AutoNumeric.Options;\n } else {\n newOptions = value;\n }\n\n return Object.assign({}, globalOptions, newOptions);\n }\n\n /* istanbul ignore next */\n private onChange = (_: number | undefined) => {};\n /* istanbul ignore next */\n private onTouched = () => {};\n}\n","import { CommonModule } from '@angular/common';\n\nimport { NgModule } from '@angular/core';\n\nimport { FormsModule, ReactiveFormsModule } from '@angular/forms';\n\nimport { SkyAutonumericDirective } from './autonumeric.directive';\n\n@NgModule({\n declarations: [SkyAutonumericDirective],\n imports: [CommonModule, FormsModule, ReactiveFormsModule],\n exports: [SkyAutonumericDirective],\n})\nexport class SkyAutonum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Q;mBAAC;oBACR,YAAY,EAAE,CAAC,uBAAuB,CAAC;oBACvC,OAAO,EAAE,CAAC,YAAY,EAAE,WAAW,EAAE,mBAAmB,CAAC;oBACzD,OAAO,EAAE,CAAC,uBAAuB,CAAC;iBACnC;;;ACZD;;;;;;"}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export * from './lib/modules/autonumeric/autonumeric-options-provider';
|
|
2
|
+
export * from './lib/modules/autonumeric/autonumeric-options';
|
|
3
|
+
export * from './lib/modules/autonumeric/autonumeric.module';
|
|
4
|
+
export { SkyAutonumericDirective as λ1 } from './lib/modules/autonumeric/autonumeric.directive';
|
|
File without changes
|
|
File without changes
|
|
@@ -29,9 +29,9 @@ export declare class SkyAutonumericDirective implements OnInit, OnDestroy, Contr
|
|
|
29
29
|
* Implemented as part of ControlValueAccessor.
|
|
30
30
|
*/
|
|
31
31
|
setDisabledState(value: boolean): void;
|
|
32
|
-
writeValue(value: number): void;
|
|
32
|
+
writeValue(value: number | undefined): void;
|
|
33
33
|
validate(control: AbstractControl): ValidationErrors | null;
|
|
34
|
-
registerOnChange(fn: (value: number) => void): void;
|
|
34
|
+
registerOnChange(fn: (value: number | undefined) => void): void;
|
|
35
35
|
registerOnTouched(fn: () => void): void;
|
|
36
36
|
onBlur(): void;
|
|
37
37
|
private getNumericValue;
|
|
@@ -43,7 +43,6 @@ export declare class SkyAutonumericDirective implements OnInit, OnDestroy, Contr
|
|
|
43
43
|
*/
|
|
44
44
|
private isInputValueTheCurrencySymbol;
|
|
45
45
|
private getInputValue;
|
|
46
|
-
private createAutonumericInstance;
|
|
47
46
|
private updateAutonumericInstance;
|
|
48
47
|
private mergeOptions;
|
|
49
48
|
private onChange;
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,15 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skyux/autonumeric",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.5.0-beta.0",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"autonumeric": "4.6.0",
|
|
6
6
|
"tslib": "^2.3.1"
|
|
7
7
|
},
|
|
8
8
|
"peerDependencies": {
|
|
9
|
-
"@angular/common": "^12.2.
|
|
10
|
-
"@angular/core": "^12.2.
|
|
11
|
-
"@angular/forms": "^12.2.
|
|
9
|
+
"@angular/common": "^12.2.16",
|
|
10
|
+
"@angular/core": "^12.2.16",
|
|
11
|
+
"@angular/forms": "^12.2.16"
|
|
12
12
|
},
|
|
13
|
+
"author": "Blackbaud, Inc.",
|
|
14
|
+
"keywords": [
|
|
15
|
+
"blackbaud",
|
|
16
|
+
"skyux"
|
|
17
|
+
],
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/blackbaud/skyux.git"
|
|
22
|
+
},
|
|
23
|
+
"bugs": {
|
|
24
|
+
"url": "https://github.com/blackbaud/skyux/issues"
|
|
25
|
+
},
|
|
26
|
+
"homepage": "https://github.com/blackbaud/skyux#readme",
|
|
13
27
|
"main": "bundles/skyux-autonumeric.umd.js",
|
|
14
28
|
"module": "fesm2015/skyux-autonumeric.js",
|
|
15
29
|
"es2015": "fesm2015/skyux-autonumeric.js",
|
package/skyux-autonumeric.d.ts
CHANGED
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2020 Blackbaud
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"skyux-autonumeric.umd.js","sources":["../../../projects/sky-autonumeric/src/modules/autonumeric/autonumeric-options-provider.ts","../../../projects/sky-autonumeric/src/modules/autonumeric/autonumeric.directive.ts","../../../projects/sky-autonumeric/src/modules/autonumeric/autonumeric.module.ts","../../../projects/sky-autonumeric/src/skyux-autonumeric.ts"],"sourcesContent":["import {\n Injectable\n} from '@angular/core';\n\nimport {\n SkyAutonumericOptions\n} from './autonumeric-options';\n\n/**\n * Provides options to the underlying [autoNumeric utility](https://github.com/autoNumeric/autoNumeric).\n * This can set global options on multiple input fields.\n */\n@Injectable({\n providedIn: 'root'\n})\nexport class SkyAutonumericOptionsProvider {\n\n /**\n * Specifies the value for a settings object to pass to the autoNumeric utility.\n * This overrides any default options specified by the `skyAutonumeric` attribute.\n */\n public getConfig(): SkyAutonumericOptions {\n return {};\n }\n\n}\n","import {\n ChangeDetectorRef,\n Directive,\n ElementRef,\n forwardRef,\n HostListener,\n Input,\n OnDestroy,\n OnInit,\n Renderer2\n} from '@angular/core';\n\nimport {\n fromEvent,\n Subject\n} from 'rxjs';\n\nimport {\n takeUntil\n} from 'rxjs/operators';\n\nimport {\n AbstractControl,\n ControlValueAccessor,\n NG_VALIDATORS,\n NG_VALUE_ACCESSOR,\n ValidationErrors,\n Validator\n} from '@angular/forms';\n\nimport {\n SkyAutonumericOptions\n} from './autonumeric-options';\n\nimport {\n SkyAutonumericOptionsProvider\n} from './autonumeric-options-provider';\n\nimport AutoNumeric from 'autonumeric';\n\n// tslint:disable:no-forward-ref no-use-before-declare\nconst SKY_AUTONUMERIC_VALUE_ACCESSOR = {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => SkyAutonumericDirective),\n multi: true\n};\n\nconst SKY_AUTONUMERIC_VALIDATOR = {\n provide: NG_VALIDATORS,\n useExisting: forwardRef(() => SkyAutonumericDirective),\n multi: true\n};\n// tslint:enable\n\n /**\n * Wraps the [autoNumeric utility](https://github.com/autoNumeric/autoNumeric) to format\n * any type of number, including currency.\n */\n @Directive({\n selector: 'input[skyAutonumeric]',\n providers: [\n SKY_AUTONUMERIC_VALUE_ACCESSOR,\n SKY_AUTONUMERIC_VALIDATOR\n ]\n})\nexport class SkyAutonumericDirective implements OnInit, OnDestroy, ControlValueAccessor, Validator {\n\n /**\n * Assigns the name of a property from `SkyAutonumericOptionsProvider`.\n */\n @Input()\n public set skyAutonumeric(value: SkyAutonumericOptions) {\n this.autonumericOptions = this.mergeOptions(value);\n this.updateAutonumericInstance();\n }\n\n private autonumericInstance: AutoNumeric;\n private autonumericOptions: SkyAutonumericOptions;\n private control: AbstractControl;\n private isFirstChange = true;\n private value: number;\n\n private ngUnsubscribe = new Subject<void>();\n\n constructor(\n private elementRef: ElementRef,\n private globalConfig: SkyAutonumericOptionsProvider,\n private renderer: Renderer2,\n private changeDetector: ChangeDetectorRef\n ) {\n this.createAutonumericInstance();\n }\n\n public ngOnInit(): void {\n // Ensure that we set the global config even if no local config has been given.\n if (!this.autonumericOptions) {\n this.autonumericOptions = this.globalConfig.getConfig();\n }\n this.updateAutonumericInstance();\n\n fromEvent(this.elementRef.nativeElement, 'input')\n .pipe(takeUntil(this.ngUnsubscribe))\n .subscribe(() => {\n const numericValue: number | undefined = this.getNumericValue();\n\n /* istanbul ignore else */\n if (this.value !== numericValue) {\n this.value = numericValue;\n this.onChange(numericValue);\n }\n\n /* istanbul ignore else */\n if (this.control && !this.control.dirty) {\n this.control.markAsDirty();\n }\n\n this.changeDetector.markForCheck();\n });\n }\n\n public ngOnDestroy(): void {\n this.ngUnsubscribe.next();\n this.ngUnsubscribe.complete();\n }\n\n /**\n * Implemented as part of ControlValueAccessor.\n */\n public setDisabledState(value: boolean): void {\n this.renderer.setProperty(this.elementRef.nativeElement, 'disabled', value);\n }\n\n public writeValue(value: number): void {\n\n if (this.value !== value) {\n this.value = value;\n this.onChange(value);\n\n // Mark the control as \"pristine\" if it is initialized with a value.\n const initializedWithValue = this.isFirstChange && this.control && this.value !== null;\n if (initializedWithValue) {\n this.isFirstChange = false;\n this.control.markAsPristine();\n }\n }\n\n const isNumber = typeof value === 'number' && value !== null && value !== undefined;\n if (isNumber) {\n this.autonumericInstance.set(value);\n } else {\n this.autonumericInstance.clear();\n }\n }\n\n public validate(control: AbstractControl): ValidationErrors | null {\n const noErrors: null = null; // tslint:disable-line: no-null-keyword\n\n if (!this.control) {\n this.control = control;\n }\n\n if (control.value === null || control.value === undefined) {\n return noErrors;\n }\n\n if (typeof control.value !== 'number') {\n return {\n 'notTypeOfNumber': { value: control.value }\n };\n }\n\n return noErrors;\n }\n\n public registerOnChange(fn: (value: number) => void): void {\n this.onChange = fn;\n }\n\n public registerOnTouched(fn: () => void): void {\n this.onTouched = fn;\n }\n\n @HostListener('blur')\n public onBlur(): void {\n this.onTouched();\n }\n\n private getNumericValue(): number | undefined {\n const inputValue = this.getInputValue();\n const numericValue = (inputValue && !this.isInputValueTheCurrencySymbol(inputValue))\n ? this.autonumericInstance.getNumber()\n : undefined;\n\n return numericValue;\n }\n\n /**\n * Due to AutoNumeric's hover logic - when AutoNumeric has a currency symbol the value\n * that we get back on empty fields will be the currency symbol.\n * The following logic ensures that we don't accidentally set\n * a form value when the only input was the programatically-added currency symbol.\n */\n private isInputValueTheCurrencySymbol(inputValue: string): boolean {\n /* istanbul ignore next */\n const currencySymbol = ((this.autonumericOptions as AutoNumeric.Options)?.currencySymbol ?? '').trim();\n return (currencySymbol && inputValue === currencySymbol);\n }\n\n private getInputValue(): string {\n return this.elementRef.nativeElement.value;\n }\n\n private createAutonumericInstance(): void {\n this.autonumericInstance = new AutoNumeric(this.elementRef.nativeElement);\n }\n\n private updateAutonumericInstance(): void {\n this.autonumericInstance.update(this.autonumericOptions as AutoNumeric.Options);\n }\n\n private mergeOptions(value: SkyAutonumericOptions): SkyAutonumericOptions {\n const globalOptions = this.globalConfig.getConfig();\n\n let newOptions: SkyAutonumericOptions = {};\n if (typeof value === 'string') {\n const predefinedOptions = AutoNumeric.getPredefinedOptions();\n newOptions = predefinedOptions[value as keyof AutoNumeric.Options] as AutoNumeric.Options;\n } else {\n newOptions = value;\n }\n\n return Object.assign(\n {},\n globalOptions,\n newOptions\n );\n }\n\n /* istanbul ignore next */\n private onChange = (_: number) => { };\n /* istanbul ignore next */\n private onTouched = () => { };\n}\n","import {\n CommonModule\n} from '@angular/common';\n\nimport {\n NgModule\n} from '@angular/core';\n\nimport {\n FormsModule,\n ReactiveFormsModule\n} from '@angular/forms';\n\nimport {\n SkyAutonumericDirective\n} from './autonumeric.directive';\n\n@NgModule({\n declarations: [\n SkyAutonumericDirective\n ],\n imports: [\n CommonModule,\n FormsModule,\n ReactiveFormsModule\n ],\n exports: [\n SkyAutonumericDirective\n ]\n})\nexport class SkyAutonumericModule { }\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["Injectable","NG_VALUE_ACCESSOR","forwardRef","NG_VALIDATORS","Subject","fromEvent","takeUntil","AutoNumeric","Directive","Input","HostListener","CommonModule","FormsModule","ReactiveFormsModule","NgModule"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAQA;;;;;QAOA;;;;;;QAMS,iD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