@skyux/autonumeric 5.0.0 → 5.5.0-alpha.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.
Files changed (32) hide show
  1. package/README.md +4 -67
  2. package/bundles/skyux-autonumeric.umd.js +33 -60
  3. package/documentation.json +113 -84
  4. package/esm2015/index.js +7 -0
  5. package/esm2015/index.js.map +1 -0
  6. package/esm2015/lib/modules/autonumeric/autonumeric-options-provider.js +24 -0
  7. package/esm2015/lib/modules/autonumeric/autonumeric-options-provider.js.map +1 -0
  8. package/esm2015/lib/modules/autonumeric/autonumeric-options.js +2 -0
  9. package/esm2015/lib/modules/autonumeric/autonumeric-options.js.map +1 -0
  10. package/esm2015/lib/modules/autonumeric/autonumeric.directive.js +171 -0
  11. package/esm2015/lib/modules/autonumeric/autonumeric.directive.js.map +1 -0
  12. package/esm2015/lib/modules/autonumeric/autonumeric.module.js +19 -0
  13. package/esm2015/lib/modules/autonumeric/autonumeric.module.js.map +1 -0
  14. package/esm2015/skyux-autonumeric.js +2 -2
  15. package/esm2015/skyux-autonumeric.js.map +1 -0
  16. package/fesm2015/skyux-autonumeric.js +25 -50
  17. package/fesm2015/skyux-autonumeric.js.map +1 -1
  18. package/index.d.ts +4 -0
  19. package/{modules → lib/modules}/autonumeric/autonumeric-options-provider.d.ts +0 -0
  20. package/{modules → lib/modules}/autonumeric/autonumeric-options.d.ts +0 -0
  21. package/{modules → lib/modules}/autonumeric/autonumeric.directive.d.ts +2 -3
  22. package/{modules → lib/modules}/autonumeric/autonumeric.module.d.ts +0 -0
  23. package/package.json +5 -5
  24. package/skyux-autonumeric.d.ts +1 -1
  25. package/LICENSE +0 -21
  26. package/bundles/skyux-autonumeric.umd.js.map +0 -1
  27. package/esm2015/modules/autonumeric/autonumeric-options-provider.js +0 -24
  28. package/esm2015/modules/autonumeric/autonumeric-options.js +0 -2
  29. package/esm2015/modules/autonumeric/autonumeric.directive.js +0 -181
  30. package/esm2015/modules/autonumeric/autonumeric.module.js +0 -33
  31. package/esm2015/public-api.js +0 -7
  32. package/public-api.d.ts +0 -4
package/README.md CHANGED
@@ -1,70 +1,7 @@
1
- # @skyux/autonumeric
1
+ # autonumeric
2
2
 
