@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.
Files changed (32) hide show
  1. package/README.md +4 -67
  2. package/bundles/skyux-autonumeric.umd.js +27 -52
  3. package/documentation.json +112 -80
  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 +24 -49
  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 +18 -4
  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
 
@@ -43,12 +43,12 @@
43
43
  };
44
44
  return SkyAutonumericOptionsProvider;
45
45
  }());
46
- SkyAutonumericOptionsProvider.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: SkyAutonumericOptionsProvider, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
47
- SkyAutonumericOptionsProvider.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: SkyAutonumericOptionsProvider, providedIn: 'root' });
48
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", 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: [{
49
49
  type: i0.Injectable,
50
50
  args: [{
51
- providedIn: 'root'
51
+ providedIn: 'root',
52
52
  }]
53
53
  }] });
54
54
 
@@ -56,12 +56,12 @@
56
56
  var SKY_AUTONUMERIC_VALUE_ACCESSOR = {
57
57
  provide: forms.NG_VALUE_ACCESSOR,
58
58
  useExisting: i0.forwardRef(function () { return SkyAutonumericDirective; }),
59
- multi: true
59
+ multi: true,
60
60
  };
61
61
  var SKY_AUTONUMERIC_VALIDATOR = {
62
62
  provide: forms.NG_VALIDATORS,
63
63
  useExisting: i0.forwardRef(function () { return SkyAutonumericDirective; }),
64
- multi: true
64
+ multi: true,
65
65
  };
66
66
  // tslint:enable
67
67
  /**
@@ -80,7 +80,7 @@
80
80
  this.onChange = function (_) { };
81
81
  /* istanbul ignore next */
82
82
  this.onTouched = function () { };
83
- this.createAutonumericInstance();
83
+ this.autonumericInstance = new AutoNumeric__default["default"](this.elementRef.nativeElement);
84
84
  }
85
85
  Object.defineProperty(SkyAutonumericDirective.prototype, "skyAutonumeric", {
86
86
  /**
@@ -137,8 +137,7 @@
137
137
  this.control.markAsPristine();
138
138
  }
139
139
  }
140
- var isNumber = typeof value === 'number' && value !== null && value !== undefined;
141
- if (isNumber) {
140
+ if (typeof value === 'number') {
142
141
  this.autonumericInstance.set(value);
143
142
  }
144
143
  else {
@@ -155,7 +154,7 @@
155
154
  }
156
155
  if (typeof control.value !== 'number') {
157
156
  return {
158
- 'notTypeOfNumber': { value: control.value }
157
+ notTypeOfNumber: { value: control.value },
159
158
  };
160
159
  }
161
160
  return noErrors;
@@ -171,10 +170,9 @@
171
170
  };
172
171
  SkyAutonumericDirective.prototype.getNumericValue = function () {
173
172
  var inputValue = this.getInputValue();
174
- var numericValue = (inputValue && !this.isInputValueTheCurrencySymbol(inputValue))
173
+ return inputValue && !this.isInputValueTheCurrencySymbol(inputValue)
175
174
  ? this.autonumericInstance.getNumber()
176
175
  : undefined;
177
- return numericValue;
178
176
  };
179
177
  /**
180
178
  * Due to AutoNumeric's hover logic - when AutoNumeric has a currency symbol the value
@@ -186,20 +184,17 @@
186
184
  var _a, _b;
187
185
  /* istanbul ignore next */
188
186
  var currencySymbol = ((_b = (_a = this.autonumericOptions) === null || _a === void 0 ? void 0 : _a.currencySymbol) !== null && _b !== void 0 ? _b : '').trim();
189
- return (currencySymbol && inputValue === currencySymbol);
187
+ return !!currencySymbol && inputValue === currencySymbol;
190
188
  };
191
189
  SkyAutonumericDirective.prototype.getInputValue = function () {
192
190
  return this.elementRef.nativeElement.value;
193
191
  };
194
- SkyAutonumericDirective.prototype.createAutonumericInstance = function () {
195
- this.autonumericInstance = new AutoNumeric__default["default"](this.elementRef.nativeElement);
196
- };
197
192
  SkyAutonumericDirective.prototype.updateAutonumericInstance = function () {
198
193
  this.autonumericInstance.update(this.autonumericOptions);
199
194
  };
200
195
  SkyAutonumericDirective.prototype.mergeOptions = function (value) {
201
196
  var globalOptions = this.globalConfig.getConfig();
202
- var newOptions = {};
197
+ var newOptions;
203
198
  if (typeof value === 'string') {
204
199
  var predefinedOptions = AutoNumeric__default["default"].getPredefinedOptions();
205
200
  newOptions = predefinedOptions[value];
@@ -211,19 +206,13 @@
211
206
  };
212
207
  return SkyAutonumericDirective;
213
208
  }());
214
- SkyAutonumericDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", 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 });
215
- SkyAutonumericDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.12", type: SkyAutonumericDirective, selector: "input[skyAutonumeric]", inputs: { skyAutonumeric: "skyAutonumeric" }, host: { listeners: { "blur": "onBlur()" } }, providers: [
216
- SKY_AUTONUMERIC_VALUE_ACCESSOR,
217
- SKY_AUTONUMERIC_VALIDATOR
218
- ], ngImport: i0__namespace });
219
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", 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: [{
220
212
  type: i0.Directive,
221
213
  args: [{
222
214
  selector: 'input[skyAutonumeric]',
223
- providers: [
224
- SKY_AUTONUMERIC_VALUE_ACCESSOR,
225
- SKY_AUTONUMERIC_VALIDATOR
226
- ]
215
+ providers: [SKY_AUTONUMERIC_VALUE_ACCESSOR, SKY_AUTONUMERIC_VALIDATOR],
227
216
  }]
228
217
  }], ctorParameters: function () { return [{ type: i0__namespace.ElementRef }, { type: SkyAutonumericOptionsProvider }, { type: i0__namespace.Renderer2 }, { type: i0__namespace.ChangeDetectorRef }]; }, propDecorators: { skyAutonumeric: [{
229
218
  type: i0.Input
@@ -237,29 +226,15 @@
237
226
  }
238
227
  return SkyAutonumericModule;
239
228
  }());
240
- SkyAutonumericModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: SkyAutonumericModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
241
- SkyAutonumericModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: SkyAutonumericModule, declarations: [SkyAutonumericDirective], imports: [common.CommonModule,
242
- forms.FormsModule,
243
- forms.ReactiveFormsModule], exports: [SkyAutonumericDirective] });
244
- SkyAutonumericModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: SkyAutonumericModule, imports: [[
245
- common.CommonModule,
246
- forms.FormsModule,
247
- forms.ReactiveFormsModule
248
- ]] });
249
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", 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: [{
250
233
  type: i0.NgModule,
251
234
  args: [{
252
- declarations: [
253
- SkyAutonumericDirective
254
- ],
255
- imports: [
256
- common.CommonModule,
257
- forms.FormsModule,
258
- forms.ReactiveFormsModule
259
- ],
260
- exports: [
261
- SkyAutonumericDirective
262
- ]
235
+ declarations: [SkyAutonumericDirective],
236
+ imports: [common.CommonModule, forms.FormsModule, forms.ReactiveFormsModule],
237
+ exports: [SkyAutonumericDirective],
263
238
  }]
264
239
  }] });
265
240