@bravura/ui 9.0.3 → 9.0.4

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/CHANGELOG.md CHANGED
@@ -1,8 +1,12 @@
1
1
  # Change history
2
2
 
3
+ ## <small>9.0.4 (2026-07-15)</small>
4
+
5
+ * fix(decimal-input): allow decimal input used as attribute ([0fc85fe](https://scm.bravurasolutions.net/projects/DIGI/repos/ui-components/commits/0fc85fe))
6
+
3
7
  ## <small>9.0.3 (2026-07-14)</small>
4
8
 
5
- * fix: update storybook ([98ce0d5](https://scm.bravurasolutions.net/projects/DIGI/repos/ui-components/commits/98ce0d5))
9
+ - fix: update storybook ([98ce0d5](https://scm.bravurasolutions.net/projects/DIGI/repos/ui-components/commits/98ce0d5))
6
10
 
7
11
  ## <small>9.0.2 (2026-07-13)</small>
8
12
 
@@ -1,11 +1,17 @@
1
- import { DecimalPipe, CommonModule } from '@angular/common';
2
1
  import * as i0 from '@angular/core';
3
- import { forwardRef, HostListener, HostBinding, Input, Self, Directive, NgModule } from '@angular/core';
2
+ import { input, forwardRef, HostListener, HostBinding, Self, Directive, NgModule } from '@angular/core';
3
+ import { DecimalPipe } from '@angular/common';
4
4
  import { NG_VALUE_ACCESSOR } from '@angular/forms';
5
5
  import { noop } from 'rxjs';
6
6
 
7
7
  /* tslint:disable:no-empty */
8
8
  const noop_consumer = (_) => { };
9
+ const optionalValue = (defaultValue) => (v) => {
10
+ if (v === '' || v === null || v === undefined || !Number.isFinite(v) || Number(v) < 0) {
11
+ return defaultValue;
12
+ }
13
+ return Number(v);
14
+ };
9
15
  /**
10
16
  * This directive will enhance an input element to format the numbers entered to a decimal amount.
11
17
  */
@@ -16,7 +22,7 @@ class DecimalInputDirective {
16
22
  /**
17
23
  * number of decimal places allowed
18
24
  */
19
- this.buiDecimalInput = 2;
25
+ this.buiDecimalInput = input(2, { ...(ngDevMode ? { debugName: "buiDecimalInput" } : /* istanbul ignore next */ {}), transform: optionalValue(2) });
20
26
  this.placeholder = '';
21
27
  this.autocomplete = 'off';
22
28
  this.type = 'number';
@@ -25,15 +31,14 @@ class DecimalInputDirective {
25
31
  this.onTouch = noop;
26
32
  }
27
33
  ngOnChanges() {
28
- this.buiDecimalInput = this.buiDecimalInput || 2;
29
34
  this.onInput();
30
35
  }
31
36
  onInput() {
32
37
  const value = this._el.nativeElement.value;
33
38
  const decimalPart = value.split('.')[1];
34
- if (decimalPart && decimalPart.length > this.buiDecimalInput) {
39
+ if (decimalPart && decimalPart.length > this.buiDecimalInput()) {
35
40
  const indexOfPeriod = value.indexOf('.');
36
- const newValue = value.substring(0, indexOfPeriod + this.buiDecimalInput + 1);
41
+ const newValue = value.substring(0, indexOfPeriod + this.buiDecimalInput() + 1);
37
42
  this._renderer.setProperty(this._el.nativeElement, 'value', newValue);
38
43
  }
39
44
  const resolvedValue = this._el.nativeElement.value;
@@ -70,17 +75,16 @@ class DecimalInputDirective {
70
75
  }
71
76
  const splitValues = value.split('.');
72
77
  let newValue = '';
73
- if (splitValues[1] && splitValues[1].length > this.buiDecimalInput) {
74
- newValue = value.substring(0, splitValues[0].length + 1 + this.buiDecimalInput);
78
+ if (splitValues[1] && splitValues[1].length > this.buiDecimalInput()) {
79
+ newValue = value.substring(0, splitValues[0].length + 1 + this.buiDecimalInput());
75
80
  }
76
81
  else {
77
- this.buiDecimalInput = this.buiDecimalInput < 0 ? 0 : this.buiDecimalInput;
78
- newValue = Number(value).toFixed(this.buiDecimalInput);
82
+ newValue = Number(value).toFixed(this.buiDecimalInput());
79
83
  }
80
84
  this._renderer.setProperty(this._el.nativeElement, 'value', newValue);
81
85
  }
82
86
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: DecimalInputDirective, deps: [{ token: i0.ElementRef, self: true }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive }); }
83
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: DecimalInputDirective, isStandalone: false, selector: "input[buiDecimalInput]", inputs: { buiDecimalInput: "buiDecimalInput" }, host: { listeners: { "input": "onInput()", "keypress": "onKeypress($event)", "blur": "onblur()" }, properties: { "placeholder": "this.placeholder", "autocomplete": "this.autocomplete", "type": "this.type", "attr.inputmode": "this.inputMode" } }, providers: [
87
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: DecimalInputDirective, isStandalone: true, selector: "input[buiDecimalInput]", inputs: { buiDecimalInput: { classPropertyName: "buiDecimalInput", publicName: "buiDecimalInput", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "input": "onInput()", "keypress": "onKeypress($event)", "blur": "onblur()" }, properties: { "placeholder": "this.placeholder", "autocomplete": "this.autocomplete", "type": "this.type", "attr.inputmode": "this.inputMode" } }, providers: [
84
88
  DecimalPipe,
85
89
  { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => DecimalInputDirective), multi: true }
86
90
  ], usesOnChanges: true, ngImport: i0 }); }
@@ -92,14 +96,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
92
96
  providers: [
93
97
  DecimalPipe,
94
98
  { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => DecimalInputDirective), multi: true }
95
- ],
96
- standalone: false
99
+ ]
97
100
  }]