3
- [![npm](https://img.shields.io/npm/v/@skyux/autonumeric.svg)](https://www.npmjs.com/package/@skyux/autonumeric)
4
- ![SKY UX CI](https://github.com/blackbaud/skyux-autonumeric/workflows/SKY%20UX%20CI/badge.svg)
5
- [![coverage](https://codecov.io/gh/blackbaud/skyux-autonumeric/branch/master/graphs/badge.svg?branch=master)](https://codecov.io/gh/blackbaud/skyux-autonumeric/branch/master)
3
+ This library was generated with [Nx](https://nx.dev).
6
4
 
7
- ### Usage
5
+ ## Running unit tests
8
6
 
9
- Add the autonumeric attribute to an input element.
10
-
11
- ```
12
- <input
13
- type="text"
14
- skyAutonumeric
15
- >
16
- ```
17
-
18
- To use a [predefined set of options](https://github.com/autoNumeric/autoNumeric#predefined-options):
19
-
20
- ```
21
- <input
22
- type="text"
23
- skyAutonumeric="dollar"
24
- />
25
- ```
26
-
27
- To use a [custom set of options](https://github.com/autoNumeric/autoNumeric#options):
28
-
29
- ```
30
- <input
31
- type="text"
32
- [skyAutonumeric]="{ decimalPlaces: 5 }"
33
- />
34
- ```
35
-
36
- ### Global Configuration
37
-
38
- To configure all `skyAutonumeric` instances in your SPA the same way, create a class that extends the base class `SkyAutonumericOptionsProvider` and supply it in the module providers.
39
-
40
- **my-autonumeric-options-provider.ts**
41
- ```
42
- export class MyAutonumericOptionsProvider extends SkyAutonumericOptionsProvider {
43
- constructor() {
44
- super();
45
- }
46
-
47
- public getConfig(): SkyAutonumericOptions {
48
- return {
49
- decimalPlaces: 5
50
- };
51
- }
52
- }
53
- ```
54
-
55
- **app.module.ts**
56
- ```
57
- providers: [
58
- {
59
- provide: SkyAutonumericOptionsProvider,
60
- useClass: MyAutonumericOptionsProvider
61
- }
62
- ]
63
- ```
64
-
65
- ## Install dependencies and view the example
66
-
67
- ```
68
- skyux install
69
- skyux serve
70
- ```
7
+ Run `nx test autonumeric` to execute the unit tests.
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/forms'), require('rxjs'), require('rxjs/operators'), require('autonumeric')) :
3
- typeof define === 'function' && define.amd ? define('@skyux/autonumeric', ['exports', '@angular/core', '@angular/common', '@angular/forms', 'rxjs', 'rxjs/operators', 'autonumeric'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.skyux = global.skyux || {}, global.skyux.autonumeric = {}), global.ng.core, global.ng.common, global.ng.forms, global.rxjs, global.rxjs.operators, global.AutoNumeric));
5
- }(this, (function (exports, i0, common, forms, rxjs, operators, AutoNumeric) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/forms'), require('autonumeric'), require('rxjs'), require('rxjs/operators')) :
3
+ typeof define === 'function' && define.amd ? define('@skyux/autonumeric', ['exports', '@angular/core', '@angular/common', '@angular/forms', 'autonumeric', 'rxjs', 'rxjs/operators'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.skyux = global.skyux || {}, global.skyux.autonumeric = {}), global.ng.core, global.ng.common, global.ng.forms, global.AutoNumeric, global.rxjs, global.rxjs.operators));
5
+ })(this, (function (exports, i0, common, forms, AutoNumeric, rxjs, operators) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -15,14 +15,12 @@
15
15
  var d = Object.getOwnPropertyDescriptor(e, k);
16
16
  Object.defineProperty(n, k, d.get ? d : {
17
17
  enumerable: true,
18
- get: function () {
19
- return e[k];
20
- }
18
+ get: function () { return e[k]; }
21
19
  });
22
20
  }
23
21
  });
24
22
  }
25
- n['default'] = e;
23
+ n["default"] = e;
26
24
  return Object.freeze(n);
27
25
  }
28
26
 
@@ -45,12 +43,12 @@
45
43
  };
46
44
  return SkyAutonumericOptionsProvider;
47
45
  }());
48
- SkyAutonumericOptionsProvider.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0__namespace, type: SkyAutonumericOptionsProvider, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
49
- SkyAutonumericOptionsProvider.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0__namespace, type: SkyAutonumericOptionsProvider, providedIn: 'root' });
50
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0__namespace, type: SkyAutonumericOptionsProvider, decorators: [{
46
+ SkyAutonumericOptionsProvider.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyAutonumericOptionsProvider, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
47
+ SkyAutonumericOptionsProvider.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyAutonumericOptionsProvider, providedIn: 'root' });
48
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyAutonumericOptionsProvider, decorators: [{
51
49
  type: i0.Injectable,
52
50
  args: [{
53
- providedIn: 'root'
51
+ providedIn: 'root',
54
52
  }]
55
53
  }] });
56
54
 
@@ -58,12 +56,12 @@
58
56
  var SKY_AUTONUMERIC_VALUE_ACCESSOR = {
59
57
  provide: forms.NG_VALUE_ACCESSOR,
60
58
  useExisting: i0.forwardRef(function () { return SkyAutonumericDirective; }),
61
- multi: true
59
+ multi: true,
62
60
  };
63
61
  var SKY_AUTONUMERIC_VALIDATOR = {
64
62
  provide: forms.NG_VALIDATORS,
65
63
  useExisting: i0.forwardRef(function () { return SkyAutonumericDirective; }),
66
- multi: true
64
+ multi: true,
67
65
  };
68
66
  // tslint:enable
