@bravura/ui 2.0.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/esm2020/currency-input/currency-input.directive.mjs +2 -2
- package/esm2020/decimal-input/decimal-input.directive.mjs +4 -2
- package/esm2020/file-upload/file-upload.component.mjs +49 -5
- package/esm2020/panel/bravura-ui-panel.mjs +5 -0
- package/esm2020/panel/panel.component.mjs +64 -0
- package/esm2020/panel/panel.module.mjs +20 -0
- package/esm2020/panel/public-api.mjs +2 -0
- package/fesm2015/bravura-ui-currency-input.mjs +1 -1
- package/fesm2015/bravura-ui-currency-input.mjs.map +1 -1
- package/fesm2015/bravura-ui-decimal-input.mjs +3 -1
- package/fesm2015/bravura-ui-decimal-input.mjs.map +1 -1
- package/fesm2015/bravura-ui-file-upload.mjs +48 -4
- package/fesm2015/bravura-ui-file-upload.mjs.map +1 -1
- package/fesm2015/bravura-ui-panel.mjs +87 -0
- package/fesm2015/bravura-ui-panel.mjs.map +1 -0
- package/fesm2020/bravura-ui-currency-input.mjs +1 -1
- package/fesm2020/bravura-ui-currency-input.mjs.map +1 -1
- package/fesm2020/bravura-ui-decimal-input.mjs +3 -1
- package/fesm2020/bravura-ui-decimal-input.mjs.map +1 -1
- package/fesm2020/bravura-ui-file-upload.mjs +48 -4
- package/fesm2020/bravura-ui-file-upload.mjs.map +1 -1
- package/fesm2020/bravura-ui-panel.mjs +87 -0
- package/fesm2020/bravura-ui-panel.mjs.map +1 -0
- package/file-upload/file-upload.component.d.ts +11 -1
- package/package.json +9 -1
- package/panel/index.d.ts +5 -0
- package/panel/panel.component.d.ts +46 -0
- package/panel/panel.module.d.ts +11 -0
- package/panel/public-api.d.ts +1 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
import * as i1 from "@angular/material/card";
|
|
4
|
+
/**
|
|
5
|
+
* A `bui-panel` consists of a `mat-card` and a tinted backdrop.
|
|
6
|
+
*
|
|
7
|
+
* Unlike `mat-card`, `bui-panel` has a flat appearance by default and a transparent background.
|
|
8
|
+
* The backdrop is nearly transparent, blending the theme palette `color`
|
|
9
|
+
* and the effective background color of the DOM ancestors.
|
|
10
|
+
*
|
|
11
|
+
* `bui-panel` supports all the content child directives of `mat-card`.
|
|
12
|
+
*
|
|
13
|
+
*/
|
|
14
|
+
export class PanelComponent {
|
|
15
|
+
constructor(_cd) {
|
|
16
|
+
this._cd = _cd;
|
|
17
|
+
this._color = 'primary';
|
|
18
|
+
this._appearance = 'flat';
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* This property defines the background (shaded) and border colors of the panel
|
|
22
|
+
*/
|
|
23
|
+
get color() {
|
|
24
|
+
return this._color;
|
|
25
|
+
}
|
|
26
|
+
set color(value) {
|
|
27
|
+
this._color = value;
|
|
28
|
+
this._cd.markForCheck();
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* In contrast to using a `mat-card` alone, a `bui-panel` does not have a elevated appearance by default.
|
|
32
|
+
*
|
|
33
|
+
* This property can change the default appearance to
|
|
34
|
+
*
|
|
35
|
+
* * `raised` - the original `mat-card` default
|
|
36
|
+
* * `outline` - a `mat-card` with borders
|
|
37
|
+
* * `flat` - no border or elevation
|
|
38
|
+
*/
|
|
39
|
+
get appearance() {
|
|
40
|
+
return this._appearance;
|
|
41
|
+
}
|
|
42
|
+
set appearance(value) {
|
|
43
|
+
this._appearance = value;
|
|
44
|
+
this._cd.markForCheck();
|
|
45
|
+
}
|
|
46
|
+
ngOnInit() { }
|
|
47
|
+
}
|
|
48
|
+
PanelComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.3", ngImport: i0, type: PanelComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
49
|
+
PanelComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.1.3", type: PanelComponent, selector: "bui-panel", inputs: { backdropClass: "backdropClass", cardClass: "cardClass", color: "color", appearance: "appearance" }, host: { classAttribute: "bui-panel bui-host" }, ngImport: i0, template: "<div class=\"bui-panel-backdrop {{ backdropClass }} bui-bg-{{ color || 'none' }}\"></div>\n<mat-card\n\tclass=\"bui-border-{{ color || 'none' }} {{ cardClass }} {{\n\t\tappearance === 'flat' ? 'mat-elevation-z' : appearance === 'outlined' ? 'mat-elevation-z bui-panel-border' : ''\n\t}}\"\n>\n\t<ng-content></ng-content>\n</mat-card>\n", styles: [":host{position:relative}:host .bui-panel-backdrop{position:absolute;top:0;left:0;right:0;bottom:0;border-radius:4px;opacity:.1}:host .mat-card{background-color:transparent}:host .bui-panel-border{border-width:1px;border-style:solid}\n"], dependencies: [{ kind: "component", type: i1.MatCard, selector: "mat-card", exportAs: ["matCard"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
50
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.3", ngImport: i0, type: PanelComponent, decorators: [{
|
|
51
|
+
type: Component,
|
|
52
|
+
args: [{ selector: 'bui-panel', host: {
|
|
53
|
+
class: 'bui-panel bui-host'
|
|
54
|
+
}, changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"bui-panel-backdrop {{ backdropClass }} bui-bg-{{ color || 'none' }}\"></div>\n<mat-card\n\tclass=\"bui-border-{{ color || 'none' }} {{ cardClass }} {{\n\t\tappearance === 'flat' ? 'mat-elevation-z' : appearance === 'outlined' ? 'mat-elevation-z bui-panel-border' : ''\n\t}}\"\n>\n\t<ng-content></ng-content>\n</mat-card>\n", styles: [":host{position:relative}:host .bui-panel-backdrop{position:absolute;top:0;left:0;right:0;bottom:0;border-radius:4px;opacity:.1}:host .mat-card{background-color:transparent}:host .bui-panel-border{border-width:1px;border-style:solid}\n"] }]
|
|
55
|
+
}], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }]; }, propDecorators: { backdropClass: [{
|
|
56
|
+
type: Input
|
|
57
|
+
}], cardClass: [{
|
|
58
|
+
type: Input
|
|
59
|
+
}], color: [{
|
|
60
|
+
type: Input
|
|
61
|
+
}], appearance: [{
|
|
62
|
+
type: Input
|
|
63
|
+
}] } });
|
|
64
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGFuZWwuY29tcG9uZW50LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vcHJvamVjdHMvdWkvcGFuZWwvcGFuZWwuY29tcG9uZW50LnRzIiwiLi4vLi4vLi4vLi4vcHJvamVjdHMvdWkvcGFuZWwvcGFuZWwuY29tcG9uZW50Lmh0bWwiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLHVCQUF1QixFQUFxQixTQUFTLEVBQUUsS0FBSyxFQUFVLE1BQU0sZUFBZSxDQUFDOzs7QUFHckc7Ozs7Ozs7OztHQVNHO0FBVUgsTUFBTSxPQUFPLGNBQWM7SUErQzFCLFlBQW9CLEdBQXNCO1FBQXRCLFFBQUcsR0FBSCxHQUFHLENBQW1CO1FBSmxDLFdBQU0sR0FBaUIsU0FBUyxDQUFDO1FBRWpDLGdCQUFXLEdBQW1DLE1BQU0sQ0FBQztJQUVoQixDQUFDO0lBbEM5Qzs7T0FFRztJQUNILElBQ0ksS0FBSztRQUNSLE9BQU8sSUFBSSxDQUFDLE1BQU0sQ0FBQztJQUNwQixDQUFDO0lBQ0QsSUFBSSxLQUFLLENBQUMsS0FBbUI7UUFDNUIsSUFBSSxDQUFDLE1BQU0sR0FBRyxLQUFLLENBQUM7UUFDcEIsSUFBSSxDQUFDLEdBQUcsQ0FBQyxZQUFZLEVBQUUsQ0FBQztJQUN6QixDQUFDO0lBRUQ7Ozs7Ozs7O09BUUc7SUFDSCxJQUNJLFVBQVU7UUFDY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3JhaXNlZCcgfCAnZmxhdCcgPSAnZmxhdCc7XG5cblx0Y29uc3RydWN0b3IocHJpdmF0ZSBfY2Q6IENoYW5nZURldGVjdG9yUmVmKSB7fVxuXG5cdG5nT25Jbml0KCk6IHZvaWQge31cbn1cbiIsIjxkaXYgY2xhc3M9XCJidWktcGFuZWwtYmFja2Ryb3Age3sgYmFja2Ryb3BDbGFzcyB9fSBidWktYmcte3sgY29sb3IgfHwgJ25vbmUnIH19XCI+PC9kaXY+XG48bWF0LWNhcmRcblx0Y2xhc3M9XCJidWktYm9yZGVyLXt7IGNvbG9yIHx8ICdub25lJyB9fSB7eyBjYXJkQ2xhc3MgfX0ge3tcblx0XHRhcHBlYXJhbmNlID09PSAnZmxhdCcgPyAnbWF0LWVsZXZhdGlvbi16JyA6IGFwcGVhcmFuY2UgPT09ICdvdXRsaW5lZCcgPyAnbWF0LWVsZXZhdGlvbi16IGJ1aS1wYW5lbC1ib3JkZXInIDogJydcblx0fX1cIlxuPlxuXHQ8bmctY29udGVudD48L25nLWNvbnRlbnQ+XG48L21hdC1jYXJkPlxuIl19
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { NgModule } from '@angular/core';
|
|
2
|
+
import { CommonModule } from '@angular/common';
|
|
3
|
+
import { PanelComponent } from './panel.component';
|
|
4
|
+
import { MatCardModule } from '@angular/material/card';
|
|
5
|
+
import * as i0 from "@angular/core";
|
|
6
|
+
export class PanelModule {
|
|
7
|
+
}
|
|
8
|
+
PanelModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.3", ngImport: i0, type: PanelModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
9
|
+
PanelModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.1.3", ngImport: i0, type: PanelModule, declarations: [PanelComponent], imports: [CommonModule, MatCardModule], exports: [MatCardModule, PanelComponent] });
|
|
10
|
+
PanelModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.1.3", ngImport: i0, type: PanelModule, imports: [CommonModule, MatCardModule, MatCardModule] });
|
|
11
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.3", ngImport: i0, type: PanelModule, decorators: [{
|
|
12
|
+
type: NgModule,
|
|
13
|
+
args: [{
|
|
14
|
+
declarations: [PanelComponent],
|
|
15
|
+
imports: [CommonModule, MatCardModule],
|
|
16
|
+
exports: [MatCardModule, PanelComponent]
|
|
17
|
+
}]
|
|
18
|
+
}] });
|
|
19
|
+
export { PanelComponent };
|
|
20
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGFuZWwubW9kdWxlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vcHJvamVjdHMvdWkvcGFuZWwvcGFuZWwubW9kdWxlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxRQUFRLEVBQUUsTUFBTSxlQUFlLENBQUM7QUFDekMsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLGlCQUFpQixDQUFDO0FBQy9DLE9BQU8sRUFBRSxjQUFjLEVBQUUsTUFBTSxtQkFBbUIsQ0FBQztBQUNuRCxPQUFPLEVBQUUsYUFBYSxFQUFFLE1BQU0sd0JBQXdCLENBQUM7O0FBT3ZELE1BQU0sT0FBTyxXQUFXOzt3R0FBWCxXQUFXO3lHQUFYLFdBQVcsaUJBSlIsY0FBYyxhQUNuQixZQUFZLEVBQUUsYUFBYSxhQUMzQixhQUFhLEVBQUUsY0FBYzt5R0FFM0IsV0FBVyxZQUhiLFlBQVksRUFBRSxhQUFhLEVBQzNCLGFBQWE7MkZBRVgsV0FBVztrQkFMdkIsUUFBUTttQkFBQztvQkFDVCxZQUFZLEVBQUUsQ0FBQyxjQUFjLENBQUM7b0JBQzlCLE9BQU8sRUFBRSxDQUFDLFlBQVksR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,7 +69,7 @@ class CurrencyInputDirective {
|
|
|
69
69
|
writeValue(value) {
|
|
70
70
|
value = this._decimalPipe.transform(value);
|
|
71
71
|
this._renderer.setProperty(this._el.nativeElement, 'value', value);
|
|
72
|
-
this._formatCurrency(this._el,
|
|
72
|
+
this._formatCurrency(this._el, true, false);
|
|
73
73
|
}
|
|
74
74
|
registerOnChange(fn) {
|
|
75
75
|
this.change = fn;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bravura-ui-currency-input.mjs","sources":["../../../projects/ui/currency-input/currency-input.directive.ts","../../../projects/ui/currency-input/currency-input.module.ts","../../../projects/ui/currency-input/bravura-ui-currency-input.ts"],"sourcesContent":["import { DecimalPipe, getCurrencySymbol } from '@angular/common';\nimport {\n\tDEFAULT_CURRENCY_CODE,\n\tDirective,\n\tElementRef,\n\tforwardRef,\n\tHostBinding,\n\tHostListener,\n\tInject,\n\tInput,\n\tLOCALE_ID,\n\tOnChanges,\n\tOnInit,\n\tOptional,\n\tRenderer2,\n\tSelf,\n\tɵfindLocaleData\n} from '@angular/core';\nimport { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';\nimport { MatFormField, MAT_FORM_FIELD } from '@angular/material/form-field';\nimport { MatInput } from '@angular/material/input';\nimport { noop } from 'rxjs';\n\n/* tslint:disable:no-empty */\nexport const noop_consumer = (_: any) => {};\n\n/**\n * This directive will enhance an input element to format the numbers entered to a currency amount.\n */\n@Directive({\n\tselector: 'input[buiCurrencyInput],input[currencyCode],input[data-type=currency]',\n\tproviders: [{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => CurrencyInputDirective), multi: true }]\n})\nexport class CurrencyInputDirective implements OnInit, OnChanges, ControlValueAccessor {\n\t/**\n\t * true to allow negative input, otherwise false\n\t * Default to false.\n\t */\n\t@Input()\n\tallowNegative: boolean = false;\n\n\t/**\n\t * Provide the currency code to format the entered amount.\n\t * Uses angular token DEFAULT_CURRENCY_CODE by default.\n\t */\n\t@Input()\n\tcurrencyCode: string = '';\n\n\t/**\n\t * true if no decimal digits allowed, otherwise false.\n\t * Default to false.\n\t */\n\t@Input()\n\tbaseUnitOnly = false;\n\n\t/**\n\t * The format the of the amount either in wide or narrow.\n\t */\n\t@Input()\n\tformat: 'narrow' | 'wide' = 'wide';\n\n\t@HostBinding('placeholder')\n\tprivate placeholder: string = '';\n\n\t@HostBinding('autocomplete')\n\tprivate autocomplete = 'off';\n\n\t@HostBinding('type')\n\tprivate type = 'text';\n\n\t@HostBinding('attr.inputmode')\n\tprivate inputMode = 'decimal';\n\n\tprivate change = noop_consumer;\n\tprivate onTouch = noop;\n\tprivate _safari: boolean;\n\tprivate _symbol: string = '$';\n\tprivate _decimalPipe!: DecimalPipe;\n\n\tprivate _ds = '.'; // decimal separator\n\tprivate _trailing = false;\n\n\tconstructor(\n\t\t@Self() private _el: ElementRef<HTMLInputElement>,\n\t\tprivate _renderer: Renderer2,\n\t\t@Inject(LOCALE_ID) private _locale: string,\n\t\t@Inject(DEFAULT_CURRENCY_CODE) private _defaultCurrencyCode: string,\n\t\t@Optional() @Inject(MAT_FORM_FIELD) private _field?: MatFormField\n\t) {\n\t\tconst userAgent = navigator.userAgent;\n\t\tthis._safari = !userAgent.match(/Firefox/i) && !userAgent.match(/Chrome/i) && !!userAgent.match(/safari/i);\n\t\tthis._currencyUpdated();\n\t}\n\n\tngOnInit() {}\n\n\tngOnChanges(): void {\n\t\tthis._currencyUpdated();\n\t\tthis.onInput();\n\t}\n\n\t@HostListener('input')\n\tonInput() {\n\t\tthis._formatCurrency(this._el, false, true);\n\t}\n\n\t@HostListener('focus')\n\tonFocus() {\n\t\tthis._formatCurrency(this._el, false, true);\n\t}\n\n\t@HostListener('blur')\n\tonblur() {\n\t\tthis.onTouch();\n\t\tthis._formatCurrency(this._el, true, false);\n\t}\n\n\twriteValue(value: any) {\n\t\tvalue = this._decimalPipe.transform(value);\n\t\tthis._renderer.setProperty(this._el.nativeElement, 'value', value);\n\t\tthis._formatCurrency(this._el, false, false);\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 _updatePlaceholder() {\n\t\tthis.placeholder = this.placeholder || this._0Text;\n\t\tif (this._field?._control instanceof MatInput) {\n\t\t\tthis._field._control.placeholder = this.placeholder;\n\t\t}\n\t}\n\n\tprivate _currencyUpdated() {\n\t\tthis.currencyCode = this.currencyCode || this._defaultCurrencyCode;\n\t\tthis._symbol = getCurrencySymbol(this.currencyCode, this.format, this._locale) || '$';\n\t\tconst localeData = ɵfindLocaleData(this._locale);\n\t\tthis._ds = localeData[13][0];\n\t\tthis._decimalPipe = new DecimalPipe(this._locale);\n\t\tconst curFormat: string = localeData[14][2];\n\t\tthis._trailing = curFormat.indexOf('¤') > 0;\n\t\tthis._updatePlaceholder();\n\t}\n\n\tprivate _formatCurrency(input: ElementRef<HTMLInputElement>, blur: boolean, focus: boolean) {\n\t\t// appends $ to value, validates decimal side\n\t\t// and puts cursor back in right position.\n\t\t// get input value\n\t\tlet input_val = input.nativeElement.value;\n\n\t\t// don't validate empty input\n\t\tif (input_val === '') {\n\t\t\tthis.change(null);\n\t\t\treturn;\n\t\t}\n\n\t\tconst minus = this.allowNegative ? '-' : '';\n\n\t\t// remove non digit values except currency symbol, decimal separator and hypen\n\t\tconst reg = new RegExp(`[^0-9${minus}${this._symbol}${this._ds}]`, 'g');\n\n\t\tlet sanitiseValue = input_val.replace(reg, '');\n\n\t\tif (sanitiseValue === '' || sanitiseValue === this._symbol) {\n\t\t\tthis.change(null);\n\t\t\tthis._renderer.setProperty(input.nativeElement, 'value', '');\n\t\t\treturn;\n\t\t} else if (\n\t\t\t(this.allowNegative && sanitiseValue === `-${this._symbol}`) ||\n\t\t\tsanitiseValue === '-' ||\n\t\t\tsanitiseValue === '--'\n\t\t) {\n\t\t\tthis.change(null);\n\t\t\tthis._renderer.setProperty(input.nativeElement, 'value', '-');\n\t\t\treturn;\n\t\t}\n\n\t\tconst negative = this.allowNegative && input_val.indexOf('-') >= 0;\n\n\t\t// original length\n\t\tconst original_len = input_val.length;\n\n\t\t// initial caret position\n\t\tlet caret_pos = input.nativeElement.selectionStart;\n\n\t\tinput_val = input_val.replace(RegExp(`[^0-9${minus}${this._ds}]`, 'g'), '').replace(/^\\.\\./, '');\n\t\t// check for decimal\n\t\tif (input_val.indexOf(this._ds) >= 0) {\n\t\t\t// get position of first decimal\n\t\t\t// this prevents multiple decimals from\n\t\t\t// being entered\n\t\t\tlet decimal_pos = input_val.indexOf(this._ds);\n\n\t\t\t// split number by decimal point\n\t\t\tlet left_side = input_val.substring(0, decimal_pos);\n\t\t\tlet right_side = input_val.substring(decimal_pos);\n\n\t\t\t// add commas to left side of number\n\t\t\tleft_side = this._formatNumber(left_side, blur) || '';\n\n\t\t\t// no value append a zero for decimal values\n\t\t\tif (!left_side.length) {\n\t\t\t\tleft_side = '0';\n\t\t\t}\n\n\t\t\tif (!this.baseUnitOnly) {\n\t\t\t\t// validate right side\n\t\t\t\tright_side = right_side.replace(/\\D/g, '');\n\n\t\t\t\t// Limit decimal to only 2 digits\n\t\t\t\tlet v = Number(`0.${right_side}`);\n\t\t\t\tif (v) {\n\t\t\t\t\tconst length = right_side.length > 1 ? 2 : 1;\n\t\t\t\t\tright_side = v.toFixed(length).substring(2, 4);\n\t\t\t\t}\n\n\t\t\t\t// On blur make sure 2 numbers after decimal\n\t\t\t\tif (blur) {\n\t\t\t\t\tright_side += '00';\n\t\t\t\t}\n\n\t\t\t\tright_side = right_side.substring(0, 2);\n\n\t\t\t\t// join number by .\n\t\t\t\tinput_val = left_side + this._ds + right_side;\n\t\t\t} else {\n\t\t\t\tinput_val = left_side;\n\t\t\t}\n\t\t} else {\n\t\t\tinput_val = this._formatNumber(input_val, blur);\n\n\t\t\t// final formatting\n\t\t\tif (blur && !this.baseUnitOnly) {\n\t\t\t\tinput_val += `${this._ds}00`;\n\t\t\t}\n\t\t}\n\n\t\tconst numStr = input_val;\n\t\t// append the currency symbol\n\t\tif (!this._safari || !focus) {\n\t\t\tif (this._trailing) {\n\t\t\t\tinput_val = input_val + ' ' + this._symbol;\n\t\t\t} else {\n\t\t\t\tinput_val = this._symbol + input_val;\n\t\t\t}\n\t\t}\n\n\t\tif (negative) {\n\t\t\t// append the hypen back to the value if a negative value was entered\n\t\t\tinput_val = `-${input_val}`;\n\t\t}\n\n\t\tconst num = this._convert((negative ? '-' : '') + numStr);\n\n\t\t// update control value first with the number\n\t\tthis.change(Number(num));\n\n\t\tif (blur && num === 0) {\n\t\t\tinput_val = this._0Text;\n\t\t}\n\n\t\t// update dom with the formatted value\n\t\tthis._renderer.setProperty(input.nativeElement, 'value', input_val);\n\t\t// put caret back in the right position\n\t\tlet updated_len = input_val.length;\n\t\tif (caret_pos) {\n\t\t\tcaret_pos = updated_len - original_len + caret_pos;\n\t\t\tif (input_val.substring(caret_pos - this._symbol.length) === this._symbol && this._trailing) {\n\t\t\t\tcaret_pos -= this._symbol.length + 1;\n\t\t\t}\n\t\t}\n\t\tif (!this._safari) {\n\t\t\tinput.nativeElement.setSelectionRange(caret_pos, caret_pos);\n\t\t}\n\t}\n\n\t// format the number into currency format\n\tprivate _formatNumber(n: string, blur: boolean = false) {\n\t\t// format number 1000000 to 1,234,567\n\t\tn = n.replace(/\\D/g, '');\n\t\tif (blur) {\n\t\t\tn = n.replace(/^0+/, '');\n\t\t}\n\t\treturn this._decimalPipe.transform(n, '1.0-0') as string;\n\t}\n\n\tprivate _convert(input: string): number {\n\t\tif (!input) {\n\t\t\treturn NaN;\n\t\t}\n\t\tconst val = input\n\t\t\t.replace(this._ds, 'd')\n\t\t\t.replace(/[^0-9d-]/g, '')\n\t\t\t.replace('d', '.');\n\t\treturn parseFloat(val);\n\t}\n\n\tprivate get _0Text(): string {\n\t\tconst decimalStr = this.baseUnitOnly ? '' : `${this._ds}00`;\n\t\treturn this._trailing ? `0${decimalStr} ${this._symbol}` : `${this._symbol}0${decimalStr}`;\n\t}\n}\n","import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { CurrencyInputDirective } from './currency-input.directive';\n\n@NgModule({\n\tdeclarations: [CurrencyInputDirective],\n\timports: [CommonModule],\n\texports: [CurrencyInputDirective]\n})\nexport class CurrencyInputModule {}\n\nexport { CurrencyInputDirective };\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;AAuBA;AACO,MAAM,aAAa,GAAG,CAAC,CAAM,KAAM,GAAC,CAAC;AAE5C;;AAEG;MAKU,sBAAsB,CAAA;IAiDlC,WACiB,CAAA,GAAiC,EACzC,SAAoB,EACD,OAAe,EACH,oBAA4B,EACvB,MAAqB,EAAA;AAJjD,QAAA,IAAG,CAAA,GAAA,GAAH,GAAG,CAA8B;AACzC,QAAA,IAAS,CAAA,SAAA,GAAT,SAAS,CAAW;AACD,QAAA,IAAO,CAAA,OAAA,GAAP,OAAO,CAAQ;AACH,QAAA,IAAoB,CAAA,oBAAA,GAApB,oBAAoB,CAAQ;AACvB,QAAA,IAAM,CAAA,MAAA,GAAN,MAAM,CAAe;AArDlE;;;AAGG;AAEH,QAAA,IAAa,CAAA,aAAA,GAAY,KAAK,CAAC;AAE/B;;;AAGG;AAEH,QAAA,IAAY,CAAA,YAAA,GAAW,EAAE,CAAC;AAE1B;;;AAGG;AAEH,QAAA,IAAY,CAAA,YAAA,GAAG,KAAK,CAAC;AAErB;;AAEG;AAEH,QAAA,IAAM,CAAA,MAAA,GAAsB,MAAM,CAAC;AAG3B,QAAA,IAAW,CAAA,WAAA,GAAW,EAAE,CAAC;AAGzB,QAAA,IAAY,CAAA,YAAA,GAAG,KAAK,CAAC;AAGrB,QAAA,IAAI,CAAA,IAAA,GAAG,MAAM,CAAC;AAGd,QAAA,IAAS,CAAA,SAAA,GAAG,SAAS,CAAC;AAEtB,QAAA,IAAM,CAAA,MAAA,GAAG,aAAa,CAAC;AACvB,QAAA,I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AA,CAAA;sBADN,YAAY;uBAAC,OAAO,CAAA;gBAMrB,MAAM,EAAA,CAAA;sBADL,YAAY;uBAAC,MAAM,CAAA;;;MCtGR,mBAAmB,CAAA;;gHAAnB,mBAAmB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;AAAnB,mBAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,mBAAmB,EAJhB,YAAA,EAAA,CAAA,sBAAsB,CAC3B,EAAA,OAAA,EAAA,CAAA,YAAY,aACZ,sBAAsB,CAAA,EAAA,CAAA,CAAA;AAEpB,mBAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,mBAAmB,YAHrB,YAAY,CAAA,EAAA,CAAA,CAAA;2FAGV,mBAAmB,EAAA,UAAA,EAAA,CAAA;kBAL/B,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;oBACT,YAAY,EAAE,CAAC,sBAAsB,CAAC;oBACtC,OAAO,EAAE,CAAC,YAAY,CAAC;oBACvB,OAAO,EAAE,CAAC,sBAAsB,CAAC;iBACjC,CAAA;;;ACRD;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"bravura-ui-currency-input.mjs","sources":["../../../projects/ui/currency-input/currency-input.directive.ts","../../../projects/ui/currency-input/currency-input.module.ts","../../../projects/ui/currency-input/bravura-ui-currency-input.ts"],"sourcesContent":["import { DecimalPipe, getCurrencySymbol } from '@angular/common';\nimport {\n\tDEFAULT_CURRENCY_CODE,\n\tDirective,\n\tElementRef,\n\tforwardRef,\n\tHostBinding,\n\tHostListener,\n\tInject,\n\tInput,\n\tLOCALE_ID,\n\tOnChanges,\n\tOnInit,\n\tOptional,\n\tRenderer2,\n\tSelf,\n\tɵfindLocaleData\n} from '@angular/core';\nimport { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';\nimport { MatFormField, MAT_FORM_FIELD } from '@angular/material/form-field';\nimport { MatInput } from '@angular/material/input';\nimport { noop } from 'rxjs';\n\n/* tslint:disable:no-empty */\nexport const noop_consumer = (_: any) => {};\n\n/**\n * This directive will enhance an input element to format the numbers entered to a currency amount.\n */\n@Directive({\n\tselector: 'input[buiCurrencyInput],input[currencyCode],input[data-type=currency]',\n\tproviders: [{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => CurrencyInputDirective), multi: true }]\n})\nexport class CurrencyInputDirective implements OnInit, OnChanges, ControlValueAccessor {\n\t/**\n\t * true to allow negative input, otherwise false\n\t * Default to false.\n\t */\n\t@Input()\n\tallowNegative: boolean = false;\n\n\t/**\n\t * Provide the currency code to format the entered amount.\n\t * Uses angular token DEFAULT_CURRENCY_CODE by default.\n\t */\n\t@Input()\n\tcurrencyCode: string = '';\n\n\t/**\n\t * true if no decimal digits allowed, otherwise false.\n\t * Default to false.\n\t */\n\t@Input()\n\tbaseUnitOnly = false;\n\n\t/**\n\t * The format the of the amount either in wide or narrow.\n\t */\n\t@Input()\n\tformat: 'narrow' | 'wide' = 'wide';\n\n\t@HostBinding('placeholder')\n\tprivate placeholder: string = '';\n\n\t@HostBinding('autocomplete')\n\tprivate autocomplete = 'off';\n\n\t@HostBinding('type')\n\tprivate type = 'text';\n\n\t@HostBinding('attr.inputmode')\n\tprivate inputMode = 'decimal';\n\n\tprivate change = noop_consumer;\n\tprivate onTouch = noop;\n\tprivate _safari: boolean;\n\tprivate _symbol: string = '$';\n\tprivate _decimalPipe!: DecimalPipe;\n\n\tprivate _ds = '.'; // decimal separator\n\tprivate _trailing = false;\n\n\tconstructor(\n\t\t@Self() private _el: ElementRef<HTMLInputElement>,\n\t\tprivate _renderer: Renderer2,\n\t\t@Inject(LOCALE_ID) private _locale: string,\n\t\t@Inject(DEFAULT_CURRENCY_CODE) private _defaultCurrencyCode: string,\n\t\t@Optional() @Inject(MAT_FORM_FIELD) private _field?: MatFormField\n\t) {\n\t\tconst userAgent = navigator.userAgent;\n\t\tthis._safari = !userAgent.match(/Firefox/i) && !userAgent.match(/Chrome/i) && !!userAgent.match(/safari/i);\n\t\tthis._currencyUpdated();\n\t}\n\n\tngOnInit() {}\n\n\tngOnChanges(): void {\n\t\tthis._currencyUpdated();\n\t\tthis.onInput();\n\t}\n\n\t@HostListener('input')\n\tonInput() {\n\t\tthis._formatCurrency(this._el, false, true);\n\t}\n\n\t@HostListener('focus')\n\tonFocus() {\n\t\tthis._formatCurrency(this._el, false, true);\n\t}\n\n\t@HostListener('blur')\n\tonblur() {\n\t\tthis.onTouch();\n\t\tthis._formatCurrency(this._el, true, false);\n\t}\n\n\twriteValue(value: any) {\n\t\tvalue = this._decimalPipe.transform(value);\n\t\tthis._renderer.setProperty(this._el.nativeElement, 'value', value);\n\t\tthis._formatCurrency(this._el, true, false);\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 _updatePlaceholder() {\n\t\tthis.placeholder = this.placeholder || this._0Text;\n\t\tif (this._field?._control instanceof MatInput) {\n\t\t\tthis._field._control.placeholder = this.placeholder;\n\t\t}\n\t}\n\n\tprivate _currencyUpdated() {\n\t\tthis.currencyCode = this.currencyCode || this._defaultCurrencyCode;\n\t\tthis._symbol = getCurrencySymbol(this.currencyCode, this.format, this._locale) || '$';\n\t\tconst localeData = ɵfindLocaleData(this._locale);\n\t\tthis._ds = localeData[13][0];\n\t\tthis._decimalPipe = new DecimalPipe(this._locale);\n\t\tconst curFormat: string = localeData[14][2];\n\t\tthis._trailing = curFormat.indexOf('¤') > 0;\n\t\tthis._updatePlaceholder();\n\t}\n\n\tprivate _formatCurrency(input: ElementRef<HTMLInputElement>, blur: boolean, focus: boolean) {\n\t\t// appends $ to value, validates decimal side\n\t\t// and puts cursor back in right position.\n\t\t// get input value\n\t\tlet input_val = input.nativeElement.value;\n\n\t\t// don't validate empty input\n\t\tif (input_val === '') {\n\t\t\tthis.change(null);\n\t\t\treturn;\n\t\t}\n\n\t\tconst minus = this.allowNegative ? '-' : '';\n\n\t\t// remove non digit values except currency symbol, decimal separator and hypen\n\t\tconst reg = new RegExp(`[^0-9${minus}${this._symbol}${this._ds}]`, 'g');\n\n\t\tlet sanitiseValue = input_val.replace(reg, '');\n\n\t\tif (sanitiseValue === '' || sanitiseValue === this._symbol) {\n\t\t\tthis.change(null);\n\t\t\tthis._renderer.setProperty(input.nativeElement, 'value', '');\n\t\t\treturn;\n\t\t} else if (\n\t\t\t(this.allowNegative && sanitiseValue === `-${this._symbol}`) ||\n\t\t\tsanitiseValue === '-' ||\n\t\t\tsanitiseValue === '--'\n\t\t) {\n\t\t\tthis.change(null);\n\t\t\tthis._renderer.setProperty(input.nativeElement, 'value', '-');\n\t\t\treturn;\n\t\t}\n\n\t\tconst negative = this.allowNegative && input_val.indexOf('-') >= 0;\n\n\t\t// original length\n\t\tconst original_len = input_val.length;\n\n\t\t// initial caret position\n\t\tlet caret_pos = input.nativeElement.selectionStart;\n\n\t\tinput_val = input_val.replace(RegExp(`[^0-9${minus}${this._ds}]`, 'g'), '').replace(/^\\.\\./, '');\n\t\t// check for decimal\n\t\tif (input_val.indexOf(this._ds) >= 0) {\n\t\t\t// get position of first decimal\n\t\t\t// this prevents multiple decimals from\n\t\t\t// being entered\n\t\t\tlet decimal_pos = input_val.indexOf(this._ds);\n\n\t\t\t// split number by decimal point\n\t\t\tlet left_side = input_val.substring(0, decimal_pos);\n\t\t\tlet right_side = input_val.substring(decimal_pos);\n\n\t\t\t// add commas to left side of number\n\t\t\tleft_side = this._formatNumber(left_side, blur) || '';\n\n\t\t\t// no value append a zero for decimal values\n\t\t\tif (!left_side.length) {\n\t\t\t\tleft_side = '0';\n\t\t\t}\n\n\t\t\tif (!this.baseUnitOnly) {\n\t\t\t\t// validate right side\n\t\t\t\tright_side = right_side.replace(/\\D/g, '');\n\n\t\t\t\t// Limit decimal to only 2 digits\n\t\t\t\tlet v = Number(`0.${right_side}`);\n\t\t\t\tif (v) {\n\t\t\t\t\tconst length = right_side.length > 1 ? 2 : 1;\n\t\t\t\t\tright_side = v.toFixed(length).substring(2, 4);\n\t\t\t\t}\n\n\t\t\t\t// On blur make sure 2 numbers after decimal\n\t\t\t\tif (blur) {\n\t\t\t\t\tright_side += '00';\n\t\t\t\t}\n\n\t\t\t\tright_side = right_side.substring(0, 2);\n\n\t\t\t\t// join number by .\n\t\t\t\tinput_val = left_side + this._ds + right_side;\n\t\t\t} else {\n\t\t\t\tinput_val = left_side;\n\t\t\t}\n\t\t} else {\n\t\t\tinput_val = this._formatNumber(input_val, blur);\n\n\t\t\t// final formatting\n\t\t\tif (blur && !this.baseUnitOnly) {\n\t\t\t\tinput_val += `${this._ds}00`;\n\t\t\t}\n\t\t}\n\n\t\tconst numStr = input_val;\n\t\t// append the currency symbol\n\t\tif (!this._safari || !focus) {\n\t\t\tif (this._trailing) {\n\t\t\t\tinput_val = input_val + ' ' + this._symbol;\n\t\t\t} else {\n\t\t\t\tinput_val = this._symbol + input_val;\n\t\t\t}\n\t\t}\n\n\t\tif (negative) {\n\t\t\t// append the hypen back to the value if a negative value was entered\n\t\t\tinput_val = `-${input_val}`;\n\t\t}\n\n\t\tconst num = this._convert((negative ? '-' : '') + numStr);\n\n\t\t// update control value first with the number\n\t\tthis.change(Number(num));\n\n\t\tif (blur && num === 0) {\n\t\t\tinput_val = this._0Text;\n\t\t}\n\n\t\t// update dom with the formatted value\n\t\tthis._renderer.setProperty(input.nativeElement, 'value', input_val);\n\t\t// put caret back in the right position\n\t\tlet updated_len = input_val.length;\n\t\tif (caret_pos) {\n\t\t\tcaret_pos = updated_len - original_len + caret_pos;\n\t\t\tif (input_val.substring(caret_pos - this._symbol.length) === this._symbol && this._trailing) {\n\t\t\t\tcaret_pos -= this._symbol.length + 1;\n\t\t\t}\n\t\t}\n\t\tif (!this._safari) {\n\t\t\tinput.nativeElement.setSelectionRange(caret_pos, caret_pos);\n\t\t}\n\t}\n\n\t// format the number into currency format\n\tprivate _formatNumber(n: string, blur: boolean = false) {\n\t\t// format number 1000000 to 1,234,567\n\t\tn = n.replace(/\\D/g, '');\n\t\tif (blur) {\n\t\t\tn = n.replace(/^0+/, '');\n\t\t}\n\t\treturn this._decimalPipe.transform(n, '1.0-0') as string;\n\t}\n\n\tprivate _convert(input: string): number {\n\t\tif (!input) {\n\t\t\treturn NaN;\n\t\t}\n\t\tconst val = input\n\t\t\t.replace(this._ds, 'd')\n\t\t\t.replace(/[^0-9d-]/g, '')\n\t\t\t.replace('d', '.');\n\t\treturn parseFloat(val);\n\t}\n\n\tprivate get _0Text(): string {\n\t\tconst decimalStr = this.baseUnitOnly ? '' : `${this._ds}00`;\n\t\treturn this._trailing ? `0${decimalStr} ${this._symbol}` : `${this._symbol}0${decimalStr}`;\n\t}\n}\n","import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { CurrencyInputDirective } from './currency-input.directive';\n\n@NgModule({\n\tdeclarations: [CurrencyInputDirective],\n\timports: [CommonModule],\n\texports: [CurrencyInputDirective]\n})\nexport class CurrencyInputModule {}\n\nexport { CurrencyInputDirective };\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;AAuBA;AACO,MAAM,aAAa,GAAG,CAAC,CAAM,KAAM,GAAC,CAAC;AAE5C;;AAEG;MAKU,sBAAsB,CAAA;IAiDlC,WACiB,CAAA,GAAiC,EACzC,SAAoB,EACD,OAAe,EACH,oBAA4B,EACvB,MAAqB,EAAA;AAJjD,QAAA,IAAG,CAAA,GAAA,GAAH,GAAG,CAA8B;AACzC,QAAA,IAAS,CAAA,SAAA,GAAT,SAAS,CAAW;AACD,QAAA,IA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,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,mBAAmB,YAHrB,YAAY,CAAA,EAAA,CAAA,CAAA;2FAGV,mBAAmB,EAAA,UAAA,EAAA,CAAA;kBAL/B,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;oBACT,YAAY,EAAE,CAAC,sBAAsB,CAAC;oBACtC,OAAO,EAAE,CAAC,YAAY,CAAC;oBACvB,OAAO,EAAE,CAAC,sBAAsB,CAAC;iBACjC,CAAA;;;ACRD;;AAEG;;;;"}
|
|
@@ -36,7 +36,8 @@ class DecimalInputDirective {
|
|
|
36
36
|
const newValue = value.substring(0, indexOfPeriod + this.buiDecimalInput + 1);
|
|
37
37
|
this._renderer.setProperty(this._el.nativeElement, 'value', newValue);
|
|
38
38
|
}
|
|
39
|
-
this.
|
|
39
|
+
const resolvedValue = this._el.nativeElement.value;
|
|
40
|
+
this.change(resolvedValue === '' || resolvedValue === null || resolvedValue === undefined ? null : Number(resolvedValue));
|
|
40
41
|
}
|
|
41
42
|
onKeypress(evt) {
|
|
42
43
|
const target = evt.target;
|
|
@@ -55,6 +56,7 @@ class DecimalInputDirective {
|
|
|
55
56
|
}
|
|
56
57
|
writeValue(value) {
|
|
57
58
|
this._renderer.setProperty(this._el.nativeElement, 'value', value);
|
|
59
|
+
this._resetDecimalPlaces();
|
|
58
60
|
}
|
|
59
61
|
registerOnChange(fn) {
|
|
60
62
|
this.change = fn;
|
|
@@ -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';\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\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\t@Input()\n\tbuiDecimalInput: number = 2;\n\n\t@HostBinding('placeholder')\n\tprivate placeholder: string = '';\n\n\t@HostBinding('autocomplete')\n\tprivate autocomplete = 'off';\n\n\t@HostBinding('type')\n\tprivate type = 'number';\n\n\t@HostBinding('attr.inputmode')\n\tprivate inputMode = 'decimal';\n\n\tprivate change = noop_consumer;\n\tprivate onTouch = noop;\n\n\tconstructor(@Self() private _el: ElementRef<HTMLInputElement>, private _renderer: Renderer2) {}\n\n\tngOnChanges(): void {\n\t\tthis.buiDecimalInput = this.buiDecimalInput || 2;\n\t\tthis.onInput();\n\t}\n\n\t@HostListener('input')\n\tonInput() {\n\t\tconst value = this._el.nativeElement.value;\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\
|
|
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\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\t@Input()\n\tbuiDecimalInput: number = 2;\n\n\t@HostBinding('placeholder')\n\tprivate placeholder: string = '';\n\n\t@HostBinding('autocomplete')\n\tprivate autocomplete = 'off';\n\n\t@HostBinding('type')\n\tprivate type = 'number';\n\n\t@HostBinding('attr.inputmode')\n\tprivate inputMode = 'decimal';\n\n\tprivate change = noop_consumer;\n\tprivate onTouch = noop;\n\n\tconstructor(@Self() private _el: ElementRef<HTMLInputElement>, private _renderer: Renderer2) {}\n\n\tngOnChanges(): void {\n\t\tthis.buiDecimalInput = this.buiDecimalInput || 2;\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('focus')\n\tonFocus() {}\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\tthis.buiDecimalInput = this.buiDecimalInput < 0 ? 0 : this.buiDecimalInput;\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 { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { DecimalInputDirective } from './decimal-input.directive';\n\n@NgModule({\n\tdeclarations: [DecimalInputDirective],\n\timports: [CommonModule],\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":";;;;;;AAe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to start uploading.';
|
|
128
128
|
/** Specifies the total number of files accepted. A falsy value removes the limit.*/
|
|
129
129
|
this.limit = 0;
|
|
130
|
+
/**
|
|
131
|
+
* specify the number of maximum bytes that can be uploaded.
|
|
132
|
+
* if number is specified, bytes are assumed, otherwise enter a string for specific size type.
|
|
133
|
+
*/
|
|
134
|
+
this.fileSize = '10MB';
|
|
135
|
+
/** @ignore */
|
|
136
|
+
this._fileSizeExceedMsg = '';
|
|
130
137
|
/** @ignore */
|
|
131
138
|
this._uploadingItems = [];
|
|
132
139
|
/** @ignore */
|
|
@@ -234,7 +241,7 @@ class FileUploadComponent {
|
|
|
234
241
|
event.stopPropagation();
|
|
235
242
|
this._onDndStopFrame();
|
|
236
243
|
const files = (_a = event.dataTransfer) === null || _a === void 0 ? void 0 : _a.files;
|
|
237
|
-
if (files === null || files === void 0 ? void 0 : files.length) {
|
|
244
|
+
if ((files === null || files === void 0 ? void 0 : files.length) && this._validateFileSize(files)) {
|
|
238
245
|
this._uploadFiles(Array.from(files));
|
|
239
246
|
}
|
|
240
247
|
}
|
|
@@ -268,7 +275,7 @@ class FileUploadComponent {
|
|
|
268
275
|
/** @ignore */
|
|
269
276
|
_handleFileSelection() {
|
|
270
277
|
const fileList = this._fileInput.nativeElement.files;
|
|
271
|
-
if (fileList === null || fileList === void 0 ? void 0 : fileList.length) {
|
|
278
|
+
if ((fileList === null || fileList === void 0 ? void 0 : fileList.length) && this._validateFileSize(fileList)) {
|
|
272
279
|
this._uploadFiles(Array.from(fileList));
|
|
273
280
|
this._fileInput.nativeElement.value = '';
|
|
274
281
|
}
|
|
@@ -281,6 +288,41 @@ class FileUploadComponent {
|
|
|
281
288
|
get _initialising() {
|
|
282
289
|
return !!this._initSubs && !this._initSubs.closed;
|
|
283
290
|
}
|
|
291
|
+
returnFileSize(size) {
|
|
292
|
+
if (size < 1024) {
|
|
293
|
+
return `${size} bytes`;
|
|
294
|
+
}
|
|
295
|
+
else if (size >= 1024 && size < 1048576) {
|
|
296
|
+
return `${(size / 1024).toFixed(1)} KB`;
|
|
297
|
+
}
|
|
298
|
+
else {
|
|
299
|
+
return `${(size / 1048576).toFixed(1)} MB`;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
_validateFileSize(files) {
|
|
303
|
+
this._fileSizeExceedMsg = '';
|
|
304
|
+
const maxSize = this.returnFileSize(this._getMaxBytes());
|
|
305
|
+
for (let i = 0; i < files.length; i++) {
|
|
306
|
+
if (files[i].size > this._getMaxBytes()) {
|
|
307
|
+
this._fileSizeExceedMsg = `Selected file/s has exceeded the allowable size of ${maxSize} per file`;
|
|
308
|
+
return false;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
return true;
|
|
312
|
+
}
|
|
313
|
+
_getMaxBytes() {
|
|
314
|
+
if (typeof this.fileSize === 'string') {
|
|
315
|
+
if (this.fileSize.toUpperCase().endsWith('KB')) {
|
|
316
|
+
const kiloBytes = this.fileSize.substring(0, this.fileSize.indexOf('KB'));
|
|
317
|
+
return Number(kiloBytes) * 1024;
|
|
318
|
+
}
|
|
319
|
+
else if (this.fileSize.toUpperCase().endsWith('MB')) {
|
|
320
|
+
const megaBytes = this.fileSize.substring(0, this.fileSize.indexOf('MB'));
|
|
321
|
+
return Number(megaBytes) * 1048576;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
return this.fileSize;
|
|
325
|
+
}
|
|
284
326
|
_uploadFiles(files) {
|
|
285
327
|
if (this._initialising || files.length > this.remaining) {
|
|
286
328
|
return;
|
|
@@ -342,7 +384,7 @@ class FileUploadComponent {
|
|
|
342
384
|
}
|
|
343
385
|
}
|
|
344
386
|
FileUploadComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.3", ngImport: i0, type: FileUploadComponent, deps: [{ token: FileUploadService }], target: i0.ɵɵFactoryTarget.Component });
|
|
345
|
-
FileUploadComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.1.3", type: FileUploadComponent, selector: "bui-file-upload", inputs: { uploadActionText: "uploadActionText", fileUploadedLabel: "fileUploadedLabel", dragHint: "dragHint", dropHint: "dropHint", limit: "limit", types: "types" }, host: { listeners: { "dragenter": "onDragEnter($event)", "dragover": "onDragOver($event)", "dragleave": "onDragLeave($event)", "drop": "onDndDrop($event)" }, properties: { "class.bui-dnd-active": "_overFrame && remaining >= _numberOfFilesDragged", "class.bui-dnd-over": "_overDropZone && remaining >= _numberOfFilesDragged", "class.bui-dnd-invalid": "_invalidFilesDragged" }, classAttribute: "bui-host bui-file-upload" }, providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => FileUploadComponent), multi: true }], viewQueries: [{ propertyName: "_fileInput", first: true, predicate: ["fileInput"], descendants: true, read: ElementRef, static: true }], ngImport: i0, template: "<div class=\"bui-file-upload-container\">\n\t<div\n\t\tclass=\"bui-file-upload-hint\"\n\t\t*ngIf=\"!_initialising && remaining > 0 && (!_itemAnimationInProgress || remaining > 1)\"\n\t>\n\t\t<ng-template [ngIf]=\"_invalidFilesDragged\" [ngIfElse]=\"validDnd\">\n\t\t\t<mat-icon [buiIcon]=\"'block'\" [size]=\"32\" color=\"warn\" variant=\"outlined\" style=\"opacity: 0.6\"></mat-icon>\n\t\t</ng-template>\n\t\t<ng-template #validDnd>\n\t\t\t<div *ngIf=\"!_overFrame && !_overDropZone\" class=\"bui-color-muted bui-upload-icon-link\" (click)=\"selectFiles()\">\n\t\t\t\t<mat-icon [buiIcon]=\"'fas fa-cloud-upload-alt'\" [size]=\"32\"></mat-icon>\n\t\t\t\t<a role=\"button\">{{ uploadActionText }}</a>\n\t\t\t</div>\n\t\t\t<div *ngIf=\"_overFrame && !_overDropZone\" class=\"bui-color-light\">{{ dragHint }}</div>\n\t\t\t<div *ngIf=\"_overDropZone\" class=\"bui-color-light\">{{ dropHint }}</div>\n\t\t</ng-template>\n\t</div>\n\t<div\n\t\tclass=\"bui-file-upload-list\"\n\t\t[@slideOut]=\"_uploadingItems.length\"\n\t\t(@slideOut.start)=\"_itemAnimationStart.next()\"\n\t\t(@slideOut.done)=\"_itemAnimationDone.next()\"\n\t\t*ngIf=\"_uploadingItems.length\"\n\t>\n\t\t<span class=\"bui-file-uploaded-label\">{{ fileUploadedLabel }}</span>\n\n\t\t<ng-container *ngFor=\"let item of _uploadingItems; let idx = index\">\n\t\t\t<div class=\"bui-file-upload-item\" [class.in-progress]=\"!item.done\" #itemDiv>\n\t\t\t\t<div class=\"bui-file-upload-item-name\">\n\t\t\t\t\t<span>\n\t\t\t\t\t\t<mat-icon class=\"bui-color-muted\">description</mat-icon>\n\t\t\t\t\t\t<a\n\t\t\t\t\t\t\tclass=\"text\"\n\t\t\t\t\t\t\t*ngIf=\"item.done && !item.downloading; else staticName\"\n\t\t\t\t\t\t\thref=\"#{{ item.uploadedItem?.id }}\"\n\t\t\t\t\t\t\t(click)=\"$event.preventDefault(); _openItem(item)\"\n\t\t\t\t\t\t\tcontextmenu=\"false\"\n\t\t\t\t\t\t\tmatTooltip=\"Download\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{{ item.name }}\n\t\t\t\t\t\t</a>\n\t\t\t\t\t\t<ng-template #staticName>\n\t\t\t\t\t\t\t<span class=\"text\">{{ item.name }}</span>\n\t\t\t\t\t\t</ng-template>\n\t\t\t\t\t</span>\n\t\t\t\t\t<div class=\"bui-file-upload-item-progress\">\n\t\t\t\t\t\t<mat-progress-bar\n\t\t\t\t\t\t\tmode=\"determinate\"\n\t\t\t\t\t\t\t[class.upload-completed]=\"item.done\"\n\t\t\t\t\t\t\t*ngIf=\"!item.downloading\"\n\t\t\t\t\t\t\t[value]=\"item.done ? 100 : item.progress * 100\"\n\t\t\t\t\t\t></mat-progress-bar>\n\t\t\t\t\t\t<mat-progress-bar mode=\"buffer\" *ngIf=\"item.downloading\"></mat-progress-bar>\n\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t<ng-template [ngIf]=\"item.done\" [ngIfElse]=\"inprogress\"> 100% </ng-template>\n\t\t\t\t\t\t\t<ng-template #inprogress>\n\t\t\t\t\t\t\t\t{{ item.progress | percent }}\n\t\t\t\t\t\t\t</ng-template>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t\t<div class=\"bui-file-upload-item-action\">\n\t\t\t\t\t<button\n\t\t\t\t\t\tmat-icon-button\n\t\t\t\t\t\tcolor=\"primary\"\n\t\t\t\t\t\t(click)=\"item.cancel()\"\n\t\t\t\t\t\t(mouseenter)=\"itemDiv.classList.add('bui-file-upload-item-deleting')\"\n\t\t\t\t\t\t(mouseleave)=\"itemDiv.classList.remove('bui-file-upload-item-deleting')\"\n\t\t\t\t\t\tmatTooltip=\"Delete\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<mat-icon [buiIcon]=\"'cancel'\" style=\"line-height: 0.9\"></mat-icon>\n\t\t\t\t\t</button>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t<mat-divider *ngIf=\"idx < _uploadingItems.length - 1\"></mat-divider>\n\t\t</ng-container>\n\t</div>\n\t<input\n\t\ttype=\"file\"\n\t\t#fileInput\n\t\tstyle=\"display: none\"\n\t\taccept=\"{{ _accept }}\"\n\t\t(change)=\"_handleFileSelection()\"\n\t\t[multiple]=\"remaining > 1\"\n\t/>\n</div>\n", styles: [":host:not([hidden]){display:block;border-style:dashed;border-width:1px;border-color:var(--bui-color-muted);transition:all .12s;padding:3px}:host:not([hidden]).bui-dnd-active,:host:not([hidden]).bui-dnd-over{padding:0;border-width:4px}:host:not([hidden]).bui-dnd-invalid{cursor:no-drop}:host:not([hidden]) .bui-file-upload-hint{margin:.5rem;height:40px;justify-content:center;display:flex;align-items:center}:host:not([hidden]) .bui-file-upload-container{min-height:4rem;display:flex;align-items:center;flex-direction:column;justify-content:center;transition:initial}:host:not([hidden]) .bui-file-upload-container .bui-upload-icon-link{cursor:pointer;transition:color .1s cubic-bezier(.55,0,.55,.2);display:flex;align-items:center}:host:not([hidden]) .bui-file-upload-container .bui-upload-icon-link:hover{color:var(--bui-color-light)!important}:host:not([hidden]) .bui-file-upload-container .bui-upload-icon-link>*{margin:4px}:host:not([hidden]) .bui-file-upload-list{align-self:stretch;margin-top:calc(1rem - 4px)}:host:not([hidden]) .bui-file-upload-list .bui-file-uploaded-label{display:block;font-size:smaller;margin:0 calc(1rem - 4px) .5rem calc(1rem - 4px)}:host:not([hidden]) .bui-file-upload-list .bui-file-upload-item{display:flex;align-items:center;margin:0 calc(1rem - 4px);padding:.25rem 0;justify-content:space-between}:host:not([hidden]) .bui-file-upload-list .bui-file-upload-item:last-child{margin-bottom:calc(.5rem - 4px)}:host:not([hidden]) .bui-file-upload-list .bui-file-upload-item.in-progress .bui-file-upload-item-name{font-style:italic}:host:not([hidden]) .bui-file-upload-list .bui-file-upload-item.bui-file-upload-item-deleting{background-color:#8080801a;transition:background-color .1s cubic-bezier(.55,0,.55,.2)}:host:not([hidden]) .bui-file-upload-list .bui-file-upload-item-name{flex-grow:1;font-size:80%;display:flex;align-items:center;flex-wrap:wrap}:host:not([hidden]) .bui-file-upload-list .bui-file-upload-item-name>span{word-break:break-all;display:flex;align-items:center}:host:not([hidden]) .bui-file-upload-list .bui-file-upload-item-name>span>mat-icon{width:20px;height:20px;font-size:20px}:host:not([hidden]) .bui-file-upload-list .bui-file-upload-item-name a{color:var(--bui-color-primary)}:host:not([hidden]) .bui-file-upload-list .bui-file-upload-item-name .text{margin-left:.5rem;margin-right:.5rem}:host:not([hidden]) .bui-file-upload-list .bui-file-upload-item-progress{flex-grow:1;min-width:50%;display:flex;justify-content:flex-start;align-items:center;margin:.5rem 0}:host:not([hidden]) .bui-file-upload-list .bui-file-upload-item-progress .mat-progress-bar{max-width:100%;height:.4rem;border-radius:1rem}:host:not([hidden]) .bui-file-upload-list .bui-file-upload-item-progress>span{margin-inline-start:.5rem}:host:not([hidden]) .bui-file-upload-list .bui-file-upload-item-action{display:flex;align-items:center;height:1em;width:1.75em}:host:not([hidden]) .bui-file-upload-list .mat-divider{margin:0 calc(1rem - 4px) 0 calc(1rem - 4px)}:host:not([hidden]) .upload-completed{animation:pulse 1s ease-in-out}@keyframes pulse{0%{transform:scaleY(1)}50%{transform:scaleY(1.5)}to{transform:scaleY(1)}}\n"], dependencies: [{ kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i3.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "directive", type: i4.IconDirective, selector: "[buiIcon]", inputs: ["buiIcon", "size", "variant"] }, { kind: "component", type: i5.MatProgressBar, selector: "mat-progress-bar", inputs: ["color", "value", "bufferValue", "mode"], outputs: ["animationEnd"], exportAs: ["matProgressBar"] }, { kind: "component", type: i6.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "component", type: i7.MatDivider, selector: "mat-divider", inputs: ["vertical", "inset"] }, { kind: "directive", type: i8.MatTooltip, selector: "[matTooltip]", exportAs: ["matTooltip"] }, { kind: "pipe", type: i2.PercentPipe, name: "percent" }], animations: [
|
|
387
|
+
FileUploadComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.1.3", type: FileUploadComponent, selector: "bui-file-upload", inputs: { uploadActionText: "uploadActionText", fileUploadedLabel: "fileUploadedLabel", dragHint: "dragHint", dropHint: "dropHint", limit: "limit", fileSize: "fileSize", types: "types" }, host: { listeners: { "dragenter": "onDragEnter($event)", "dragover": "onDragOver($event)", "dragleave": "onDragLeave($event)", "drop": "onDndDrop($event)" }, properties: { "class.bui-dnd-active": "_overFrame && remaining >= _numberOfFilesDragged", "class.bui-dnd-over": "_overDropZone && remaining >= _numberOfFilesDragged", "class.bui-dnd-invalid": "_invalidFilesDragged" }, classAttribute: "bui-host bui-file-upload" }, providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => FileUploadComponent), multi: true }], viewQueries: [{ propertyName: "_fileInput", first: true, predicate: ["fileInput"], descendants: true, read: ElementRef, static: true }], ngImport: i0, template: "<div class=\"bui-file-upload-container\">\n\t<div\n\t\tclass=\"bui-file-upload-hint\"\n\t\t*ngIf=\"!_initialising && remaining > 0 && (!_itemAnimationInProgress || remaining > 1)\"\n\t>\n\t\t<ng-template [ngIf]=\"_invalidFilesDragged\" [ngIfElse]=\"validDnd\">\n\t\t\t<mat-icon [buiIcon]=\"'block'\" [size]=\"32\" color=\"warn\" variant=\"outlined\" style=\"opacity: 0.6\"></mat-icon>\n\t\t</ng-template>\n\t\t<ng-template #validDnd>\n\t\t\t<div *ngIf=\"!_overFrame && !_overDropZone\" class=\"bui-color-muted bui-upload-icon-link\" (click)=\"selectFiles()\">\n\t\t\t\t<mat-icon [buiIcon]=\"'fas fa-cloud-upload-alt'\" [size]=\"32\"></mat-icon>\n\t\t\t\t<a role=\"button\">{{ uploadActionText }}</a>\n\t\t\t</div>\n\t\t\t<div *ngIf=\"_overFrame && !_overDropZone\" class=\"bui-color-light\">{{ dragHint }}</div>\n\t\t\t<div *ngIf=\"_overDropZone\" class=\"bui-color-light\">{{ dropHint }}</div>\n\t\t</ng-template>\n\t</div>\n\t<div\n\t\tclass=\"bui-file-upload-list\"\n\t\t[@slideOut]=\"_uploadingItems.length\"\n\t\t(@slideOut.start)=\"_itemAnimationStart.next()\"\n\t\t(@slideOut.done)=\"_itemAnimationDone.next()\"\n\t\t*ngIf=\"_uploadingItems.length\"\n\t>\n\t\t<span class=\"bui-file-uploaded-label\">{{ fileUploadedLabel }}</span>\n\n\t\t<ng-container *ngFor=\"let item of _uploadingItems; let idx = index\">\n\t\t\t<div class=\"bui-file-upload-item\" [class.in-progress]=\"!item.done\" #itemDiv>\n\t\t\t\t<div class=\"bui-file-upload-item-name\">\n\t\t\t\t\t<span>\n\t\t\t\t\t\t<mat-icon class=\"bui-color-muted\">description</mat-icon>\n\t\t\t\t\t\t<a\n\t\t\t\t\t\t\tclass=\"text\"\n\t\t\t\t\t\t\t*ngIf=\"item.done && !item.downloading; else staticName\"\n\t\t\t\t\t\t\thref=\"#{{ item.uploadedItem?.id }}\"\n\t\t\t\t\t\t\t(click)=\"$event.preventDefault(); _openItem(item)\"\n\t\t\t\t\t\t\tcontextmenu=\"false\"\n\t\t\t\t\t\t\tmatTooltip=\"Download\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{{ item.name }}\n\t\t\t\t\t\t</a>\n\t\t\t\t\t\t<ng-template #staticName>\n\t\t\t\t\t\t\t<span class=\"text\">{{ item.name }}</span>\n\t\t\t\t\t\t</ng-template>\n\t\t\t\t\t</span>\n\t\t\t\t\t<div class=\"bui-file-upload-item-progress\">\n\t\t\t\t\t\t<mat-progress-bar\n\t\t\t\t\t\t\tmode=\"determinate\"\n\t\t\t\t\t\t\t[class.upload-completed]=\"item.done\"\n\t\t\t\t\t\t\t*ngIf=\"!item.downloading\"\n\t\t\t\t\t\t\t[value]=\"item.done ? 100 : item.progress * 100\"\n\t\t\t\t\t\t></mat-progress-bar>\n\t\t\t\t\t\t<mat-progress-bar mode=\"buffer\" *ngIf=\"item.downloading\"></mat-progress-bar>\n\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t<ng-template [ngIf]=\"item.done\" [ngIfElse]=\"inprogress\"> 100% </ng-template>\n\t\t\t\t\t\t\t<ng-template #inprogress>\n\t\t\t\t\t\t\t\t{{ item.progress | percent }}\n\t\t\t\t\t\t\t</ng-template>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t\t<div class=\"bui-file-upload-item-action\">\n\t\t\t\t\t<button\n\t\t\t\t\t\tmat-icon-button\n\t\t\t\t\t\tcolor=\"primary\"\n\t\t\t\t\t\t(click)=\"item.cancel()\"\n\t\t\t\t\t\t(mouseenter)=\"itemDiv.classList.add('bui-file-upload-item-deleting')\"\n\t\t\t\t\t\t(mouseleave)=\"itemDiv.classList.remove('bui-file-upload-item-deleting')\"\n\t\t\t\t\t\tmatTooltip=\"Delete\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<mat-icon [buiIcon]=\"'cancel'\" style=\"line-height: 0.9\"></mat-icon>\n\t\t\t\t\t</button>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t<mat-divider *ngIf=\"idx < _uploadingItems.length - 1\"></mat-divider>\n\t\t</ng-container>\n\t</div>\n\t<input\n\t\ttype=\"file\"\n\t\t#fileInput\n\t\tstyle=\"display: none\"\n\t\taccept=\"{{ _accept }}\"\n\t\t(change)=\"_handleFileSelection()\"\n\t\t[multiple]=\"remaining > 1\"\n\t/>\n\n\t<div *ngIf=\"_fileSizeExceedMsg\" class=\"bui-color-warn bui-file-size-exceed\">\n\t\t<span> {{ _fileSizeExceedMsg }}</span> <mat-icon role=\"button\" (click)=\"_fileSizeExceedMsg = ''\">cancel</mat-icon>\n\t</div>\n</div>\n", styles: [":host:not([hidden]){display:block;border-style:dashed;border-width:1px;border-color:var(--bui-color-muted);transition:all .12s;padding:3px}:host:not([hidden]).bui-dnd-active,:host:not([hidden]).bui-dnd-over{padding:0;border-width:4px}:host:not([hidden]) .bui-file-size-exceed{display:flex;align-items:center;margin-bottom:1rem}:host:not([hidden]) .bui-file-size-exceed mat-icon{margin-left:.2rem}:host:not([hidden]).bui-dnd-invalid{cursor:no-drop}:host:not([hidden]) .bui-file-upload-hint{margin:.5rem;height:40px;justify-content:center;display:flex;align-items:center}:host:not([hidden]) .bui-file-upload-container{min-height:4rem;display:flex;align-items:center;flex-direction:column;justify-content:center;transition:initial}:host:not([hidden]) .bui-file-upload-container .bui-upload-icon-link{cursor:pointer;transition:color .1s cubic-bezier(.55,0,.55,.2);display:flex;align-items:center}:host:not([hidden]) .bui-file-upload-container .bui-upload-icon-link:hover{color:var(--bui-color-light)!important}:host:not([hidden]) .bui-file-upload-container .bui-upload-icon-link>*{margin:4px}:host:not([hidden]) .bui-file-upload-list{align-self:stretch;margin-top:calc(1rem - 4px)}:host:not([hidden]) .bui-file-upload-list .bui-file-uploaded-label{display:block;font-size:smaller;margin:0 calc(1rem - 4px) .5rem calc(1rem - 4px)}:host:not([hidden]) .bui-file-upload-list .bui-file-upload-item{display:flex;align-items:center;margin:0 calc(1rem - 4px);padding:.25rem 0;justify-content:space-between}:host:not([hidden]) .bui-file-upload-list .bui-file-upload-item:last-child{margin-bottom:calc(.5rem - 4px)}:host:not([hidden]) .bui-file-upload-list .bui-file-upload-item.in-progress .bui-file-upload-item-name{font-style:italic}:host:not([hidden]) .bui-file-upload-list .bui-file-upload-item.bui-file-upload-item-deleting{background-color:#8080801a;transition:background-color .1s cubic-bezier(.55,0,.55,.2)}:host:not([hidden]) .bui-file-upload-list .bui-file-upload-item-name{flex-grow:1;font-size:80%;display:flex;align-items:center;flex-wrap:wrap}:host:not([hidden]) .bui-file-upload-list .bui-file-upload-item-name>span{word-break:break-all;display:flex;align-items:center}:host:not([hidden]) .bui-file-upload-list .bui-file-upload-item-name>span>mat-icon{width:20px;height:20px;font-size:20px}:host:not([hidden]) .bui-file-upload-list .bui-file-upload-item-name a{color:var(--bui-color-primary)}:host:not([hidden]) .bui-file-upload-list .bui-file-upload-item-name .text{margin-left:.5rem;margin-right:.5rem}:host:not([hidden]) .bui-file-upload-list .bui-file-upload-item-progress{flex-grow:1;min-width:50%;display:flex;justify-content:flex-start;align-items:center;margin:.5rem 0}:host:not([hidden]) .bui-file-upload-list .bui-file-upload-item-progress .mat-progress-bar{max-width:100%;height:.4rem;border-radius:1rem}:host:not([hidden]) .bui-file-upload-list .bui-file-upload-item-progress>span{margin-inline-start:.5rem}:host:not([hidden]) .bui-file-upload-list .bui-file-upload-item-action{display:flex;align-items:center;height:1em;width:1.75em}:host:not([hidden]) .bui-file-upload-list .mat-divider{margin:0 calc(1rem - 4px) 0 calc(1rem - 4px)}:host:not([hidden]) .upload-completed{animation:pulse 1s ease-in-out}@keyframes pulse{0%{transform:scaleY(1)}50%{transform:scaleY(1.5)}to{transform:scaleY(1)}}\n"], dependencies: [{ kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i3.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "directive", type: i4.IconDirective, selector: "[buiIcon]", inputs: ["buiIcon", "size", "variant"] }, { kind: "component", type: i5.MatProgressBar, selector: "mat-progress-bar", inputs: ["color", "value", "bufferValue", "mode"], outputs: ["animationEnd"], exportAs: ["matProgressBar"] }, { kind: "component", type: i6.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "component", type: i7.MatDivider, selector: "mat-divider", inputs: ["vertical", "inset"] }, { kind: "directive", type: i8.MatTooltip, selector: "[matTooltip]", exportAs: ["matTooltip"] }, { kind: "pipe", type: i2.PercentPipe, name: "percent" }], animations: [
|
|
346
388
|
trigger('slideOut', [
|
|
347
389
|
transition('* => *', [
|
|
348
390
|
query(':leave', stagger(100, animate('0.25s', style({ height: 0, overflow: 'hidden' }))), { optional: true })
|
|
@@ -362,7 +404,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.3", ngImpor
|
|
|
362
404
|
query(':leave', stagger(100, animate('0.25s', style({ height: 0, overflow: 'hidden' }))), { optional: true })
|
|
363
405
|
])
|
|
364
406
|
])
|
|
365
|
-
], template: "<div class=\"bui-file-upload-container\">\n\t<div\n\t\tclass=\"bui-file-upload-hint\"\n\t\t*ngIf=\"!_initialising && remaining > 0 && (!_itemAnimationInProgress || remaining > 1)\"\n\t>\n\t\t<ng-template [ngIf]=\"_invalidFilesDragged\" [ngIfElse]=\"validDnd\">\n\t\t\t<mat-icon [buiIcon]=\"'block'\" [size]=\"32\" color=\"warn\" variant=\"outlined\" style=\"opacity: 0.6\"></mat-icon>\n\t\t</ng-template>\n\t\t<ng-template #validDnd>\n\t\t\t<div *ngIf=\"!_overFrame && !_overDropZone\" class=\"bui-color-muted bui-upload-icon-link\" (click)=\"selectFiles()\">\n\t\t\t\t<mat-icon [buiIcon]=\"'fas fa-cloud-upload-alt'\" [size]=\"32\"></mat-icon>\n\t\t\t\t<a role=\"button\">{{ uploadActionText }}</a>\n\t\t\t</div>\n\t\t\t<div *ngIf=\"_overFrame && !_overDropZone\" class=\"bui-color-light\">{{ dragHint }}</div>\n\t\t\t<div *ngIf=\"_overDropZone\" class=\"bui-color-light\">{{ dropHint }}</div>\n\t\t</ng-template>\n\t</div>\n\t<div\n\t\tclass=\"bui-file-upload-list\"\n\t\t[@slideOut]=\"_uploadingItems.length\"\n\t\t(@slideOut.start)=\"_itemAnimationStart.next()\"\n\t\t(@slideOut.done)=\"_itemAnimationDone.next()\"\n\t\t*ngIf=\"_uploadingItems.length\"\n\t>\n\t\t<span class=\"bui-file-uploaded-label\">{{ fileUploadedLabel }}</span>\n\n\t\t<ng-container *ngFor=\"let item of _uploadingItems; let idx = index\">\n\t\t\t<div class=\"bui-file-upload-item\" [class.in-progress]=\"!item.done\" #itemDiv>\n\t\t\t\t<div class=\"bui-file-upload-item-name\">\n\t\t\t\t\t<span>\n\t\t\t\t\t\t<mat-icon class=\"bui-color-muted\">description</mat-icon>\n\t\t\t\t\t\t<a\n\t\t\t\t\t\t\tclass=\"text\"\n\t\t\t\t\t\t\t*ngIf=\"item.done && !item.downloading; else staticName\"\n\t\t\t\t\t\t\thref=\"#{{ item.uploadedItem?.id }}\"\n\t\t\t\t\t\t\t(click)=\"$event.preventDefault(); _openItem(item)\"\n\t\t\t\t\t\t\tcontextmenu=\"false\"\n\t\t\t\t\t\t\tmatTooltip=\"Download\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{{ item.name }}\n\t\t\t\t\t\t</a>\n\t\t\t\t\t\t<ng-template #staticName>\n\t\t\t\t\t\t\t<span class=\"text\">{{ item.name }}</span>\n\t\t\t\t\t\t</ng-template>\n\t\t\t\t\t</span>\n\t\t\t\t\t<div class=\"bui-file-upload-item-progress\">\n\t\t\t\t\t\t<mat-progress-bar\n\t\t\t\t\t\t\tmode=\"determinate\"\n\t\t\t\t\t\t\t[class.upload-completed]=\"item.done\"\n\t\t\t\t\t\t\t*ngIf=\"!item.downloading\"\n\t\t\t\t\t\t\t[value]=\"item.done ? 100 : item.progress * 100\"\n\t\t\t\t\t\t></mat-progress-bar>\n\t\t\t\t\t\t<mat-progress-bar mode=\"buffer\" *ngIf=\"item.downloading\"></mat-progress-bar>\n\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t<ng-template [ngIf]=\"item.done\" [ngIfElse]=\"inprogress\"> 100% </ng-template>\n\t\t\t\t\t\t\t<ng-template #inprogress>\n\t\t\t\t\t\t\t\t{{ item.progress | percent }}\n\t\t\t\t\t\t\t</ng-template>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t\t<div class=\"bui-file-upload-item-action\">\n\t\t\t\t\t<button\n\t\t\t\t\t\tmat-icon-button\n\t\t\t\t\t\tcolor=\"primary\"\n\t\t\t\t\t\t(click)=\"item.cancel()\"\n\t\t\t\t\t\t(mouseenter)=\"itemDiv.classList.add('bui-file-upload-item-deleting')\"\n\t\t\t\t\t\t(mouseleave)=\"itemDiv.classList.remove('bui-file-upload-item-deleting')\"\n\t\t\t\t\t\tmatTooltip=\"Delete\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<mat-icon [buiIcon]=\"'cancel'\" style=\"line-height: 0.9\"></mat-icon>\n\t\t\t\t\t</button>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t<mat-divider *ngIf=\"idx < _uploadingItems.length - 1\"></mat-divider>\n\t\t</ng-container>\n\t</div>\n\t<input\n\t\ttype=\"file\"\n\t\t#fileInput\n\t\tstyle=\"display: none\"\n\t\taccept=\"{{ _accept }}\"\n\t\t(change)=\"_handleFileSelection()\"\n\t\t[multiple]=\"remaining > 1\"\n\t/>\n</div>\n", styles: [":host:not([hidden]){display:block;border-style:dashed;border-width:1px;border-color:var(--bui-color-muted);transition:all .12s;padding:3px}:host:not([hidden]).bui-dnd-active,:host:not([hidden]).bui-dnd-over{padding:0;border-width:4px}:host:not([hidden]).bui-dnd-invalid{cursor:no-drop}:host:not([hidden]) .bui-file-upload-hint{margin:.5rem;height:40px;justify-content:center;display:flex;align-items:center}:host:not([hidden]) .bui-file-upload-container{min-height:4rem;display:flex;align-items:center;flex-direction:column;justify-content:center;transition:initial}:host:not([hidden]) .bui-file-upload-container .bui-upload-icon-link{cursor:pointer;transition:color .1s cubic-bezier(.55,0,.55,.2);display:flex;align-items:center}:host:not([hidden]) .bui-file-upload-container .bui-upload-icon-link:hover{color:var(--bui-color-light)!important}:host:not([hidden]) .bui-file-upload-container .bui-upload-icon-link>*{margin:4px}:host:not([hidden]) .bui-file-upload-list{align-self:stretch;margin-top:calc(1rem - 4px)}:host:not([hidden]) .bui-file-upload-list .bui-file-uploaded-label{display:block;font-size:smaller;margin:0 calc(1rem - 4px) .5rem calc(1rem - 4px)}:host:not([hidden]) .bui-file-upload-list .bui-file-upload-item{display:flex;align-items:center;margin:0 calc(1rem - 4px);padding:.25rem 0;justify-content:space-between}:host:not([hidden]) .bui-file-upload-list .bui-file-upload-item:last-child{margin-bottom:calc(.5rem - 4px)}:host:not([hidden]) .bui-file-upload-list .bui-file-upload-item.in-progress .bui-file-upload-item-name{font-style:italic}:host:not([hidden]) .bui-file-upload-list .bui-file-upload-item.bui-file-upload-item-deleting{background-color:#8080801a;transition:background-color .1s cubic-bezier(.55,0,.55,.2)}:host:not([hidden]) .bui-file-upload-list .bui-file-upload-item-name{flex-grow:1;font-size:80%;display:flex;align-items:center;flex-wrap:wrap}:host:not([hidden]) .bui-file-upload-list .bui-file-upload-item-name>span{word-break:break-all;display:flex;align-items:center}:host:not([hidden]) .bui-file-upload-list .bui-file-upload-item-name>span>mat-icon{width:20px;height:20px;font-size:20px}:host:not([hidden]) .bui-file-upload-list .bui-file-upload-item-name a{color:var(--bui-color-primary)}:host:not([hidden]) .bui-file-upload-list .bui-file-upload-item-name .text{margin-left:.5rem;margin-right:.5rem}:host:not([hidden]) .bui-file-upload-list .bui-file-upload-item-progress{flex-grow:1;min-width:50%;display:flex;justify-content:flex-start;align-items:center;margin:.5rem 0}:host:not([hidden]) .bui-file-upload-list .bui-file-upload-item-progress .mat-progress-bar{max-width:100%;height:.4rem;border-radius:1rem}:host:not([hidden]) .bui-file-upload-list .bui-file-upload-item-progress>span{margin-inline-start:.5rem}:host:not([hidden]) .bui-file-upload-list .bui-file-upload-item-action{display:flex;align-items:center;height:1em;width:1.75em}:host:not([hidden]) .bui-file-upload-list .mat-divider{margin:0 calc(1rem - 4px) 0 calc(1rem - 4px)}:host:not([hidden]) .upload-completed{animation:pulse 1s ease-in-out}@keyframes pulse{0%{transform:scaleY(1)}50%{transform:scaleY(1.5)}to{transform:scaleY(1)}}\n"] }]
|
|
407
|
+
], template: "<div class=\"bui-file-upload-container\">\n\t<div\n\t\tclass=\"bui-file-upload-hint\"\n\t\t*ngIf=\"!_initialising && remaining > 0 && (!_itemAnimationInProgress || remaining > 1)\"\n\t>\n\t\t<ng-template [ngIf]=\"_invalidFilesDragged\" [ngIfElse]=\"validDnd\">\n\t\t\t<mat-icon [buiIcon]=\"'block'\" [size]=\"32\" color=\"warn\" variant=\"outlined\" style=\"opacity: 0.6\"></mat-icon>\n\t\t</ng-template>\n\t\t<ng-template #validDnd>\n\t\t\t<div *ngIf=\"!_overFrame && !_overDropZone\" class=\"bui-color-muted bui-upload-icon-link\" (click)=\"selectFiles()\">\n\t\t\t\t<mat-icon [buiIcon]=\"'fas fa-cloud-upload-alt'\" [size]=\"32\"></mat-icon>\n\t\t\t\t<a role=\"button\">{{ uploadActionText }}</a>\n\t\t\t</div>\n\t\t\t<div *ngIf=\"_overFrame && !_overDropZone\" class=\"bui-color-light\">{{ dragHint }}</div>\n\t\t\t<div *ngIf=\"_overDropZone\" class=\"bui-color-light\">{{ dropHint }}</div>\n\t\t</ng-template>\n\t</div>\n\t<div\n\t\tclass=\"bui-file-upload-list\"\n\t\t[@slideOut]=\"_uploadingItems.length\"\n\t\t(@slideOut.start)=\"_itemAnimationStart.next()\"\n\t\t(@slideOut.done)=\"_itemAnimationDone.next()\"\n\t\t*ngIf=\"_uploadingItems.length\"\n\t>\n\t\t<span class=\"bui-file-uploaded-label\">{{ fileUploadedLabel }}</span>\n\n\t\t<ng-container *ngFor=\"let item of _uploadingItems; let idx = index\">\n\t\t\t<div class=\"bui-file-upload-item\" [class.in-progress]=\"!item.done\" #itemDiv>\n\t\t\t\t<div class=\"bui-file-upload-item-name\">\n\t\t\t\t\t<span>\n\t\t\t\t\t\t<mat-icon class=\"bui-color-muted\">description</mat-icon>\n\t\t\t\t\t\t<a\n\t\t\t\t\t\t\tclass=\"text\"\n\t\t\t\t\t\t\t*ngIf=\"item.done && !item.downloading; else staticName\"\n\t\t\t\t\t\t\thref=\"#{{ item.uploadedItem?.id }}\"\n\t\t\t\t\t\t\t(click)=\"$event.preventDefault(); _openItem(item)\"\n\t\t\t\t\t\t\tcontextmenu=\"false\"\n\t\t\t\t\t\t\tmatTooltip=\"Download\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{{ item.name }}\n\t\t\t\t\t\t</a>\n\t\t\t\t\t\t<ng-template #staticName>\n\t\t\t\t\t\t\t<span class=\"text\">{{ item.name }}</span>\n\t\t\t\t\t\t</ng-template>\n\t\t\t\t\t</span>\n\t\t\t\t\t<div class=\"bui-file-upload-item-progress\">\n\t\t\t\t\t\t<mat-progress-bar\n\t\t\t\t\t\t\tmode=\"determinate\"\n\t\t\t\t\t\t\t[class.upload-completed]=\"item.done\"\n\t\t\t\t\t\t\t*ngIf=\"!item.downloading\"\n\t\t\t\t\t\t\t[value]=\"item.done ? 100 : item.progress * 100\"\n\t\t\t\t\t\t></mat-progress-bar>\n\t\t\t\t\t\t<mat-progress-bar mode=\"buffer\" *ngIf=\"item.downloading\"></mat-progress-bar>\n\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t<ng-template [ngIf]=\"item.done\" [ngIfElse]=\"inprogress\"> 100% </ng-template>\n\t\t\t\t\t\t\t<ng-template #inprogress>\n\t\t\t\t\t\t\t\t{{ item.progress | percent }}\n\t\t\t\t\t\t\t</ng-template>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t\t<div class=\"bui-file-upload-item-action\">\n\t\t\t\t\t<button\n\t\t\t\t\t\tmat-icon-button\n\t\t\t\t\t\tcolor=\"primary\"\n\t\t\t\t\t\t(click)=\"item.cancel()\"\n\t\t\t\t\t\t(mouseenter)=\"itemDiv.classList.add('bui-file-upload-item-deleting')\"\n\t\t\t\t\t\t(mouseleave)=\"itemDiv.classList.remove('bui-file-upload-item-deleting')\"\n\t\t\t\t\t\tmatTooltip=\"Delete\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<mat-icon [buiIcon]=\"'cancel'\" style=\"line-height: 0.9\"></mat-icon>\n\t\t\t\t\t</button>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t<mat-divider *ngIf=\"idx < _uploadingItems.length - 1\"></mat-divider>\n\t\t</ng-container>\n\t</div>\n\t<input\n\t\ttype=\"file\"\n\t\t#fileInput\n\t\tstyle=\"display: none\"\n\t\taccept=\"{{ _accept }}\"\n\t\t(change)=\"_handleFileSelection()\"\n\t\t[multiple]=\"remaining > 1\"\n\t/>\n\n\t<div *ngIf=\"_fileSizeExceedMsg\" class=\"bui-color-warn bui-file-size-exceed\">\n\t\t<span> {{ _fileSizeExceedMsg }}</span> <mat-icon role=\"button\" (click)=\"_fileSizeExceedMsg = ''\">cancel</mat-icon>\n\t</div>\n</div>\n", styles: [":host:not([hidden]){display:block;border-style:dashed;border-width:1px;border-color:var(--bui-color-muted);transition:all .12s;padding:3px}:host:not([hidden]).bui-dnd-active,:host:not([hidden]).bui-dnd-over{padding:0;border-width:4px}:host:not([hidden]) .bui-file-size-exceed{display:flex;align-items:center;margin-bottom:1rem}:host:not([hidden]) .bui-file-size-exceed mat-icon{margin-left:.2rem}:host:not([hidden]).bui-dnd-invalid{cursor:no-drop}:host:not([hidden]) .bui-file-upload-hint{margin:.5rem;height:40px;justify-content:center;display:flex;align-items:center}:host:not([hidden]) .bui-file-upload-container{min-height:4rem;display:flex;align-items:center;flex-direction:column;justify-content:center;transition:initial}:host:not([hidden]) .bui-file-upload-container .bui-upload-icon-link{cursor:pointer;transition:color .1s cubic-bezier(.55,0,.55,.2);display:flex;align-items:center}:host:not([hidden]) .bui-file-upload-container .bui-upload-icon-link:hover{color:var(--bui-color-light)!important}:host:not([hidden]) .bui-file-upload-container .bui-upload-icon-link>*{margin:4px}:host:not([hidden]) .bui-file-upload-list{align-self:stretch;margin-top:calc(1rem - 4px)}:host:not([hidden]) .bui-file-upload-list .bui-file-uploaded-label{display:block;font-size:smaller;margin:0 calc(1rem - 4px) .5rem calc(1rem - 4px)}:host:not([hidden]) .bui-file-upload-list .bui-file-upload-item{display:flex;align-items:center;margin:0 calc(1rem - 4px);padding:.25rem 0;justify-content:space-between}:host:not([hidden]) .bui-file-upload-list .bui-file-upload-item:last-child{margin-bottom:calc(.5rem - 4px)}:host:not([hidden]) .bui-file-upload-list .bui-file-upload-item.in-progress .bui-file-upload-item-name{font-style:italic}:host:not([hidden]) .bui-file-upload-list .bui-file-upload-item.bui-file-upload-item-deleting{background-color:#8080801a;transition:background-color .1s cubic-bezier(.55,0,.55,.2)}:host:not([hidden]) .bui-file-upload-list .bui-file-upload-item-name{flex-grow:1;font-size:80%;display:flex;align-items:center;flex-wrap:wrap}:host:not([hidden]) .bui-file-upload-list .bui-file-upload-item-name>span{word-break:break-all;display:flex;align-items:center}:host:not([hidden]) .bui-file-upload-list .bui-file-upload-item-name>span>mat-icon{width:20px;height:20px;font-size:20px}:host:not([hidden]) .bui-file-upload-list .bui-file-upload-item-name a{color:var(--bui-color-primary)}:host:not([hidden]) .bui-file-upload-list .bui-file-upload-item-name .text{margin-left:.5rem;margin-right:.5rem}:host:not([hidden]) .bui-file-upload-list .bui-file-upload-item-progress{flex-grow:1;min-width:50%;display:flex;justify-content:flex-start;align-items:center;margin:.5rem 0}:host:not([hidden]) .bui-file-upload-list .bui-file-upload-item-progress .mat-progress-bar{max-width:100%;height:.4rem;border-radius:1rem}:host:not([hidden]) .bui-file-upload-list .bui-file-upload-item-progress>span{margin-inline-start:.5rem}:host:not([hidden]) .bui-file-upload-list .bui-file-upload-item-action{display:flex;align-items:center;height:1em;width:1.75em}:host:not([hidden]) .bui-file-upload-list .mat-divider{margin:0 calc(1rem - 4px) 0 calc(1rem - 4px)}:host:not([hidden]) .upload-completed{animation:pulse 1s ease-in-out}@keyframes pulse{0%{transform:scaleY(1)}50%{transform:scaleY(1.5)}to{transform:scaleY(1)}}\n"] }]
|
|
366
408
|
}], ctorParameters: function () { return [{ type: FileUploadService }]; }, propDecorators: { uploadActionText: [{
|
|
367
409
|
type: Input
|
|
368
410
|
}], fileUploadedLabel: [{
|
|
@@ -373,6 +415,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.3", ngImpor
|
|
|
373
415
|
type: Input
|
|
374
416
|
}], limit: [{
|
|
375
417
|
type: Input
|
|
418
|
+
}], fileSize: [{
|
|
419
|
+
type: Input
|
|
376
420
|
}], types: [{
|
|
377
421
|
type: Input
|
|
378
422
|
}], _fileInput: [{
|