98
101
  }], ctorParameters: () => [{ type: i0.ElementRef, decorators: [{
99
102
  type: Self
100
- }] }, { type: i0.Renderer2 }], propDecorators: { buiDecimalInput: [{
101
- type: Input
102
- }], placeholder: [{
103
+ }] }, { type: i0.Renderer2 }], propDecorators: { buiDecimalInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "buiDecimalInput", required: false }] }], placeholder: [{
103
104
  type: HostBinding,
104
105
  args: ['placeholder']
105
106
  }], autocomplete: [{
@@ -124,14 +125,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
124
125
 
125
126
  class DecimalInputModule {
126
127
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: DecimalInputModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
127
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "22.0.6", ngImport: i0, type: DecimalInputModule, declarations: [DecimalInputDirective], imports: [CommonModule], exports: [DecimalInputDirective] }); }
128
- static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: DecimalInputModule, imports: [CommonModule] }); }
128
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "22.0.6", ngImport: i0, type: DecimalInputModule, imports: [DecimalInputDirective], exports: [DecimalInputDirective] }); }
129
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: DecimalInputModule }); }
129
130
  }
130
131
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: DecimalInputModule, decorators: [{
131
132
  type: NgModule,
132
133
  args: [{
133
- declarations: [DecimalInputDirective],
134
- imports: [CommonModule],
134
+ imports: [DecimalInputDirective],
135
135
  exports: [DecimalInputDirective]
136
136
  }]
137
137
  }] });