69
67
  /**
@@ -82,7 +80,7 @@
82
80
  this.onChange = function (_) { };
83
81
  /* istanbul ignore next */
84
82
  this.onTouched = function () { };
85
- this.createAutonumericInstance();
83
+ this.autonumericInstance = new AutoNumeric__default["default"](this.elementRef.nativeElement);
86
84
  }
87
85
  Object.defineProperty(SkyAutonumericDirective.prototype, "skyAutonumeric", {
88
86
  /**
@@ -102,7 +100,7 @@
102
100
  this.autonumericOptions = this.globalConfig.getConfig();
103
101
  }
104
102
  this.updateAutonumericInstance();
105
- rxjs.fromEvent(this.elementRef.nativeElement, 'keyup')
103
+ rxjs.fromEvent(this.elementRef.nativeElement, 'input')
106
104
  .pipe(operators.takeUntil(this.ngUnsubscribe))
107
105
  .subscribe(function () {
108
106
  var numericValue = _this.getNumericValue();
@@ -139,8 +137,7 @@
139
137
  this.control.markAsPristine();
140
138
  }
141
139
  }
142
- var isNumber = typeof value === 'number' && value !== null && value !== undefined;
143
- if (isNumber) {
140
+ if (typeof value === 'number') {
144
141
  this.autonumericInstance.set(value);
145
142
  }
146
143
  else {
@@ -157,7 +154,7 @@
157
154
  }
158
155
  if (typeof control.value !== 'number') {
159
156
  return {
160
- 'notTypeOfNumber': { value: control.value }
157
+ notTypeOfNumber: { value: control.value },
161
158
  };
162
159
  }
163
160
  return noErrors;
@@ -173,10 +170,9 @@
173
170
  };
174
171
  SkyAutonumericDirective.prototype.getNumericValue = function () {
175
172
  var inputValue = this.getInputValue();
176
- var numericValue = (inputValue && !this.isInputValueTheCurrencySymbol(inputValue))
173
+ return inputValue && !this.isInputValueTheCurrencySymbol(inputValue)
177
174
  ? this.autonumericInstance.getNumber()
178
175
  : undefined;
179
- return numericValue;
180
176
  };
181
177
  /**
182
178
  * Due to AutoNumeric's hover logic - when AutoNumeric has a currency symbol the value
@@ -188,22 +184,19 @@
188
184
  var _a, _b;
189
185
  /* istanbul ignore next */
190
186
  var currencySymbol = ((_b = (_a = this.autonumericOptions) === null || _a === void 0 ? void 0 : _a.currencySymbol) !== null && _b !== void 0 ? _b : '').trim();
191
- return (currencySymbol && inputValue === currencySymbol);
187
+ return !!currencySymbol && inputValue === currencySymbol;
192
188
  };
193
189
  SkyAutonumericDirective.prototype.getInputValue = function () {
194
190
  return this.elementRef.nativeElement.value;
195
191
  };
196
- SkyAutonumericDirective.prototype.createAutonumericInstance = function () {
197
- this.autonumericInstance = new AutoNumeric__default['default'](this.elementRef.nativeElement);
198
- };
199
192
  SkyAutonumericDirective.prototype.updateAutonumericInstance = function () {
200
193
  this.autonumericInstance.update(this.autonumericOptions);
201
194
  };
202
195
  SkyAutonumericDirective.prototype.mergeOptions = function (value) {
203
196
  var globalOptions = this.globalConfig.getConfig();
204
- var newOptions = {};
197
+ var newOptions;
205
198
  if (typeof value === 'string') {
206
- var predefinedOptions = AutoNumeric__default['default'].getPredefinedOptions();
199
+ var predefinedOptions = AutoNumeric__default["default"].getPredefinedOptions();
207
200
  newOptions = predefinedOptions[value];
208
201
  }
209
202
  else {
@@ -213,19 +206,13 @@
213
206
  };
214
207
  return SkyAutonumericDirective;
215
208
  }());
