@skyux/autonumeric 5.5.0 → 5.6.2
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/bundles/skyux-autonumeric.umd.js +2 -2
- package/documentation.json +22 -65
- package/esm2015/lib/modules/autonumeric/autonumeric.directive.js +4 -4
- package/esm2015/lib/modules/autonumeric/autonumeric.directive.js.map +1 -1
- package/esm2015/lib/modules/autonumeric/autonumeric.module.js.map +1 -1
- package/fesm2015/skyux-autonumeric.js +2 -2
- package/fesm2015/skyux-autonumeric.js.map +1 -1
- package/package.json +10 -10
|
@@ -76,9 +76,9 @@
|
|
|
76
76
|
this.changeDetector = changeDetector;
|
|
77
77
|
this.isFirstChange = true;
|
|
78
78
|
this.ngUnsubscribe = new rxjs.Subject();
|
|
79
|
-
|
|
79
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
80
80
|
this.onChange = function (_) { };
|
|
81
|
-
|
|
81
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
82
82
|
this.onTouched = function () { };
|
|
83
83
|
this.autonumericInstance = new AutoNumeric__default["default"](this.elementRef.nativeElement);
|
|
84
84
|
}
|
package/documentation.json
CHANGED
|
@@ -33,29 +33,7 @@
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
],
|
|
36
|
-
"children": [
|
|
37
|
-
{
|
|
38
|
-
"id": 67,
|
|
39
|
-
"name": "constructor",
|
|
40
|
-
"kind": 512,
|
|
41
|
-
"kindString": "Constructor",
|
|
42
|
-
"flags": {},
|
|
43
|
-
"signatures": [
|
|
44
|
-
{
|
|
45
|
-
"id": 68,
|
|
46
|
-
"name": "new SkyAutonumericModule",
|
|
47
|
-
"kind": 16384,
|
|
48
|
-
"kindString": "Constructor signature",
|
|
49
|
-
"flags": {},
|
|
50
|
-
"type": {
|
|
51
|
-
"type": "reference",
|
|
52
|
-
"id": 66,
|
|
53
|
-
"name": "SkyAutonumericModule"
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
]
|
|
57
|
-
}
|
|
58
|
-
],
|
|
36
|
+
"children": [],
|
|
59
37
|
"groups": [
|
|
60
38
|
{
|
|
61
39
|
"title": "Constructors",
|
|
@@ -68,7 +46,7 @@
|
|
|
68
46
|
"sources": [
|
|
69
47
|
{
|
|
70
48
|
"fileName": "projects/autonumeric/src/modules/autonumeric/autonumeric.module.ts",
|
|
71
|
-
"line":
|
|
49
|
+
"line": 12,
|
|
72
50
|
"character": 13
|
|
73
51
|
}
|
|
74
52
|
]
|
|
@@ -97,27 +75,6 @@
|
|
|
97
75
|
}
|
|
98
76
|
],
|
|
99
77
|
"children": [
|
|
100
|
-
{
|
|
101
|
-
"id": 61,
|
|
102
|
-
"name": "constructor",
|
|
103
|
-
"kind": 512,
|
|
104
|
-
"kindString": "Constructor",
|
|
105
|
-
"flags": {},
|
|
106
|
-
"signatures": [
|
|
107
|
-
{
|
|
108
|
-
"id": 62,
|
|
109
|
-
"name": "new SkyAutonumericOptionsProvider",
|
|
110
|
-
"kind": 16384,
|
|
111
|
-
"kindString": "Constructor signature",
|
|
112
|
-
"flags": {},
|
|
113
|
-
"type": {
|
|
114
|
-
"type": "reference",
|
|
115
|
-
"id": 60,
|
|
116
|
-
"name": "SkyAutonumericOptionsProvider"
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
]
|
|
120
|
-
},
|
|
121
78
|
{
|
|
122
79
|
"id": 63,
|
|
123
80
|
"name": "getConfig",
|
|
@@ -209,7 +166,7 @@
|
|
|
209
166
|
"sources": [
|
|
210
167
|
{
|
|
211
168
|
"fileName": "projects/autonumeric/src/modules/autonumeric/autonumeric.directive.ts",
|
|
212
|
-
"line":
|
|
169
|
+
"line": 70,
|
|
213
170
|
"character": 2
|
|
214
171
|
}
|
|
215
172
|
],
|
|
@@ -310,7 +267,7 @@
|
|
|
310
267
|
"sources": [
|
|
311
268
|
{
|
|
312
269
|
"fileName": "projects/autonumeric/src/modules/autonumeric/autonumeric.directive.ts",
|
|
313
|
-
"line":
|
|
270
|
+
"line": 57,
|
|
314
271
|
"character": 13
|
|
315
272
|
}
|
|
316
273
|
],
|
|
@@ -356,7 +313,7 @@
|
|
|
356
313
|
"sources": [
|
|
357
314
|
{
|
|
358
315
|
"fileName": "projects/autonumeric/src/modules/autonumeric/autonumeric.directive.ts",
|
|
359
|
-
"line":
|
|
316
|
+
"line": 106,
|
|
360
317
|
"character": 9
|
|
361
318
|
}
|
|
362
319
|
],
|
|
@@ -393,7 +350,7 @@
|
|
|
393
350
|
"sources": [
|
|
394
351
|
{
|
|
395
352
|
"fileName": "projects/autonumeric/src/modules/autonumeric/autonumeric.directive.ts",
|
|
396
|
-
"line":
|
|
353
|
+
"line": 79,
|
|
397
354
|
"character": 9
|
|
398
355
|
}
|
|
399
356
|
],
|
|
@@ -444,7 +401,7 @@
|
|
|
444
401
|
"sources": [
|
|
445
402
|
{
|
|
446
403
|
"fileName": "projects/autonumeric/src/modules/autonumeric/autonumeric.directive.ts",
|
|
447
|
-
"line":
|
|
404
|
+
"line": 168,
|
|
448
405
|
"character": 9
|
|
449
406
|
}
|
|
450
407
|
],
|
|
@@ -473,7 +430,7 @@
|
|
|
473
430
|
"sources": [
|
|
474
431
|
{
|
|
475
432
|
"fileName": "projects/autonumeric/src/modules/autonumeric/autonumeric.directive.ts",
|
|
476
|
-
"line":
|
|
433
|
+
"line": 159,
|
|
477
434
|
"character": 9
|
|
478
435
|
}
|
|
479
436
|
],
|
|
@@ -555,7 +512,7 @@
|
|
|
555
512
|
"sources": [
|
|
556
513
|
{
|
|
557
514
|
"fileName": "projects/autonumeric/src/modules/autonumeric/autonumeric.directive.ts",
|
|
558
|
-
"line":
|
|
515
|
+
"line": 163,
|
|
559
516
|
"character": 9
|
|
560
517
|
}
|
|
561
518
|
],
|
|
@@ -624,7 +581,7 @@
|
|
|
624
581
|
"sources": [
|
|
625
582
|
{
|
|
626
583
|
"fileName": "projects/autonumeric/src/modules/autonumeric/autonumeric.directive.ts",
|
|
627
|
-
"line":
|
|
584
|
+
"line": 114,
|
|
628
585
|
"character": 9
|
|
629
586
|
}
|
|
630
587
|
],
|
|
@@ -677,7 +634,7 @@
|
|
|
677
634
|
"sources": [
|
|
678
635
|
{
|
|
679
636
|
"fileName": "projects/autonumeric/src/modules/autonumeric/autonumeric.directive.ts",
|
|
680
|
-
"line":
|
|
637
|
+
"line": 139,
|
|
681
638
|
"character": 9
|
|
682
639
|
}
|
|
683
640
|
],
|
|
@@ -731,7 +688,7 @@
|
|
|
731
688
|
"sources": [
|
|
732
689
|
{
|
|
733
690
|
"fileName": "projects/autonumeric/src/modules/autonumeric/autonumeric.directive.ts",
|
|
734
|
-
"line":
|
|
691
|
+
"line": 118,
|
|
735
692
|
"character": 9
|
|
736
693
|
}
|
|
737
694
|
],
|
|
@@ -804,7 +761,7 @@
|
|
|
804
761
|
"sources": [
|
|
805
762
|
{
|
|
806
763
|
"fileName": "projects/autonumeric/src/modules/autonumeric/autonumeric.directive.ts",
|
|
807
|
-
"line":
|
|
764
|
+
"line": 50,
|
|
808
765
|
"character": 13
|
|
809
766
|
}
|
|
810
767
|
],
|
|
@@ -913,12 +870,12 @@
|
|
|
913
870
|
{
|
|
914
871
|
"fileName": "autonumeric-demo.component.ts",
|
|
915
872
|
"filePath": "/projects/autonumeric/documentation/code-examples/autonumeric/currency/autonumeric-demo.component.ts",
|
|
916
|
-
"rawContents": "import { Component, OnInit } from '@angular/core';\
|
|
873
|
+
"rawContents": "import { Component, OnInit } from '@angular/core';\nimport {\n FormBuilder,\n FormControl,\n FormGroup,\n Validators,\n} from '@angular/forms';\n\nimport { SkyAutonumericOptions } from 'projects/sky-autonumeric/src/public-api';\n\n@Component({\n selector: 'app-autonumeric-demo',\n templateUrl: './autonumeric-demo.component.html',\n})\nexport class AutonumericDemoComponent implements OnInit {\n public autonumericOptions: SkyAutonumericOptions;\n\n public formGroup: FormGroup;\n\n constructor(private formBuilder: FormBuilder) {}\n\n public ngOnInit(): void {\n this.formGroup = this.formBuilder.group({\n donationAmount: new FormControl(1234.5678, [Validators.required]),\n });\n\n this.autonumericOptions = {\n currencySymbol: ' €',\n currencySymbolPlacement: 's',\n decimalPlaces: 2,\n decimalCharacter: ',',\n digitGroupSeparator: '',\n };\n }\n}\n"
|
|
917
874
|
},
|
|
918
875
|
{
|
|
919
876
|
"fileName": "autonumeric-demo.module.ts",
|
|
920
877
|
"filePath": "/projects/autonumeric/documentation/code-examples/autonumeric/currency/autonumeric-demo.module.ts",
|
|
921
|
-
"rawContents": "import {
|
|
878
|
+
"rawContents": "import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { ReactiveFormsModule } from '@angular/forms';\nimport { SkyIdModule } from '@skyux/core';\nimport { SkyInputBoxModule } from '@skyux/forms';\n\nimport { SkyAutonumericModule } from 'projects/sky-autonumeric/src/public-api';\n\nimport { AutonumericDemoComponent } from './autonumeric-demo.component';\n\n@NgModule({\n imports: [\n CommonModule,\n ReactiveFormsModule,\n SkyAutonumericModule,\n SkyIdModule,\n SkyInputBoxModule,\n ],\n declarations: [AutonumericDemoComponent],\n exports: [AutonumericDemoComponent],\n})\nexport class AutonumericDemoModule {}\n"
|
|
922
879
|
},
|
|
923
880
|
{
|
|
924
881
|
"fileName": "autonumeric-demo.component.html",
|
|
@@ -928,17 +885,17 @@
|
|
|
928
885
|
{
|
|
929
886
|
"fileName": "autonumeric-demo.component.ts",
|
|
930
887
|
"filePath": "/projects/autonumeric/documentation/code-examples/autonumeric/international-formatting/autonumeric-demo.component.ts",
|
|
931
|
-
"rawContents": "import { Component, OnInit } from '@angular/core';\
|
|
888
|
+
"rawContents": "import { Component, OnInit } from '@angular/core';\nimport {\n FormBuilder,\n FormControl,\n FormGroup,\n Validators,\n} from '@angular/forms';\n\nimport { SkyAutonumericOptions } from 'projects/sky-autonumeric/src/public-api';\n\n@Component({\n selector: 'app-autonumeric-demo',\n templateUrl: './autonumeric-demo.component.html',\n})\nexport class AutonumericDemoComponent implements OnInit {\n public autonumericOptions: SkyAutonumericOptions;\n\n public formGroup: FormGroup;\n\n constructor(private formBuilder: FormBuilder) {}\n\n public ngOnInit(): void {\n this.formGroup = this.formBuilder.group({\n donationAmount: new FormControl(1234.5678, [Validators.required]),\n });\n\n this.autonumericOptions = {\n decimalCharacter: ',',\n decimalPlaces: 4,\n digitGroupSeparator: '',\n };\n }\n}\n"
|
|
932
889
|
},
|
|
933
890
|
{
|
|
934
891
|
"fileName": "autonumeric-demo.module.ts",
|
|
935
892
|
"filePath": "/projects/autonumeric/documentation/code-examples/autonumeric/international-formatting/autonumeric-demo.module.ts",
|
|
936
|
-
"rawContents": "import {
|
|
893
|
+
"rawContents": "import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { ReactiveFormsModule } from '@angular/forms';\nimport { SkyIdModule } from '@skyux/core';\nimport { SkyInputBoxModule } from '@skyux/forms';\n\nimport { SkyAutonumericModule } from 'projects/sky-autonumeric/src/public-api';\n\nimport { AutonumericDemoComponent } from './autonumeric-demo.component';\n\n@NgModule({\n imports: [\n CommonModule,\n ReactiveFormsModule,\n SkyAutonumericModule,\n SkyIdModule,\n SkyInputBoxModule,\n ],\n declarations: [AutonumericDemoComponent],\n exports: [AutonumericDemoComponent],\n})\nexport class AutonumericDemoModule {}\n"
|
|
937
894
|
},
|
|
938
895
|
{
|
|
939
896
|
"fileName": "autonumeric-demo-options-provider.ts",
|
|
940
897
|
"filePath": "/projects/autonumeric/documentation/code-examples/autonumeric/options-provider/autonumeric-demo-options-provider.ts",
|
|
941
|
-
"rawContents": "import { SkyAutonumericOptions } from 'projects/sky-autonumeric/src/public-api';\
|
|
898
|
+
"rawContents": "import { SkyAutonumericOptions } from 'projects/sky-autonumeric/src/public-api';\nimport { SkyAutonumericOptionsProvider } from 'projects/sky-autonumeric/src/public-api';\n\nexport class AutonumericDemoOptionsProvider extends SkyAutonumericOptionsProvider {\n constructor() {\n super();\n }\n\n public getConfig(): SkyAutonumericOptions {\n return {\n currencySymbol: ' €',\n currencySymbolPlacement: 's',\n decimalPlaces: 2,\n decimalCharacter: ',',\n digitGroupSeparator: '',\n };\n }\n}\n"
|
|
942
899
|
},
|
|
943
900
|
{
|
|
944
901
|
"fileName": "autonumeric-demo.component.html",
|
|
@@ -948,12 +905,12 @@
|
|
|
948
905
|
{
|
|
949
906
|
"fileName": "autonumeric-demo.component.ts",
|
|
950
907
|
"filePath": "/projects/autonumeric/documentation/code-examples/autonumeric/options-provider/autonumeric-demo.component.ts",
|
|
951
|
-
"rawContents": "import { Component, OnInit } from '@angular/core';\
|
|
908
|
+
"rawContents": "import { Component, OnInit } from '@angular/core';\nimport {\n FormBuilder,\n FormControl,\n FormGroup,\n Validators,\n} from '@angular/forms';\n\nimport { SkyAutonumericOptions } from 'projects/sky-autonumeric/src/public-api';\nimport { SkyAutonumericOptionsProvider } from 'projects/sky-autonumeric/src/public-api';\n\nimport { AutonumericDemoOptionsProvider } from './autonumeric-demo-options-provider';\n\n@Component({\n selector: 'app-autonumeric-demo',\n templateUrl: './autonumeric-demo.component.html',\n providers: [\n {\n provide: SkyAutonumericOptionsProvider,\n useClass: AutonumericDemoOptionsProvider,\n },\n ],\n})\nexport class AutonumericDemoComponent implements OnInit {\n public donationOptions: SkyAutonumericOptions = {};\n\n public formGroup: FormGroup;\n\n public pledgeOptions: SkyAutonumericOptions = {\n decimalPlaces: 0,\n };\n\n constructor(private formBuilder: FormBuilder) {}\n\n public ngOnInit(): void {\n this.formGroup = this.formBuilder.group({\n donationAmount: new FormControl(1234.5678, [Validators.required]),\n pledgeAmount: new FormControl(2345.6789, [Validators.required]),\n });\n }\n}\n"
|
|
952
909
|
},
|
|
953
910
|
{
|
|
954
911
|
"fileName": "autonumeric-demo.module.ts",
|
|
955
912
|
"filePath": "/projects/autonumeric/documentation/code-examples/autonumeric/options-provider/autonumeric-demo.module.ts",
|
|
956
|
-
"rawContents": "import {
|
|
913
|
+
"rawContents": "import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { ReactiveFormsModule } from '@angular/forms';\nimport { SkyIdModule } from '@skyux/core';\nimport { SkyInputBoxModule } from '@skyux/forms';\n\nimport { SkyAutonumericModule } from 'projects/sky-autonumeric/src/public-api';\n\nimport { AutonumericDemoComponent } from './autonumeric-demo.component';\n\n@NgModule({\n imports: [\n CommonModule,\n ReactiveFormsModule,\n SkyAutonumericModule,\n SkyIdModule,\n SkyInputBoxModule,\n ],\n declarations: [AutonumericDemoComponent],\n exports: [AutonumericDemoComponent],\n})\nexport class AutonumericDemoModule {}\n"
|
|
957
914
|
},
|
|
958
915
|
{
|
|
959
916
|
"fileName": "autonumeric-demo.component.html",
|
|
@@ -963,12 +920,12 @@
|
|
|
963
920
|
{
|
|
964
921
|
"fileName": "autonumeric-demo.component.ts",
|
|
965
922
|
"filePath": "/projects/autonumeric/documentation/code-examples/autonumeric/preset/autonumeric-demo.component.ts",
|
|
966
|
-
"rawContents": "import { Component, OnInit } from '@angular/core';\
|
|
923
|
+
"rawContents": "import { Component, OnInit } from '@angular/core';\nimport {\n FormBuilder,\n FormControl,\n FormGroup,\n Validators,\n} from '@angular/forms';\n\nimport { SkyAutonumericOptions } from 'projects/sky-autonumeric/src/public-api';\n\n@Component({\n selector: 'app-autonumeric-demo',\n templateUrl: './autonumeric-demo.component.html',\n})\nexport class AutonumericDemoComponent implements OnInit {\n public autonumericOptions: SkyAutonumericOptions;\n\n public formGroup: FormGroup;\n\n constructor(private formBuilder: FormBuilder) {}\n\n public ngOnInit(): void {\n this.formGroup = this.formBuilder.group({\n donationAmount: new FormControl(1234.5678, [Validators.required]),\n });\n\n this.autonumericOptions = 'Chinese';\n }\n}\n"
|
|
967
924
|
},
|
|
968
925
|
{
|
|
969
926
|
"fileName": "autonumeric-demo.module.ts",
|
|
970
927
|
"filePath": "/projects/autonumeric/documentation/code-examples/autonumeric/preset/autonumeric-demo.module.ts",
|
|
971
|
-
"rawContents": "import {
|
|
928
|
+
"rawContents": "import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { ReactiveFormsModule } from '@angular/forms';\nimport { SkyIdModule } from '@skyux/core';\nimport { SkyInputBoxModule } from '@skyux/forms';\n\nimport { SkyAutonumericModule } from 'projects/sky-autonumeric/src/public-api';\n\nimport { AutonumericDemoComponent } from './autonumeric-demo.component';\n\n@NgModule({\n imports: [\n CommonModule,\n ReactiveFormsModule,\n SkyAutonumericModule,\n SkyIdModule,\n SkyInputBoxModule,\n ],\n declarations: [AutonumericDemoComponent],\n exports: [AutonumericDemoComponent],\n})\nexport class AutonumericDemoModule {}\n"
|
|
972
929
|
}
|
|
973
930
|
]
|
|
974
931
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ChangeDetectorRef, Directive, ElementRef,
|
|
1
|
+
import { ChangeDetectorRef, Directive, ElementRef, HostListener, Input, Renderer2, forwardRef, } from '@angular/core';
|
|
2
2
|
import { NG_VALIDATORS, NG_VALUE_ACCESSOR, } from '@angular/forms';
|
|
3
3
|
import AutoNumeric from 'autonumeric';
|
|
4
|
-
import {
|
|
4
|
+
import { Subject, fromEvent } from 'rxjs';
|
|
5
5
|
import { takeUntil } from 'rxjs/operators';
|
|
6
6
|
import { SkyAutonumericOptionsProvider } from './autonumeric-options-provider';
|
|
7
7
|
import * as i0 from "@angular/core";
|
|
@@ -30,9 +30,9 @@ export class SkyAutonumericDirective {
|
|
|
30
30
|
this.changeDetector = changeDetector;
|
|
31
31
|
this.isFirstChange = true;
|
|
32
32
|
this.ngUnsubscribe = new Subject();
|
|
33
|
-
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
34
34
|
this.onChange = (_) => { };
|
|
35
|
-
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
36
36
|
this.onTouched = () => { };
|
|
37
37
|
this.autonumericInstance = new AutoNumeric(this.elementRef.nativeElement);
|
|
38
38
|
}
|
|
@@ -1 +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,GAGlB,MAAM,gBAAgB,CAAC;AAExB,OAAO,WAAW,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAE1C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAI3C,OAAO,EAAE,6BAA6B,EAAE,MAAM,gCAAgC,CAAC;;;AAE/E,sDAAsD;AACtD,MAAM,8BAA8B,GAAG;IACrC,OAAO,EAAE,iBAAiB;IAC1B,WAAW,EAAE,UAAU,CAAC,GAAG,EAAE,CAAC,uBAAuB,CAAC;IACtD,KAAK,EAAE,IAAI;CACZ,CAAC;AAEF,MAAM,yBAAyB,GAAG;IAChC,OAAO,EAAE,aAAa;IACtB,WAAW,EAAE,UAAU,CAAC,GAAG,EAAE,CAAC,uBAAuB,CAAC;IACtD,KAAK,EAAE,IAAI;CACZ,CAAC;AACF,gBAAgB;AAEhB;;;GAGG;AAKH,MAAM,OAAO,uBAAuB;IAoBlC,YACU,UAAsB,EACtB,YAA2C,EAC3C,QAAmB,EACnB,cAAiC;QAHjC,eAAU,GAAV,UAAU,CAAY;QACtB,iBAAY,GAAZ,YAAY,CAA+B;QAC3C,aAAQ,GAAR,QAAQ,CAAW;QACnB,mBAAc,GAAd,cAAc,CAAmB;QATnC,kBAAa,GAAG,IAAI,CAAC;QAGrB,kBAAa,GAAG,IAAI,OAAO,EAAQ,CAAC;QAuJ5C,0BAA0B;QAClB,aAAQ,GAAG,CAAC,CAAqB,EAAE,EAAE,GAAE,CAAC,CAAC;QACjD,0BAA0B;QAClB,cAAS,GAAG,GA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OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,aAAa,EAAE,UAAU,CAAC,CAAC;IACtD,CAAC;;qHAvKU,uBAAuB;yGAAvB,uBAAuB,2IAFvB,CAAC,8BAA8B,EAAE,yBAAyB,CAAC;4FAE3D,uBAAuB;kBAJnC,SAAS;mBAAC;oBACT,QAAQ,EAAE,uBAAuB;oBACjC,SAAS,EAAE,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"]}
|
|
1
|
+
{"version":3,"file":"autonumeric.directive.js","sourceRoot":"","sources":["../../../../../../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C,EAAE,EAAE,aAAa,EAAE,UAAU,CAAC,CAAC;IACtD,CAAC;;qHAvKU,uBAAuB;yGAAvB,uBAAuB,2IAFvB,CAAC,8BAA8B,EAAE,yBAAyB,CAAC;4FAE3D,uBAAuB;kBAJnC,SAAS;mBAAC;oBACT,QAAQ,EAAE,uBAAuB;oBACjC,SAAS,EAAE,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 HostListener,\n Input,\n OnDestroy,\n OnInit,\n Renderer2,\n forwardRef,\n} from '@angular/core';\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';\nimport { Subject, fromEvent } from 'rxjs';\nimport { takeUntil } from 'rxjs/operators';\n\nimport { SkyAutonumericOptions } from './autonumeric-options';\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; // 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 ? 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 // eslint-disable-next-line @typescript-eslint/no-empty-function\n private onChange = (_: number | undefined) => {};\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n private onTouched = () => {};\n}\n"]}
|
|
@@ -1 +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;
|
|
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;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,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';\nimport { NgModule } from '@angular/core';\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"]}
|
|
@@ -52,9 +52,9 @@ class SkyAutonumericDirective {
|
|
|
52
52
|
this.changeDetector = changeDetector;
|
|
53
53
|
this.isFirstChange = true;
|
|
54
54
|
this.ngUnsubscribe = new Subject();
|
|
55
|
-
|
|
55
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
56
56
|
this.onChange = (_) => { };
|
|
57
|
-
|
|
57
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
58
58
|
this.onTouched = () => { };
|
|
59
59
|
this.autonumericInstance = new AutoNumeric(this.elementRef.nativeElement);
|
|
60
60
|
}
|
|
@@ -1 +1 @@
|
|
|
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 SkyAutonumericModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;AAIA;;;;MAOa,6BAA6B;;;;;IAKjC,SAAS;QACd,OAAO,EAAE,CAAC;KACX;;2HAPU,6BAA6B;+HAA7B,6BAA6B,cAF5B,MAAM;4FAEP,6BAA6B;kBAHzC,UAAU;mBAAC;oBACV,UAAU,EAAE,MAAM;iBACnB;;;ACqBD;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;AAEA;;;;MAQa,uBAAuB;IAoBlC,YACU,UAAsB,EACtB,YAA2C,EAC3C,QAAmB,EACnB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AU,GAAG,KAAK,CAAC;SACpB;QAED,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,aAAa,EAAE,UAAU,CAAC,CAAC;KACrD;;qHAvKU,uBAAuB;yGAAvB,uBAAuB,2IAFvB,CAAC,8BAA8B,EAAE,yBAAyB,CAAC;4FAE3D,uBAAuB;kBAJnC,SAAS;mBAAC;oBACT,QAAQ,EAAE,uBAAuB;oBACjC,SAAS,EAAE,CAAC,8BAA8B,EAAE,yBAAyB,CAAC;iBACvE;kMAQY,cAAc;sBADxB,KAAK;gBAgHC,MAAM;sBADZ,YAAY;uBAAC,MAAM;;;MC7JT,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;;;ACZD;;;;;;"}
|
|
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 HostListener,\n Input,\n OnDestroy,\n OnInit,\n Renderer2,\n forwardRef,\n} from '@angular/core';\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';\nimport { Subject, fromEvent } from 'rxjs';\nimport { takeUntil } from 'rxjs/operators';\n\nimport { SkyAutonumericOptions } from './autonumeric-options';\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; // 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 ? 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 // eslint-disable-next-line @typescript-eslint/no-empty-function\n private onChange = (_: number | undefined) => {};\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n private onTouched = () => {};\n}\n","import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\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","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;AAIA;;;;MAO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W,EAAE,mBAAmB,CAAC;oBACzD,OAAO,EAAE,CAAC,uBAAuB,CAAC;iBACnC;;;ACVD;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,15 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skyux/autonumeric",
|
|
3
|
-
"version": "5.
|
|
4
|
-
"dependencies": {
|
|
5
|
-
"autonumeric": "4.6.0",
|
|
6
|
-
"tslib": "^2.3.1"
|
|
7
|
-
},
|
|
8
|
-
"peerDependencies": {
|
|
9
|
-
"@angular/common": "^12.2.16",
|
|
10
|
-
"@angular/core": "^12.2.16",
|
|
11
|
-
"@angular/forms": "^12.2.16"
|
|
12
|
-
},
|
|
3
|
+
"version": "5.6.2",
|
|
13
4
|
"author": "Blackbaud, Inc.",
|
|
14
5
|
"keywords": [
|
|
15
6
|
"blackbaud",
|
|
@@ -24,6 +15,15 @@
|
|
|
24
15
|
"url": "https://github.com/blackbaud/skyux/issues"
|
|
25
16
|
},
|
|
26
17
|
"homepage": "https://github.com/blackbaud/skyux#readme",
|
|
18
|
+
"peerDependencies": {
|
|
19
|
+
"@angular/common": "^12.2.16",
|
|
20
|
+
"@angular/core": "^12.2.16",
|
|
21
|
+
"@angular/forms": "^12.2.16"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"autonumeric": "4.6.0",
|
|
25
|
+
"tslib": "^2.3.1"
|
|
26
|
+
},
|
|
27
27
|
"main": "bundles/skyux-autonumeric.umd.js",
|
|
28
28
|
"module": "fesm2015/skyux-autonumeric.js",
|
|
29
29
|
"es2015": "fesm2015/skyux-autonumeric.js",
|