@@ -1 +1 @@
1
- {"version":3,"file":"bravura-ui-decimal-input.mjs","sources":["../../../projects/ui/decimal-input/decimal-input.directive.ts","../../../projects/ui/decimal-input/decimal-input.module.ts","../../../projects/ui/decimal-input/bravura-ui-decimal-input.ts"],"sourcesContent":["import { DecimalPipe } from '@angular/common';\r\nimport {\r\n\tDirective,\r\n\tElementRef,\r\n\tforwardRef,\r\n\tHostBinding,\r\n\tHostListener,\r\n\tInput,\r\n\tOnChanges,\r\n\tRenderer2,\r\n\tSelf\r\n} from '@angular/core';\r\nimport { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';\r\nimport { noop } from 'rxjs';\r\n\r\n/* tslint:disable:no-empty */\r\nexport const noop_consumer = (_: any) => {};\r\n\r\n/**\r\n * This directive will enhance an input element to format the numbers entered to a decimal amount.\r\n */\r\n@Directive({\r\n\tselector: 'input[buiDecimalInput]',\r\n\tproviders: [\r\n\t\tDecimalPipe,\r\n\t\t{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => DecimalInputDirective), multi: true }\r\n\t],\r\n\tstandalone: false\r\n})\r\nexport class DecimalInputDirective implements OnChanges, ControlValueAccessor {\r\n\t/**\r\n\t * number of decimal places allowed\r\n\t */\r\n\t@Input()\r\n\tbuiDecimalInput: number = 2;\r\n\r\n\t@HostBinding('placeholder')\r\n\tplaceholder: string = '';\r\n\r\n\t@HostBinding('autocomplete')\r\n\tautocomplete = 'off';\r\n\r\n\t@HostBinding('type')\r\n\ttype = 'number';\r\n\r\n\t@HostBinding('attr.inputmode')\r\n\tinputMode = 'decimal';\r\n\r\n\tprivate change = noop_consumer;\r\n\tprivate onTouch = noop;\r\n\r\n\tconstructor(\r\n\t\t@Self() private _el: ElementRef<HTMLInputElement>,\r\n\t\tprivate _renderer: Renderer2\r\n\t) {}\r\n\r\n\tngOnChanges(): void {\r\n\t\tthis.buiDecimalInput = this.buiDecimalInput || 2;\r\n\t\tthis.onInput();\r\n\t}\r\n\r\n\t@HostListener('input')\r\n\tonInput() {\r\n\t\tconst value = this._el.nativeElement.value;\r\n\r\n\t\tconst decimalPart = value.split('.')[1];\r\n\r\n\t\tif (decimalPart && decimalPart.length > this.buiDecimalInput) {\r\n\t\t\tconst indexOfPeriod = value.indexOf('.');\r\n\t\t\tconst newValue = value.substring(0, indexOfPeriod + this.buiDecimalInput + 1);\r\n\t\t\tthis._renderer.setProperty(this._el.nativeElement, 'value', newValue);\r\n\t\t}\r\n\t\tconst resolvedValue = this._el.nativeElement.value;\r\n\t\tthis.change(\r\n\t\t\tresolvedValue === '' || resolvedValue === null || resolvedValue === undefined ? null : Number(resolvedValue)\r\n\t\t);\r\n\t}\r\n\r\n\t@HostListener('keypress', ['$event'])\r\n\tonKeypress(evt: KeyboardEvent) {\r\n\t\tconst target = evt.target as HTMLInputElement;\r\n\t\tconst value = target.value;\r\n\t\tconst isSpace = evt.key === ' ';\r\n\r\n\t\tif (\r\n\t\t\tisSpace ||\r\n\t\t\t(!['.', '-'].includes(evt.key) && isNaN(Number(evt.key))) ||\r\n\t\t\t(evt.key === '.' && value.indexOf('.') > 0)\r\n\t\t) {\r\n\t\t\tevt.preventDefault();\r\n\t\t}\r\n\t}\r\n\r\n\t@HostListener('blur')\r\n\tonblur() {\r\n\t\tthis.onTouch();\r\n\t\tthis._resetDecimalPlaces();\r\n\t}\r\n\r\n\twriteValue(value: any) {\r\n\t\tthis._renderer.setProperty(this._el.nativeElement, 'value', value);\r\n\t\tthis._resetDecimalPlaces();\r\n\t}\r\n\r\n\tregisterOnChange(fn: any) {\r\n\t\tthis.change = fn;\r\n\t}\r\n\r\n\tregisterOnTouched(fn: any) {\r\n\t\tthis.onTouch = fn;\r\n\t}\r\n\r\n\tprivate _resetDecimalPlaces() {\r\n\t\tconst value = this._el.nativeElement.value;\r\n\t\tif (value === '' || value === null || value === undefined) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tconst splitValues = value.split('.');\r\n\t\tlet newValue = '';\r\n\t\tif (splitValues[1] && splitValues[1].length > this.buiDecimalInput) {\r\n\t\t\tnewValue = value.substring(0, splitValues[0].length + 1 + this.buiDecimalInput);\r\n\t\t} else {\r\n\t\t\tthis.buiDecimalInput = this.buiDecimalInput < 0 ? 0 : this.buiDecimalInput;\r\n\t\t\tnewValue = Number(value).toFixed(this.buiDecimalInput);\r\n\t\t}\r\n\t\tthis._renderer.setProperty(this._el.nativeElement, 'value', newValue);\r\n\t}\r\n}\r\n","import { CommonModule } from '@angular/common';\r\nimport { NgModule } from '@angular/core';\r\nimport { DecimalInputDirective } from './decimal-input.directive';\r\n\r\n@NgModule({\r\n\tdeclarations: [DecimalInputDirective],\r\n\timports: [CommonModule],\r\n\texports: [DecimalInputDirective]\r\n})\r\nexport class DecimalInputModule {}\r\nexport { DecimalInputDirective };\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;AAeA;AACO,MAAM,aAAa,GAAG,CAAC,CAAM,KAAI,EAAE,CAAC;AAE3C;;AAEG;MASU,qBAAqB,CAAA;IAsBjC,WAAA,CACiB,GAAiC,EACzC,SAAoB,EAAA;QADZ,IAAA,CAAA,GAAG,GAAH,GAAG;QACX,IAAA,CAAA,SAAS,GAAT,SAAS;AAvBlB;;AAEG;QAEH,IAAA,CAAA,eAAe,GAAW,CAAC;QAG3B,IAAA,CAAA,WAAW,GAAW,EAAE;QAGxB,IAAA,CAAA,YAAY,GAAG,KAAK;QAGpB,IAAA,CAAA,IAAI,GAAG,QAAQ;QAGf,IAAA,CAAA,SAAS,GAAG,SAAS;QAEb,IAAA,CAAA,MAAM,GAAG,aAAa;QACtB,IAAA,CAAA,OAAO,GAAG,IAAI;IAKnB;IAEH,WAAW,GAAA;QACV,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,IAAI,CAAC;QAChD,IAAI,CAAC,OAAO,EAAE;IACf;IAGA,OAAO,GAAA;QACN,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,KAAK;QAE1C,MAAM,WAAW,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAEvC,IAAI,WAAW,IAAI,WAAW,CAAC,MAAM,GAAG,IAAI,CAAC,eAAe,EAAE;YAC7D,MAAM,aAAa,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;AACxC,YAAA,MAAM,QAAQ,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,aAAa,GAAG,IAAI,CAAC,eAAe,GAAG,CAAC,CAAC;AAC7E,YAAA,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,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eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;AAAlB,IAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,kBAAkB,EAAA,YAAA,EAAA,CAJf,qBAAqB,CAAA,EAAA,OAAA,EAAA,CAC1B,YAAY,aACZ,qBAAqB,CAAA,EAAA,CAAA,CAAA;AAEnB,IAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,kBAAkB,YAHpB,YAAY,CAAA,EAAA,CAAA,CAAA;;2FAGV,kBAAkB,EAAA,UAAA,EAAA,CAAA;kBAL9B,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;oBACT,YAAY,EAAE,CAAC,qBAAqB,CAAC;oBACrC,OAAO,EAAE,CAAC,YAAY,CAAC;oBACvB,OAAO,EAAE,CAAC,qBAAqB;AAC/B,iBAAA;;;ACRD;;AAEG;;;;"}
1
+ {"version":3,"file":"bravura-ui-decimal-input.mjs","sources":["../../../projects/ui/decimal-input/decimal-input.directive.ts","../../../projects/ui/decimal-input/decimal-input.module.ts","../../../projects/ui/decimal-input/bravura-ui-decimal-input.ts"],"sourcesContent":["import { DecimalPipe } from '@angular/common';\nimport {\n\tDirective,\n\tElementRef,\n\tforwardRef,\n\tHostBinding,\n\tHostListener,\n\tinput,\n\tOnChanges,\n\tRenderer2,\n\tSelf\n} from '@angular/core';\nimport { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';\nimport { noop } from 'rxjs';\n\n/* tslint:disable:no-empty */\nexport const noop_consumer = (_: any) => {};\n\nconst optionalValue = (defaultValue: number) => (v: unknown) => {\n\tif (v === '' || v === null || v === undefined || !Number.isFinite(v) || Number(v) < 0) {\n\t\treturn defaultValue;\n\t}\n\treturn Number(v);\n};\n\n/**\n * This directive will enhance an input element to format the numbers entered to a decimal amount.\n */\n@Directive({\n\tselector: 'input[buiDecimalInput]',\n\tproviders: [\n\t\tDecimalPipe,\n\t\t{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => DecimalInputDirective), multi: true }\n\t]\n})\nexport class DecimalInputDirective implements OnChanges, ControlValueAccessor {\n\t/**\n\t * number of decimal places allowed\n\t */\n\n\tbuiDecimalInput = input(2, {\n\t\ttransform: optionalValue(2)\n\t});\n\n\t@HostBinding('placeholder')\n\tplaceholder: string = '';\n\n\t@HostBinding('autocomplete')\n\tautocomplete = 'off';\n\n\t@HostBinding('type')\n\ttype = 'number';\n\n\t@HostBinding('attr.inputmode')\n\tinputMode = 'decimal';\n\n\tprivate change = noop_consumer;\n\tprivate onTouch = noop;\n\n\tconstructor(\n\t\t@Self() private _el: ElementRef<HTMLInputElement>,\n\t\tprivate _renderer: Renderer2\n\t) {}\n\n\tngOnChanges(): void {\n\t\tthis.onInput();\n\t}\n\n\t@HostListener('input')\n\tonInput() {\n\t\tconst value = this._el.nativeElement.value;\n\n\t\tconst decimalPart = value.split('.')[1];\n\n\t\tif (decimalPart && decimalPart.length > this.buiDecimalInput()) {\n\t\t\tconst indexOfPeriod = value.indexOf('.');\n\t\t\tconst newValue = value.substring(0, indexOfPeriod + this.buiDecimalInput() + 1);\n\t\t\tthis._renderer.setProperty(this._el.nativeElement, 'value', newValue);\n\t\t}\n\t\tconst resolvedValue = this._el.nativeElement.value;\n\t\tthis.change(\n\t\t\tresolvedValue === '' || resolvedValue === null || resolvedValue === undefined ? null : Number(resolvedValue)\n\t\t);\n\t}\n\n\t@HostListener('keypress', ['$event'])\n\tonKeypress(evt: KeyboardEvent) {\n\t\tconst target = evt.target as HTMLInputElement;\n\t\tconst value = target.value;\n\t\tconst isSpace = evt.key === ' ';\n\n\t\tif (\n\t\t\tisSpace ||\n\t\t\t(!['.', '-'].includes(evt.key) && isNaN(Number(evt.key))) ||\n\t\t\t(evt.key === '.' && value.indexOf('.') > 0)\n\t\t) {\n\t\t\tevt.preventDefault();\n\t\t}\n\t}\n\n\t@HostListener('blur')\n\tonblur() {\n\t\tthis.onTouch();\n\t\tthis._resetDecimalPlaces();\n\t}\n\n\twriteValue(value: any) {\n\t\tthis._renderer.setProperty(this._el.nativeElement, 'value', value);\n\t\tthis._resetDecimalPlaces();\n\t}\n\n\tregisterOnChange(fn: any) {\n\t\tthis.change = fn;\n\t}\n\n\tregisterOnTouched(fn: any) {\n\t\tthis.onTouch = fn;\n\t}\n\n\tprivate _resetDecimalPlaces() {\n\t\tconst value = this._el.nativeElement.value;\n\t\tif (value === '' || value === null || value === undefined) {\n\t\t\treturn;\n\t\t}\n\t\tconst splitValues = value.split('.');\n\t\tlet newValue = '';\n\t\tif (splitValues[1] && splitValues[1].length > this.buiDecimalInput()) {\n\t\t\tnewValue = value.substring(0, splitValues[0].length + 1 + this.buiDecimalInput());\n\t\t} else {\n\t\t\tnewValue = Number(value).toFixed(this.buiDecimalInput());\n\t\t}\n\t\tthis._renderer.setProperty(this._el.nativeElement, 'value', newValue);\n\t}\n}\n","import { NgModule } from '@angular/core';\nimport { DecimalInputDirective } from './decimal-input.directive';\n\n@NgModule({\n\timports: [DecimalInputDirective],\n\texports: [DecimalInputDirective]\n})\nexport class DecimalInputModule {}\nexport { DecimalInputDirective };\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;AAeA;AACO,MAAM,aAAa,GAAG,CAAC,CAAM,KAAI,EAAE,CAAC;AAE3C,MAAM,aAAa,GAAG,CAAC,YAAoB,KAAK,CAAC,CAAU,KAAI;IAC9D,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC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,CAAA,CAAA;+GAAlB,kBAAkB,EAAA,OAAA,EAAA,CAHpB,qBAAqB,CAAA,EAAA,OAAA,EAAA,CACrB,qBAAqB,CAAA,EAAA,CAAA,CAAA;+GAEnB,kBAAkB,EAAA,CAAA,CAAA;;2FAAlB,kBAAkB,EAAA,UAAA,EAAA,CAAA;kBAJ9B,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;oBACT,OAAO,EAAE,CAAC,qBAAqB,CAAC;oBAChC,OAAO,EAAE,CAAC,qBAAqB;AAC/B,iBAAA;;;ACND;;AAEG;;;;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bravura/ui",
3
3
  "description": "Bravura UI Components for Angular applications",
4
- "version": "9.0.3",
4
+ "version": "9.0.4",
5
5
  "keywords": [
6
6
  "Angular",
7
7
  "Angular Material",
@@ -1,7 +1,6 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { OnChanges, ElementRef, Renderer2 } from '@angular/core';
3
3
  import { ControlValueAccessor } from '@angular/forms';
4
- import * as i2 from '@angular/common';
5
4
 
6
5
  /**
7
6
  * This directive will enhance an input element to format the numbers entered to a decimal amount.
@@ -12,7 +11,7 @@ declare class DecimalInputDirective implements OnChanges, ControlValueAccessor {
12
11
  /**
13
12
  * number of decimal places allowed
14
13
  */
15
- buiDecimalInput: number;
14
+ buiDecimalInput: i0.InputSignalWithTransform<number, unknown>;
16
15
  placeholder: string;
17
16
  autocomplete: string;
18
17
  type: string;
@@ -29,12 +28,12 @@ declare class DecimalInputDirective implements OnChanges, ControlValueAccessor {
29
28
  registerOnTouched(fn: any): void;
30
29
  private _resetDecimalPlaces;
31
30
  static ɵfac: i0.ɵɵFactoryDeclaration<DecimalInputDirective, [{ self: true; }, null]>;
32
- static ɵdir: i0.ɵɵDirectiveDeclaration<DecimalInputDirective, "input[buiDecimalInput]", never, { "buiDecimalInput": { "alias": "buiDecimalInput"; "required": false; }; }, {}, never, never, false, never>;
31
+ static ɵdir: i0.ɵɵDirectiveDeclaration<DecimalInputDirective, "input[buiDecimalInput]", never, { "buiDecimalInput": { "alias": "buiDecimalInput"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
33
32
  }
34
33
 
35
34
  declare class DecimalInputModule {
36
35
  static ɵfac: i0.ɵɵFactoryDeclaration<DecimalInputModule, never>;
37
- static ɵmod: i0.ɵɵNgModuleDeclaration<DecimalInputModule, [typeof DecimalInputDirective], [typeof i2.CommonModule], [typeof DecimalInputDirective]>;
36
+ static ɵmod: i0.ɵɵNgModuleDeclaration<DecimalInputModule, never, [typeof DecimalInputDirective], [typeof DecimalInputDirective]>;
38
37
  static ɵinj: i0.ɵɵInjectorDeclaration<DecimalInputModule>;
39
38
  }
40
39