216
- SkyAutonumericDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0__namespace, type: SkyAutonumericDirective, deps: [{ token: i0__namespace.ElementRef }, { token: SkyAutonumericOptionsProvider }, { token: i0__namespace.Renderer2 }, { token: i0__namespace.ChangeDetectorRef }], target: i0__namespace.ɵɵFactoryTarget.Directive });
217
- SkyAutonumericDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.7", type: SkyAutonumericDirective, selector: "input[skyAutonumeric]", inputs: { skyAutonumeric: "skyAutonumeric" }, host: { listeners: { "blur": "onBlur()" } }, providers: [
218
- SKY_AUTONUMERIC_VALUE_ACCESSOR,
219
- SKY_AUTONUMERIC_VALIDATOR
220
- ], ngImport: i0__namespace });
221
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0__namespace, type: SkyAutonumericDirective, decorators: [{
209
+ SkyAutonumericDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyAutonumericDirective, deps: [{ token: i0__namespace.ElementRef }, { token: SkyAutonumericOptionsProvider }, { token: i0__namespace.Renderer2 }, { token: i0__namespace.ChangeDetectorRef }], target: i0__namespace.ɵɵFactoryTarget.Directive });
210
+ SkyAutonumericDirective.ɵdir = i0__namespace.ɵɵ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__namespace });
211
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyAutonumericDirective, decorators: [{
222
212
  type: i0.Directive,
223
213
  args: [{
224
214
  selector: 'input[skyAutonumeric]',
225
- providers: [
226
- SKY_AUTONUMERIC_VALUE_ACCESSOR,
227
- SKY_AUTONUMERIC_VALIDATOR
228
- ]
215
+ providers: [SKY_AUTONUMERIC_VALUE_ACCESSOR, SKY_AUTONUMERIC_VALIDATOR],
229
216
  }]
230
217
  }], ctorParameters: function () { return [{ type: i0__namespace.ElementRef }, { type: SkyAutonumericOptionsProvider }, { type: i0__namespace.Renderer2 }, { type: i0__namespace.ChangeDetectorRef }]; }, propDecorators: { skyAutonumeric: [{
231
218
  type: i0.Input
@@ -239,29 +226,15 @@
239
226
  }
240
227
  return SkyAutonumericModule;
241
228
  }());
242
- SkyAutonumericModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0__namespace, type: SkyAutonumericModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
243
- SkyAutonumericModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0__namespace, type: SkyAutonumericModule, declarations: [SkyAutonumericDirective], imports: [common.CommonModule,
244
- forms.FormsModule,
245
- forms.ReactiveFormsModule], exports: [SkyAutonumericDirective] });
246
- SkyAutonumericModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0__namespace, type: SkyAutonumericModule, imports: [[
247
- common.CommonModule,
248
- forms.FormsModule,
249
- forms.ReactiveFormsModule
250
- ]] });
251
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0__namespace, type: SkyAutonumericModule, decorators: [{
229
+ SkyAutonumericModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyAutonumericModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
230
+ SkyAutonumericModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyAutonumericModule, declarations: [SkyAutonumericDirective], imports: [common.CommonModule, forms.FormsModule, forms.ReactiveFormsModule], exports: [SkyAutonumericDirective] });
231
+ SkyAutonumericModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyAutonumericModule, imports: [[common.CommonModule, forms.FormsModule, forms.ReactiveFormsModule]] });
232
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyAutonumericModule, decorators: [{
252
233
  type: i0.NgModule,
253
234
  args: [{
254
- declarations: [
255
- SkyAutonumericDirective
256
- ],
257
- imports: [
258
- common.CommonModule,
259
- forms.FormsModule,
260
- forms.ReactiveFormsModule
261
- ],
262
- exports: [
263
- SkyAutonumericDirective
264
- ]
235
+ declarations: [SkyAutonumericDirective],
236
+ imports: [common.CommonModule, forms.FormsModule, forms.ReactiveFormsModule],
237
+ exports: [SkyAutonumericDirective],
265
238
  }]
266
239
  }] });
267
240
 
@@ -271,9 +244,9 @@
271
244
 
272
245
  exports.SkyAutonumericModule = SkyAutonumericModule;
273
246
  exports.SkyAutonumericOptionsProvider = SkyAutonumericOptionsProvider;
274
- exports1 = SkyAutonumericDirective;
247
+ exports["λ1"] = SkyAutonumericDirective;
275
248
 
276
249
  Object.defineProperty(exports, '__esModule', { value: true });
277
250
 
278
- })));
251
+ }));
279
252
  //# sourceMappingURL=skyux-autonumeric.umd.js.map