@sd-angular/core 1.0.33 → 1.0.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/sd-angular-core-common.umd.js +20 -2
- package/bundles/sd-angular-core-common.umd.js.map +1 -1
- package/bundles/sd-angular-core-common.umd.min.js +1 -1
- package/bundles/sd-angular-core-common.umd.min.js.map +1 -1
- package/bundles/sd-angular-core-input-currency.umd.js +40 -40
- package/bundles/sd-angular-core-input-currency.umd.js.map +1 -1
- package/bundles/sd-angular-core-input-currency.umd.min.js +2 -2
- package/bundles/sd-angular-core-input-currency.umd.min.js.map +1 -1
- package/bundles/sd-angular-core-notify.umd.js +10 -9
- package/bundles/sd-angular-core-notify.umd.js.map +1 -1
- package/bundles/sd-angular-core-notify.umd.min.js +2 -2
- package/bundles/sd-angular-core-notify.umd.min.js.map +1 -1
- package/bundles/sd-angular-core-select.umd.js +1 -2
- package/bundles/sd-angular-core-select.umd.js.map +1 -1
- package/bundles/sd-angular-core-select.umd.min.js +2 -2
- package/bundles/sd-angular-core-select.umd.min.js.map +1 -1
- package/common/sd-angular-core-common.metadata.json +1 -1
- package/common/src/lib/directives/sd-suffix.directive.d.ts +5 -0
- package/common/src/public-api.d.ts +1 -0
- package/esm2015/common/src/lib/common.module.js +6 -3
- package/esm2015/common/src/lib/directives/sd-suffix.directive.js +15 -0
- package/esm2015/common/src/public-api.js +2 -1
- package/esm2015/input-currency/src/lib/input-currency.component.js +42 -42
- package/esm2015/input-currency/src/lib/input-currency.module.js +3 -1
- package/esm2015/notify/src/lib/notify.service.js +10 -8
- package/esm2015/select/src/lib/select.component.js +2 -3
- package/fesm2015/sd-angular-core-common.js +19 -3
- package/fesm2015/sd-angular-core-common.js.map +1 -1
- package/fesm2015/sd-angular-core-input-currency.js +42 -42
- package/fesm2015/sd-angular-core-input-currency.js.map +1 -1
- package/fesm2015/sd-angular-core-notify.js +9 -7
- package/fesm2015/sd-angular-core-notify.js.map +1 -1
- package/fesm2015/sd-angular-core-select.js +1 -2
- package/fesm2015/sd-angular-core-select.js.map +1 -1
- package/input-currency/sd-angular-core-input-currency.metadata.json +1 -1
- package/input-currency/src/lib/input-currency.component.d.ts +6 -6
- package/notify/sd-angular-core-notify.metadata.json +1 -1
- package/package.json +1 -1
- package/{sd-angular-core-1.0.33.tgz → sd-angular-core-1.0.36.tgz} +0 -0
- package/select/sd-angular-core-select.metadata.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EventEmitter, Component, ChangeDetectorRef, Input, Output, ViewChild, Pipe, NgModule } from '@angular/core';
|
|
1
|
+
import { EventEmitter, Component, ChangeDetectorRef, Input, Output, ContentChild, ViewChild, Pipe, NgModule } from '@angular/core';
|
|
2
2
|
import { CommonModule } from '@angular/common';
|
|
3
3
|
import { MatIconModule } from '@angular/material/icon';
|
|
4
4
|
import { MatTooltipModule } from '@angular/material/tooltip';
|
|
@@ -7,29 +7,28 @@ import { Validators, NgForm, FormsModule, ReactiveFormsModule } from '@angular/f
|
|
|
7
7
|
import { v4 } from 'uuid';
|
|
8
8
|
import { debounceTime } from 'rxjs/operators';
|
|
9
9
|
import { Subscription } from 'rxjs';
|
|
10
|
-
import { SdFormControl } from '@sd-angular/core/common';
|
|
10
|
+
import { SdFormControl, SdSuffixDirective, SdCommonModule } from '@sd-angular/core/common';
|
|
11
11
|
import { MatInputModule } from '@angular/material/input';
|
|
12
12
|
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
13
13
|
import { SdTranslateModule } from '@sd-angular/core/translate';
|
|
14
14
|
import { NgxCurrencyModule } from 'ngx-currency';
|
|
15
15
|
|
|
16
|
-
var _name, _form, _model, _align, _allowNegative, _decimal, _precision, _prefix, _suffix, _thousands, _nullable, _min, _max, _pattern, _validator, _subscription, _updateValidator, _onChange, _customValidator;
|
|
16
|
+
var _name, _form, _model, _align, _allowNegative, _decimal, _precision, _prefix, _suffix, _thousands, _nullable, _min, _max, _pattern, _validator, _subscription, _generateOption, _updateValidator, _onChange, _customValidator;
|
|
17
17
|
class SdInputCurrency {
|
|
18
18
|
constructor(ref) {
|
|
19
19
|
this.ref = ref;
|
|
20
20
|
_name.set(this, v4());
|
|
21
21
|
this.disableErrorMessage = false;
|
|
22
22
|
_form.set(this, void 0);
|
|
23
|
-
this.step = 0.01;
|
|
24
23
|
_model.set(this, void 0);
|
|
25
24
|
this.modelChange = new EventEmitter();
|
|
26
|
-
_align.set(this,
|
|
27
|
-
_allowNegative.set(this,
|
|
28
|
-
_decimal.set(this,
|
|
29
|
-
_precision.set(this,
|
|
25
|
+
_align.set(this, 'right');
|
|
26
|
+
_allowNegative.set(this, true);
|
|
27
|
+
_decimal.set(this, ',');
|
|
28
|
+
_precision.set(this, 0);
|
|
30
29
|
_prefix.set(this, void 0);
|
|
31
30
|
_suffix.set(this, void 0);
|
|
32
|
-
_thousands.set(this,
|
|
31
|
+
_thousands.set(this, '.');
|
|
33
32
|
_nullable.set(this, void 0);
|
|
34
33
|
_min.set(this, void 0);
|
|
35
34
|
_max.set(this, void 0);
|
|
@@ -43,6 +42,20 @@ class SdInputCurrency {
|
|
|
43
42
|
this.formControl = new SdFormControl();
|
|
44
43
|
_subscription.set(this, new Subscription());
|
|
45
44
|
this.options = {};
|
|
45
|
+
_generateOption.set(this, () => {
|
|
46
|
+
this.options = {
|
|
47
|
+
align: __classPrivateFieldGet(this, _align) || '',
|
|
48
|
+
allowNegative: __classPrivateFieldGet(this, _allowNegative),
|
|
49
|
+
decimal: __classPrivateFieldGet(this, _decimal),
|
|
50
|
+
precision: __classPrivateFieldGet(this, _precision),
|
|
51
|
+
prefix: __classPrivateFieldGet(this, _prefix) || '',
|
|
52
|
+
suffix: __classPrivateFieldGet(this, _suffix) || '',
|
|
53
|
+
thousands: __classPrivateFieldGet(this, _thousands),
|
|
54
|
+
nullable: __classPrivateFieldGet(this, _nullable),
|
|
55
|
+
min: __classPrivateFieldGet(this, _min),
|
|
56
|
+
max: __classPrivateFieldGet(this, _max)
|
|
57
|
+
};
|
|
58
|
+
});
|
|
46
59
|
this.reValidate = () => {
|
|
47
60
|
this.formControl.updateValueAndValidity();
|
|
48
61
|
};
|
|
@@ -133,44 +146,44 @@ class SdInputCurrency {
|
|
|
133
146
|
}
|
|
134
147
|
}
|
|
135
148
|
set align(val) {
|
|
136
|
-
__classPrivateFieldSet(this, _align, val);
|
|
137
|
-
this.
|
|
149
|
+
__classPrivateFieldSet(this, _align, val || 'right');
|
|
150
|
+
__classPrivateFieldGet(this, _generateOption).call(this);
|
|
138
151
|
}
|
|
139
152
|
set allowNegative(val) {
|
|
140
|
-
__classPrivateFieldSet(this, _allowNegative, val);
|
|
141
|
-
this.
|
|
153
|
+
__classPrivateFieldSet(this, _allowNegative, (val === '') || val);
|
|
154
|
+
__classPrivateFieldGet(this, _generateOption).call(this);
|
|
142
155
|
}
|
|
143
156
|
set decimal(val) {
|
|
144
|
-
__classPrivateFieldSet(this, _decimal, val);
|
|
145
|
-
this.
|
|
157
|
+
__classPrivateFieldSet(this, _decimal, val || ',');
|
|
158
|
+
__classPrivateFieldGet(this, _generateOption).call(this);
|
|
146
159
|
}
|
|
147
160
|
set precision(val) {
|
|
148
|
-
__classPrivateFieldSet(this, _precision, val);
|
|
149
|
-
this.
|
|
161
|
+
__classPrivateFieldSet(this, _precision, val || 0);
|
|
162
|
+
__classPrivateFieldGet(this, _generateOption).call(this);
|
|
150
163
|
}
|
|
151
164
|
set prefix(val) {
|
|
152
165
|
__classPrivateFieldSet(this, _prefix, val);
|
|
153
|
-
this.
|
|
166
|
+
__classPrivateFieldGet(this, _generateOption).call(this);
|
|
154
167
|
}
|
|
155
168
|
set suffix(val) {
|
|
156
169
|
__classPrivateFieldSet(this, _suffix, val);
|
|
157
|
-
this.
|
|
170
|
+
__classPrivateFieldGet(this, _generateOption).call(this);
|
|
158
171
|
}
|
|
159
172
|
set thousands(val) {
|
|
160
|
-
__classPrivateFieldSet(this, _thousands, val);
|
|
161
|
-
this.
|
|
173
|
+
__classPrivateFieldSet(this, _thousands, val || '.');
|
|
174
|
+
__classPrivateFieldGet(this, _generateOption).call(this);
|
|
162
175
|
}
|
|
163
176
|
set nullable(val) {
|
|
164
177
|
__classPrivateFieldSet(this, _nullable, val);
|
|
165
|
-
this.
|
|
178
|
+
__classPrivateFieldGet(this, _generateOption).call(this);
|
|
166
179
|
}
|
|
167
180
|
set min(val) {
|
|
168
181
|
__classPrivateFieldSet(this, _min, val);
|
|
169
|
-
this.
|
|
182
|
+
__classPrivateFieldGet(this, _generateOption).call(this);
|
|
170
183
|
}
|
|
171
184
|
set max(val) {
|
|
172
185
|
__classPrivateFieldSet(this, _max, val);
|
|
173
|
-
this.
|
|
186
|
+
__classPrivateFieldGet(this, _generateOption).call(this);
|
|
174
187
|
}
|
|
175
188
|
set required(val) {
|
|
176
189
|
this.isRequired = (val === '') || val;
|
|
@@ -198,21 +211,7 @@ class SdInputCurrency {
|
|
|
198
211
|
__classPrivateFieldGet(this, _subscription).add(this.formControl.touchedChanges.subscribe(() => {
|
|
199
212
|
this.ref.markForCheck();
|
|
200
213
|
}));
|
|
201
|
-
this.
|
|
202
|
-
}
|
|
203
|
-
getOptions() {
|
|
204
|
-
this.options = {
|
|
205
|
-
align: __classPrivateFieldGet(this, _align) || '',
|
|
206
|
-
allowNegative: __classPrivateFieldGet(this, _allowNegative),
|
|
207
|
-
decimal: __classPrivateFieldGet(this, _decimal) || '.',
|
|
208
|
-
precision: __classPrivateFieldGet(this, _precision) || 0,
|
|
209
|
-
prefix: __classPrivateFieldGet(this, _prefix) || '',
|
|
210
|
-
suffix: __classPrivateFieldGet(this, _suffix) || '',
|
|
211
|
-
thousands: __classPrivateFieldGet(this, _thousands) || ',',
|
|
212
|
-
nullable: __classPrivateFieldGet(this, _nullable),
|
|
213
|
-
min: __classPrivateFieldGet(this, _min),
|
|
214
|
-
max: __classPrivateFieldGet(this, _max)
|
|
215
|
-
};
|
|
214
|
+
__classPrivateFieldGet(this, _generateOption).call(this);
|
|
216
215
|
}
|
|
217
216
|
ngAfterViewInit() {
|
|
218
217
|
var _a;
|
|
@@ -226,11 +225,11 @@ class SdInputCurrency {
|
|
|
226
225
|
__classPrivateFieldGet(this, _subscription).unsubscribe();
|
|
227
226
|
}
|
|
228
227
|
}
|
|
229
|
-
_name = new WeakMap(), _form = new WeakMap(), _model = new WeakMap(), _align = new WeakMap(), _allowNegative = new WeakMap(), _decimal = new WeakMap(), _precision = new WeakMap(), _prefix = new WeakMap(), _suffix = new WeakMap(), _thousands = new WeakMap(), _nullable = new WeakMap(), _min = new WeakMap(), _max = new WeakMap(), _pattern = new WeakMap(), _validator = new WeakMap(), _subscription = new WeakMap(), _updateValidator = new WeakMap(), _onChange = new WeakMap(), _customValidator = new WeakMap();
|
|
228
|
+
_name = new WeakMap(), _form = new WeakMap(), _model = new WeakMap(), _align = new WeakMap(), _allowNegative = new WeakMap(), _decimal = new WeakMap(), _precision = new WeakMap(), _prefix = new WeakMap(), _suffix = new WeakMap(), _thousands = new WeakMap(), _nullable = new WeakMap(), _min = new WeakMap(), _max = new WeakMap(), _pattern = new WeakMap(), _validator = new WeakMap(), _subscription = new WeakMap(), _generateOption = new WeakMap(), _updateValidator = new WeakMap(), _onChange = new WeakMap(), _customValidator = new WeakMap();
|
|
230
229
|
SdInputCurrency.decorators = [
|
|
231
230
|
{ type: Component, args: [{
|
|
232
231
|
selector: 'sd-input-currency',
|
|
233
|
-
template: "<div class=\"d-flex align-items-center\">\r\n <mat-form-field class=\"sd-md\"
|
|
232
|
+
template: "<div class=\"d-flex align-items-center\">\r\n <mat-form-field class=\"sd-md\"\r\n [ngClass]=\"{'sd-form-tooltip':tooltip, 'sd-sm': size === 'sm', 'no-padding-wrapper': disableErrorMessage}\"\r\n appearance=\"outline\">\r\n <mat-label *ngIf=\"label\">{{label}}</mat-label>\r\n <input currencyMask [options]=\"options\" [formControl]=\"formControl\" #control matInput\r\n [placeholder]=\"placeholder || label\" (keyup.enter)=\"onKeyupEnter()\" (focus)=\"onFocus()\" [required]=\"isRequired\"\r\n autocomplete=\"off\">\r\n <ng-container *ngIf=\"sdSuffix?.templateRef\" matSuffix>\r\n <ng-container *ngTemplateOutlet=\"sdSuffix.templateRef\">\r\n </ng-container>\r\n </ng-container>\r\n <mat-error *ngIf=\"formControl.errors?.required && !disableErrorMessage\">\r\n {{'This field is required' | sdTranslate}}\r\n </mat-error>\r\n <mat-error *ngIf=\"formControl.errors?.pattern && !disableErrorMessage\">\r\n {{'Pattern error' | sdTranslate}}\r\n </mat-error>\r\n <mat-error *ngIf=\"formControl.errors?.customValidator && !disableErrorMessage\">\r\n <strong>{{formControl.errors?.customValidator}}</strong>\r\n </mat-error>\r\n </mat-form-field>\r\n <div *ngIf=\"tooltip\" class=\"sd-tooltip\">\r\n <mat-icon (click)=\"sdTooltip.toggle()\" [matTooltip]=\"formControl.value | sdInputCurrencyTooltipPipe:tooltip\"\r\n matSuffix #sdTooltip=\"matTooltip\">info</mat-icon>\r\n </div>\r\n</div>",
|
|
234
233
|
styles: [":host ::ng-deep .mat-form-field.sd-form-tooltip{width:calc(100% - 30px)}.sd-tooltip{display:inline-block;margin:auto;text-align:center;width:30px}:host{display:block;padding-top:5px}:host ::ng-deep .mat-form-field.no-padding-wrapper .mat-form-field-wrapper{padding-bottom:0}:host ::ng-deep .mat-form-field.mat-form-field-appearance-outline.mat-form-field-disabled .mat-form-field-outline{background:#f6f6f6;color:#e9e9e9}:host ::ng-deep .mat-form-field input.mat-input-element:disabled{color:#4d4d4d!important}:host ::ng-deep .mat-form-field .mat-placeholder-required{color:#f82c13}"]
|
|
235
234
|
},] }
|
|
236
235
|
];
|
|
@@ -244,7 +243,6 @@ SdInputCurrency.propDecorators = {
|
|
|
244
243
|
form: [{ type: Input }],
|
|
245
244
|
label: [{ type: Input }],
|
|
246
245
|
placeholder: [{ type: Input }],
|
|
247
|
-
step: [{ type: Input }],
|
|
248
246
|
model: [{ type: Input }],
|
|
249
247
|
modelChange: [{ type: Output }],
|
|
250
248
|
align: [{ type: Input }],
|
|
@@ -261,6 +259,7 @@ SdInputCurrency.propDecorators = {
|
|
|
261
259
|
pattern: [{ type: Input }],
|
|
262
260
|
validator: [{ type: Input }],
|
|
263
261
|
disabled: [{ type: Input }],
|
|
262
|
+
sdSuffix: [{ type: ContentChild, args: [SdSuffixDirective,] }],
|
|
264
263
|
tooltip: [{ type: Input }],
|
|
265
264
|
sdChange: [{ type: Output }],
|
|
266
265
|
sdFocus: [{ type: Output }],
|
|
@@ -294,6 +293,7 @@ SdInputCurrencyModule.decorators = [
|
|
|
294
293
|
MatInputModule,
|
|
295
294
|
MatIconModule,
|
|
296
295
|
MatTooltipModule,
|
|
296
|
+
SdCommonModule,
|
|
297
297
|
SdTranslateModule,
|
|
298
298
|
NgxCurrencyModule
|
|
299
299
|
],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sd-angular-core-input-currency.js","sources":["../../../../projects/sd-core/input-currency/src/lib/input-currency.component.ts","../../../../projects/sd-core/input-currency/src/lib/input-currency-tooltip.pipe.ts","../../../../projects/sd-core/input-currency/src/lib/input-currency.module.ts","../../../../projects/sd-core/input-currency/src/public-api.ts","../../../../projects/sd-core/input-currency/sd-angular-core-input-currency.ts"],"sourcesContent":["import {\r\n Component,\r\n Input,\r\n ViewChild,\r\n Output,\r\n EventEmitter,\r\n ChangeDetectorRef,\r\n OnDestroy,\r\n AfterViewInit,\r\n ElementRef,\r\n OnInit\r\n} from '@angular/core';\r\nimport { AbstractControl, FormControl, NgForm, ValidatorFn, Validators, AsyncValidatorFn, FormGroup } from '@angular/forms';\r\nimport * as uuid from 'uuid';\r\nimport { debounceTime, startWith } from 'rxjs/operators';\r\nimport { Subscription } from 'rxjs';\r\nimport { SdFormControl } from '@sd-angular/core/common';\r\n\r\n@Component({\r\n selector: 'sd-input-currency',\r\n templateUrl: './input-currency.component.html',\r\n styleUrls: ['./input-currency.component.scss']\r\n})\r\nexport class SdInputCurrency implements OnDestroy, OnInit, AfterViewInit {\r\n #name = uuid.v4();\r\n @Input() set name(val: string) {\r\n if (val) {\r\n this.#name = val;\r\n }\r\n }\r\n disableErrorMessage = false;\r\n @Input('disableErrorMessage') set _disableErrorMessage(val: boolean | '') {\r\n this.disableErrorMessage = (val === '') || val;\r\n val = (val === '') || val;\r\n }\r\n @Input() size: 'sm' | 'lg';\r\n #form: FormGroup;\r\n @Input() set form(val: NgForm | FormGroup) {\r\n if (val) {\r\n if (val instanceof NgForm) {\r\n this.#form = val.form;\r\n } else {\r\n this.#form = val;\r\n }\r\n }\r\n }\r\n @Input() label: string;\r\n @Input() placeholder: string;\r\n @Input() step = 0.01;\r\n\r\n #model: any;\r\n @Input() set model(value: any) {\r\n if (this.#model !== value) {\r\n this.#model = value;\r\n this.formControl.setValue(value);\r\n this.ref.detectChanges();\r\n }\r\n }\r\n\r\n @Output() modelChange = new EventEmitter();\r\n\r\n #align: string;\r\n @Input() set align(val: string | '') {\r\n this.#align = val;\r\n this.getOptions();\r\n }\r\n\r\n #allowNegative: boolean;\r\n @Input() set allowNegative(val: boolean | false) {\r\n this.#allowNegative = val;\r\n this.getOptions();\r\n }\r\n\r\n #decimal: string;\r\n @Input() set decimal(val: string | '') {\r\n this.#decimal = val;\r\n this.getOptions();\r\n }\r\n\r\n #precision: number;\r\n @Input() set precision(val: number) {\r\n this.#precision = val;\r\n this.getOptions();\r\n }\r\n\r\n #prefix: string;\r\n @Input() set prefix(val: string) {\r\n this.#prefix = val;\r\n this.getOptions();\r\n }\r\n\r\n #suffix: string;\r\n @Input() set suffix(val: string) {\r\n this.#suffix = val;\r\n this.getOptions();\r\n }\r\n\r\n #thousands: string;\r\n @Input() set thousands(val: string) {\r\n this.#thousands = val;\r\n this.getOptions();\r\n }\r\n\r\n #nullable: boolean;\r\n @Input() set nullable(val: boolean | false) {\r\n this.#nullable = val;\r\n this.getOptions();\r\n }\r\n\r\n #min: number;\r\n @Input() set min(val: number) {\r\n this.#min = val;\r\n this.getOptions();\r\n }\r\n\r\n #max: number;\r\n @Input() set max(val: number) {\r\n this.#max = val;\r\n this.getOptions();\r\n }\r\n\r\n // Validator\r\n isRequired = false;\r\n @Input() set required(val: boolean | '') {\r\n this.isRequired = (val === '') || val;\r\n this.#updateValidator();\r\n }\r\n\r\n #pattern: string;\r\n @Input() set pattern(val: string) {\r\n this.#pattern = val;\r\n this.#updateValidator();\r\n }\r\n #validator: (value: any) => string | Promise<string>;\r\n @Input() set validator(validator: (value: any) => string | Promise<string>) {\r\n this.#validator = validator;\r\n this.#updateValidator();\r\n }\r\n\r\n // Optional\r\n @Input() set disabled(val: boolean | '') {\r\n val = (val === '') || val;\r\n if (val) {\r\n this.formControl.disable();\r\n } else {\r\n this.formControl.enable();\r\n }\r\n }\r\n @Input() tooltip: string | ((inputValue: string) => string);\r\n @Output() sdChange = new EventEmitter<any>();\r\n @Output() sdFocus = new EventEmitter<any>();\r\n @Output() keyupEnter = new EventEmitter();\r\n\r\n @ViewChild('control') control: ElementRef;\r\n formControl = new SdFormControl();\r\n #subscription = new Subscription();\r\n options = {};\r\n constructor(private ref: ChangeDetectorRef) {\r\n }\r\n\r\n ngOnInit() {\r\n this.#subscription.add(this.formControl.touchedChanges.subscribe(() => {\r\n this.ref.markForCheck();\r\n }));\r\n this.getOptions();\r\n }\r\n\r\n getOptions() {\r\n this.options = {\r\n align: this.#align || '',\r\n allowNegative: this.#allowNegative,\r\n decimal: this.#decimal || '.',\r\n precision: this.#precision || 0,\r\n prefix: this.#prefix || '',\r\n suffix: this.#suffix || '',\r\n thousands: this.#thousands || ',',\r\n nullable: this.#nullable,\r\n min: this.#min,\r\n max: this.#max\r\n }\r\n }\r\n\r\n ngAfterViewInit() {\r\n this.#subscription.add(this.formControl.valueChanges.pipe(debounceTime(200)).subscribe(this.#onChange));\r\n this.#form?.addControl(this.#name, this.formControl);\r\n this.ref.detectChanges();\r\n }\r\n\r\n ngOnDestroy() {\r\n this.#form?.removeControl(this.#name);\r\n this.#subscription.unsubscribe();\r\n }\r\n\r\n reValidate = () => {\r\n this.formControl.updateValueAndValidity();\r\n }\r\n\r\n #updateValidator = () => {\r\n this.formControl.clearValidators();\r\n this.formControl.clearAsyncValidators();\r\n const validators: ValidatorFn[] = [];\r\n const asyncValidators: AsyncValidatorFn[] = [];\r\n if (this.isRequired) {\r\n validators.push(Validators.required);\r\n }\r\n if (this.#pattern) {\r\n validators.push(Validators.pattern(this.#pattern));\r\n }\r\n if (this.#validator) {\r\n asyncValidators.push(this.#customValidator(this.#validator));\r\n }\r\n this.formControl.setValidators(validators);\r\n this.formControl.setAsyncValidators(asyncValidators);\r\n this.formControl.updateValueAndValidity();\r\n }\r\n\r\n #onChange = async (value: any) => {\r\n this.modelChange.emit(value);\r\n this.sdChange.emit(value);\r\n }\r\n\r\n onKeyupEnter = () => {\r\n this.keyupEnter.emit(this.formControl.value);\r\n }\r\n\r\n onFocus = () => {\r\n this.sdFocus.emit();\r\n }\r\n\r\n onBlur = () => {\r\n const val: string = (this.formControl.value ?? '').toString();\r\n if (val.length > val.trim().length) {\r\n this.formControl.setValue(val.trim());\r\n }\r\n }\r\n\r\n #customValidator = (func: (value: any) => string | Promise<string>): AsyncValidatorFn => {\r\n return async (c: AbstractControl): Promise<{ [key: string]: any } | null> => {\r\n const value = c.value || null;\r\n if (func && typeof (func) === 'function') {\r\n const result = func(value);\r\n if (result instanceof Promise) {\r\n const message = await result;\r\n if (message) {\r\n return {\r\n customValidator: message\r\n };\r\n }\r\n return null;\r\n }\r\n if (result) {\r\n return {\r\n customValidator: result\r\n };\r\n }\r\n return null;\r\n }\r\n return null;\r\n };\r\n }\r\n}\r\n","import { Pipe, PipeTransform } from '@angular/core';\r\n@Pipe({\r\n name: 'sdInputCurrencyTooltipPipe'\r\n})\r\nexport class SdInputCurrencyTooltipPipe implements PipeTransform {\r\n transform(value: any, tooltip: string | ((inputValue: string) => string)): string {\r\n if (typeof (tooltip) === 'string') {\r\n return tooltip;\r\n }\r\n return tooltip(value);\r\n }\r\n}\r\n","import { NgModule } from '@angular/core';\r\nimport { CommonModule } from '@angular/common';\r\nimport { MatIconModule } from '@angular/material/icon';\r\nimport { MatTooltipModule } from '@angular/material/tooltip';\r\nimport { SdInputCurrency } from './input-currency.component';\r\nimport { MatInputModule } from '@angular/material/input';\r\nimport { MatFormFieldModule } from '@angular/material/form-field';\r\nimport { SdTranslateModule } from '@sd-angular/core/translate';\r\nimport { FormsModule, ReactiveFormsModule } from '@angular/forms';\r\nimport { SdInputCurrencyTooltipPipe } from './input-currency-tooltip.pipe';\r\nimport { NgxCurrencyModule } from \"ngx-currency\";\r\n\r\n@NgModule({\r\n imports: [\r\n CommonModule,\r\n FormsModule,\r\n ReactiveFormsModule,\r\n MatFormFieldModule,\r\n MatInputModule,\r\n MatIconModule,\r\n MatTooltipModule,\r\n SdTranslateModule,\r\n NgxCurrencyModule\r\n ],\r\n declarations: [\r\n SdInputCurrency,\r\n SdInputCurrencyTooltipPipe\r\n ],\r\n exports: [\r\n SdInputCurrency,\r\n SdInputCurrencyTooltipPipe\r\n ]\r\n})\r\nexport class SdInputCurrencyModule { }\r\n","/*\r\n * Public API Surface of superdev-angular-core\r\n */\r\n\r\nexport * from './lib/input-currency.module';\r\nexport * from './lib/input-currency-tooltip.pipe';\r\nexport * from './lib/input-currency.component';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["uuid.v4"],"mappings":";;;;;;;;;;;;;;;;MAuBa,eAAe;IAsI1B,YAAoB,GAAsB;QAAtB,QAAG,GAAH,GAAG,CAAmB;QArI1C,gBAAQA,EAAO,EAAE,EAAC;QAMlB,wBAAmB,GAAG,KAAK,CAAC;QAM5B,wBAAiB;QAYR,SAAI,GAAG,IAAI,CAAC;QAErB,yBAAY;QASF,gBAAW,GAAG,IAAI,YAAY,EAAE,CAAC;QAE3C,yBAAe;QAMf,iCAAwB;QAMxB,2BAAiB;QAMjB,6BAAmB;QAMnB,0BAAgB;QAMhB,0BAAgB;QAMhB,6BAAmB;QAMnB,4BAAmB;QAMnB,uB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AE;YACjC,OAAO,OAAO,CAAC;SAChB;QACD,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC;KACvB;;;YATF,IAAI,SAAC;gBACJ,IAAI,EAAE,4BAA4B;aACnC;;;MC8BY,qBAAqB;;;YArBjC,QAAQ,SAAC;gBACR,OAAO,EAAE;oBACP,YAAY;oBACZ,WAAW;oBACX,mBAAmB;oBACnB,kBAAkB;oBAClB,cAAc;oBACd,aAAa;oBACb,gBAAgB;oBAChB,iBAAiB;oBACjB,iBAAiB;iBAClB;gBACD,YAAY,EAAE;oBACZ,eAAe;oBACf,0BAA0B;iBAC3B;gBACD,OAAO,EAAE;oBACP,eAAe;oBACf,0BAA0B;iBAC3B;aACF;;;AChCD;;;;ACAA;;;;;;"}
|
|
1
|
+
{"version":3,"file":"sd-angular-core-input-currency.js","sources":["../../../../projects/sd-core/input-currency/src/lib/input-currency.component.ts","../../../../projects/sd-core/input-currency/src/lib/input-currency-tooltip.pipe.ts","../../../../projects/sd-core/input-currency/src/lib/input-currency.module.ts","../../../../projects/sd-core/input-currency/src/public-api.ts","../../../../projects/sd-core/input-currency/sd-angular-core-input-currency.ts"],"sourcesContent":["import {\r\n Component,\r\n Input,\r\n ViewChild,\r\n Output,\r\n EventEmitter,\r\n ChangeDetectorRef,\r\n OnDestroy,\r\n AfterViewInit,\r\n ElementRef,\r\n OnInit,\r\n ContentChild\r\n} from '@angular/core';\r\nimport { AbstractControl, FormControl, NgForm, ValidatorFn, Validators, AsyncValidatorFn, FormGroup } from '@angular/forms';\r\nimport * as uuid from 'uuid';\r\nimport { debounceTime, startWith } from 'rxjs/operators';\r\nimport { Subscription } from 'rxjs';\r\nimport { SdFormControl } from '@sd-angular/core/common';\r\nimport { SdSuffixDirective } from '@sd-angular/core/common';\r\n\r\n@Component({\r\n selector: 'sd-input-currency',\r\n templateUrl: './input-currency.component.html',\r\n styleUrls: ['./input-currency.component.scss']\r\n})\r\nexport class SdInputCurrency implements OnDestroy, OnInit, AfterViewInit {\r\n #name = uuid.v4();\r\n @Input() set name(val: string) {\r\n if (val) {\r\n this.#name = val;\r\n }\r\n }\r\n disableErrorMessage = false;\r\n @Input('disableErrorMessage') set _disableErrorMessage(val: boolean | '') {\r\n this.disableErrorMessage = (val === '') || val;\r\n val = (val === '') || val;\r\n }\r\n @Input() size: 'sm' | 'lg';\r\n #form: FormGroup;\r\n @Input() set form(val: NgForm | FormGroup) {\r\n if (val) {\r\n if (val instanceof NgForm) {\r\n this.#form = val.form;\r\n } else {\r\n this.#form = val;\r\n }\r\n }\r\n }\r\n @Input() label: string;\r\n @Input() placeholder: string;\r\n\r\n #model: any;\r\n @Input() set model(value: any) {\r\n if (this.#model !== value) {\r\n this.#model = value;\r\n this.formControl.setValue(value);\r\n this.ref.detectChanges();\r\n }\r\n }\r\n\r\n @Output() modelChange = new EventEmitter();\r\n\r\n #align: 'left' | 'right' = 'right';\r\n @Input() set align(val: 'left' | 'right' | '') {\r\n this.#align = val || 'right';\r\n this.#generateOption();\r\n }\r\n\r\n #allowNegative = true;\r\n @Input() set allowNegative(val: boolean | '') {\r\n this.#allowNegative = (val === '') || val;\r\n this.#generateOption();\r\n }\r\n\r\n #decimal: '.' | ',' = ',';\r\n @Input() set decimal(val: '.' | ',' | '') {\r\n this.#decimal = val || ',';\r\n this.#generateOption();\r\n }\r\n\r\n #precision: number = 0;\r\n @Input() set precision(val: number) {\r\n this.#precision = val || 0;\r\n this.#generateOption();\r\n }\r\n\r\n #prefix: string;\r\n @Input() set prefix(val: string) {\r\n this.#prefix = val;\r\n this.#generateOption();\r\n }\r\n\r\n #suffix: string;\r\n @Input() set suffix(val: string) {\r\n this.#suffix = val;\r\n this.#generateOption();\r\n }\r\n\r\n #thousands: '.' | ',' = '.';\r\n @Input() set thousands(val: '.' | ',' | '') {\r\n this.#thousands = val || '.';\r\n this.#generateOption();\r\n }\r\n\r\n #nullable: boolean;\r\n @Input() set nullable(val: boolean | false) {\r\n this.#nullable = val;\r\n this.#generateOption();\r\n }\r\n\r\n #min: number;\r\n @Input() set min(val: number) {\r\n this.#min = val;\r\n this.#generateOption();\r\n }\r\n\r\n #max: number;\r\n @Input() set max(val: number) {\r\n this.#max = val;\r\n this.#generateOption();\r\n }\r\n\r\n // Validator\r\n isRequired = false;\r\n @Input() set required(val: boolean | '') {\r\n this.isRequired = (val === '') || val;\r\n this.#updateValidator();\r\n }\r\n\r\n #pattern: string;\r\n @Input() set pattern(val: string) {\r\n this.#pattern = val;\r\n this.#updateValidator();\r\n }\r\n #validator: (value: any) => string | Promise<string>;\r\n @Input() set validator(validator: (value: any) => string | Promise<string>) {\r\n this.#validator = validator;\r\n this.#updateValidator();\r\n }\r\n\r\n // Optional\r\n @Input() set disabled(val: boolean | '') {\r\n val = (val === '') || val;\r\n if (val) {\r\n this.formControl.disable();\r\n } else {\r\n this.formControl.enable();\r\n }\r\n }\r\n @ContentChild(SdSuffixDirective) sdSuffix: SdSuffixDirective;\r\n @Input() tooltip: string | ((inputValue: string) => string);\r\n @Output() sdChange = new EventEmitter<any>();\r\n @Output() sdFocus = new EventEmitter<any>();\r\n @Output() keyupEnter = new EventEmitter();\r\n\r\n @ViewChild('control') control: ElementRef;\r\n formControl = new SdFormControl();\r\n #subscription = new Subscription();\r\n options = {};\r\n constructor(private ref: ChangeDetectorRef) {\r\n }\r\n\r\n ngOnInit() {\r\n this.#subscription.add(this.formControl.touchedChanges.subscribe(() => {\r\n this.ref.markForCheck();\r\n }));\r\n this.#generateOption();\r\n }\r\n\r\n #generateOption = () => {\r\n this.options = {\r\n align: this.#align || '',\r\n allowNegative: this.#allowNegative,\r\n decimal: this.#decimal,\r\n precision: this.#precision,\r\n prefix: this.#prefix || '',\r\n suffix: this.#suffix || '',\r\n thousands: this.#thousands,\r\n nullable: this.#nullable,\r\n min: this.#min,\r\n max: this.#max\r\n }\r\n }\r\n\r\n ngAfterViewInit() {\r\n this.#subscription.add(this.formControl.valueChanges.pipe(debounceTime(200)).subscribe(this.#onChange));\r\n this.#form?.addControl(this.#name, this.formControl);\r\n this.ref.detectChanges();\r\n }\r\n\r\n ngOnDestroy() {\r\n this.#form?.removeControl(this.#name);\r\n this.#subscription.unsubscribe();\r\n }\r\n\r\n reValidate = () => {\r\n this.formControl.updateValueAndValidity();\r\n }\r\n\r\n #updateValidator = () => {\r\n this.formControl.clearValidators();\r\n this.formControl.clearAsyncValidators();\r\n const validators: ValidatorFn[] = [];\r\n const asyncValidators: AsyncValidatorFn[] = [];\r\n if (this.isRequired) {\r\n validators.push(Validators.required);\r\n }\r\n if (this.#pattern) {\r\n validators.push(Validators.pattern(this.#pattern));\r\n }\r\n if (this.#validator) {\r\n asyncValidators.push(this.#customValidator(this.#validator));\r\n }\r\n this.formControl.setValidators(validators);\r\n this.formControl.setAsyncValidators(asyncValidators);\r\n this.formControl.updateValueAndValidity();\r\n }\r\n\r\n #onChange = async (value: any) => {\r\n this.modelChange.emit(value);\r\n this.sdChange.emit(value);\r\n }\r\n\r\n onKeyupEnter = () => {\r\n this.keyupEnter.emit(this.formControl.value);\r\n }\r\n\r\n onFocus = () => {\r\n this.sdFocus.emit();\r\n }\r\n\r\n onBlur = () => {\r\n const val: string = (this.formControl.value ?? '').toString();\r\n if (val.length > val.trim().length) {\r\n this.formControl.setValue(val.trim());\r\n }\r\n }\r\n\r\n #customValidator = (func: (value: any) => string | Promise<string>): AsyncValidatorFn => {\r\n return async (c: AbstractControl): Promise<{ [key: string]: any } | null> => {\r\n const value = c.value || null;\r\n if (func && typeof (func) === 'function') {\r\n const result = func(value);\r\n if (result instanceof Promise) {\r\n const message = await result;\r\n if (message) {\r\n return {\r\n customValidator: message\r\n };\r\n }\r\n return null;\r\n }\r\n if (result) {\r\n return {\r\n customValidator: result\r\n };\r\n }\r\n return null;\r\n }\r\n return null;\r\n };\r\n }\r\n}\r\n","import { Pipe, PipeTransform } from '@angular/core';\r\n@Pipe({\r\n name: 'sdInputCurrencyTooltipPipe'\r\n})\r\nexport class SdInputCurrencyTooltipPipe implements PipeTransform {\r\n transform(value: any, tooltip: string | ((inputValue: string) => string)): string {\r\n if (typeof (tooltip) === 'string') {\r\n return tooltip;\r\n }\r\n return tooltip(value);\r\n }\r\n}\r\n","import { NgModule } from '@angular/core';\r\nimport { CommonModule } from '@angular/common';\r\nimport { MatIconModule } from '@angular/material/icon';\r\nimport { MatTooltipModule } from '@angular/material/tooltip';\r\nimport { SdInputCurrency } from './input-currency.component';\r\nimport { MatInputModule } from '@angular/material/input';\r\nimport { MatFormFieldModule } from '@angular/material/form-field';\r\nimport { SdTranslateModule } from '@sd-angular/core/translate';\r\nimport { FormsModule, ReactiveFormsModule } from '@angular/forms';\r\nimport { SdInputCurrencyTooltipPipe } from './input-currency-tooltip.pipe';\r\nimport { NgxCurrencyModule } from \"ngx-currency\";\r\nimport { SdCommonModule } from '@sd-angular/core/common';\r\n\r\n@NgModule({\r\n imports: [\r\n CommonModule,\r\n FormsModule,\r\n ReactiveFormsModule,\r\n MatFormFieldModule,\r\n MatInputModule,\r\n MatIconModule,\r\n MatTooltipModule,\r\n SdCommonModule,\r\n SdTranslateModule,\r\n NgxCurrencyModule\r\n ],\r\n declarations: [\r\n SdInputCurrency,\r\n SdInputCurrencyTooltipPipe\r\n ],\r\n exports: [\r\n SdInputCurrency,\r\n SdInputCurrencyTooltipPipe\r\n ]\r\n})\r\nexport class SdInputCurrencyModule { }\r\n","/*\r\n * Public API Surface of superdev-angular-core\r\n */\r\n\r\nexport * from './lib/input-currency.module';\r\nexport * from './lib/input-currency-tooltip.pipe';\r\nexport * from './lib/input-currency.component';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["uuid.v4"],"mappings":";;;;;;;;;;;;;;;;MAyBa,eAAe;IAsI1B,YAAoB,GAAsB;QAAtB,QAAG,GAAH,GAAG,CAAmB;QArI1C,gBAAQA,EAAO,EAAE,EAAC;QAMlB,wBAAmB,GAAG,KAAK,CAAC;QAM5B,wBAAiB;QAajB,yBAAY;QASF,gBAAW,GAAG,IAAI,YAAY,E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BAOL,KAAK;sBAML,KAAK;wBAKL,KAAK;uBAML,KAAK;uBAQL,YAAY,SAAC,iBAAiB;sBAC9B,KAAK;uBACL,MAAM;sBACN,MAAM;yBACN,MAAM;sBAEN,SAAS,SAAC,SAAS;;;MCvJT,0BAA0B;IACrC,SAAS,CAAC,KAAU,EAAE,OAAkD;QACtE,IAAI,QAAQ,OAAO,CAAC,KAAK,QAAQ,EAAE;YACjC,OAAO,OAAO,CAAC;SAChB;QACD,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC;KACvB;;;YATF,IAAI,SAAC;gBACJ,IAAI,EAAE,4BAA4B;aACnC;;;MCgCY,qBAAqB;;;YAtBjC,QAAQ,SAAC;gBACR,OAAO,EAAE;oBACP,YAAY;oBACZ,WAAW;oBACX,mBAAmB;oBACnB,kBAAkB;oBAClB,cAAc;oBACd,aAAa;oBACb,gBAAgB;oBAChB,cAAc;oBACd,iBAAiB;oBACjB,iBAAiB;iBAClB;gBACD,YAAY,EAAE;oBACZ,eAAe;oBACf,0BAA0B;iBAC3B;gBACD,OAAO,EAAE;oBACP,eAAe;oBACf,0BAA0B;iBAC3B;aACF;;;AClCD;;;;ACAA;;;;;;"}
|
|
@@ -12,6 +12,7 @@ import { __classPrivateFieldGet } from 'tslib';
|
|
|
12
12
|
import '@sd-angular/core/common';
|
|
13
13
|
import { SdTranslateService } from '@sd-angular/core/translate';
|
|
14
14
|
import { takeUntil } from 'rxjs/operators';
|
|
15
|
+
import { v4 } from 'uuid';
|
|
15
16
|
|
|
16
17
|
class DialogConfirmComponent {
|
|
17
18
|
constructor(dialogRef, data) {
|
|
@@ -35,14 +36,15 @@ DialogConfirmComponent.ctorParameters = () => [
|
|
|
35
36
|
{ type: undefined, decorators: [{ type: Inject, args: [MAT_DIALOG_DATA,] }] }
|
|
36
37
|
];
|
|
37
38
|
|
|
38
|
-
var
|
|
39
|
+
var _delayDuration, _cache, _buildToastMultiMesssage;
|
|
39
40
|
let notifyId = 0;
|
|
40
41
|
class SdNotifyService {
|
|
41
42
|
constructor(dialog, toastr, translateService) {
|
|
42
43
|
this.dialog = dialog;
|
|
43
44
|
this.toastr = toastr;
|
|
44
45
|
this.translateService = translateService;
|
|
45
|
-
|
|
46
|
+
_delayDuration.set(this, 500); // Các error/warning message sẽ tự động gộp sau khoảng thời gian trên
|
|
47
|
+
_cache.set(this, {});
|
|
46
48
|
this.alert = {
|
|
47
49
|
info: (message, title, yesTitle, icon) => {
|
|
48
50
|
this.dialog.open(DialogConfirmComponent, {
|
|
@@ -143,19 +145,19 @@ class SdNotifyService {
|
|
|
143
145
|
_buildToastMultiMesssage.set(this, (type, messages, delay, title) => {
|
|
144
146
|
/** số lượng item hiển thị mặc định */
|
|
145
147
|
const showNum = 2;
|
|
146
|
-
const id =
|
|
148
|
+
const id = `sd-notify-ckb-${v4()}`;
|
|
147
149
|
const messageLength = messages.length;
|
|
148
150
|
const messageRests = messages.splice(showNum);
|
|
149
151
|
const messageContainer = `<ul class="sd-notify__list">{0}{1}</ul>`;
|
|
150
152
|
const messageTemp = `<li class="sd-notify__item">- {0}</li>`;
|
|
151
153
|
let contentRest = '';
|
|
152
154
|
if (messageRests === null || messageRests === void 0 ? void 0 : messageRests.length) {
|
|
153
|
-
contentRest = `<input id="
|
|
154
|
-
<label class="sd-notify__text sd-notify__text--show text-secondary" for="
|
|
155
|
+
contentRest = `<input id="${id}" class="cdk-visually-hidden sd-notify__checkbox" type="checkbox" />
|
|
156
|
+
<label class="sd-notify__text sd-notify__text--show text-secondary" for="${id}">${this.translate('Show more')}</label>
|
|
155
157
|
<div class="sd-notify__item--rest">
|
|
156
158
|
${messageRests.map(m => String.format(messageTemp, m)).join('')}
|
|
157
159
|
</div>
|
|
158
|
-
<label class="sd-notify__text sd-notify__text--less text-secondary" for="
|
|
160
|
+
<label class="sd-notify__text sd-notify__text--less text-secondary" for="${id}">${this.translate('Show less')}</label>`;
|
|
159
161
|
}
|
|
160
162
|
const content = String.format(messageContainer, messages.map(m => String.format(messageTemp, m)).join(''), contentRest);
|
|
161
163
|
let toast;
|
|
@@ -281,7 +283,7 @@ class SdNotifyService {
|
|
|
281
283
|
};
|
|
282
284
|
}
|
|
283
285
|
}
|
|
284
|
-
|
|
286
|
+
_delayDuration = new WeakMap(), _cache = new WeakMap(), _buildToastMultiMesssage = new WeakMap();
|
|
285
287
|
SdNotifyService.decorators = [
|
|
286
288
|
{ type: Injectable }
|
|
287
289
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sd-angular-core-notify.js","sources":["../../../../projects/sd-core/notify/src/lib/components/dialog-confirm/dialog-confirm.component.ts","../../../../projects/sd-core/notify/src/lib/notify.service.ts","../../../../projects/sd-core/notify/src/lib/notify.module.ts","../../../../projects/sd-core/notify/src/public-api.ts","../../../../projects/sd-core/notify/sd-angular-core-notify.ts"],"sourcesContent":["import { Component, Inject } from \"@angular/core\";\r\nimport { MatDialogRef, MAT_DIALOG_DATA } from \"@angular/material/dialog\";\r\n\r\nexport interface DialogData {\r\n icon?: string;\r\n title?: string;\r\n message?: string;\r\n yesTitle?: string;\r\n noTitle?: string;\r\n yesButtonColor?: string;\r\n noButtonColor?: string;\r\n input?: {\r\n placeholder?: string;\r\n minlength?: number;\r\n maxlength?: number;\r\n required?: boolean;\r\n defaultValue?: string;\r\n };\r\n}\r\n\r\n@Component({\r\n selector: \"sd-dialog-confirm\",\r\n templateUrl: \"dialog-confirm.component.html\",\r\n styleUrls: [\"./dialog-confirm.component.css\"],\r\n})\r\nexport class DialogConfirmComponent {\r\n value: string;\r\n isString = false;\r\n constructor(\r\n public dialogRef: MatDialogRef<DialogConfirmComponent>,\r\n @Inject(MAT_DIALOG_DATA) public data: DialogData\r\n ) {\r\n this.isString = typeof this.data?.message === \"string\";\r\n this.value = data?.input?.defaultValue ?? '';\r\n }\r\n}\r\n","import \"@sd-angular/core/common\";\r\nimport { Injectable } from \"@angular/core\";\r\nimport { MatDialog } from \"@angular/material/dialog\";\r\nimport { DialogConfirmComponent } from \"./components/dialog-confirm/dialog-confirm.component\";\r\nimport { ActiveToast, ToastrService } from \"ngx-toastr\";\r\nimport { SdTranslateService } from \"@sd-angular/core/translate\";\r\nimport { takeUntil } from \"rxjs/operators\";\r\n\r\nlet notifyId = 0;\r\n\r\n@Injectable()\r\nexport class SdNotifyService {\r\n #cacheDuration = 2000; // 2s\r\n constructor(\r\n private dialog: MatDialog,\r\n private toastr: ToastrService,\r\n private translateService: SdTranslateService\r\n ) {}\r\n\r\n alert = {\r\n info: (\r\n message?: string,\r\n title?: string,\r\n yesTitle?: string,\r\n icon?: string\r\n ) => {\r\n this.dialog.open(DialogConfirmComponent, {\r\n width: \"400px\",\r\n data: {\r\n icon: icon || \"info\",\r\n title: title || this.translate(\"Notice\"),\r\n message: message || \"Done!\",\r\n yesTitle: yesTitle || this.translate(\"Ok\"),\r\n },\r\n });\r\n },\r\n success: (\r\n message?: string,\r\n title?: string,\r\n yesTitle?: string,\r\n icon?: string\r\n ) => {\r\n this.dialog.open(DialogConfirmComponent, {\r\n width: \"400px\",\r\n data: {\r\n icon: icon || \"done\",\r\n title: title || this.translate(\"Success\"),\r\n message: message || \"Done!\",\r\n yesTitle: yesTitle || this.translate(\"Ok\"),\r\n },\r\n });\r\n },\r\n warning: (\r\n message?: string,\r\n title?: string,\r\n yesTitle?: string,\r\n icon?: string\r\n ) => {\r\n this.dialog.open(DialogConfirmComponent, {\r\n width: \"400px\",\r\n data: {\r\n icon: icon || \"warning\",\r\n title: title || this.translate(\"Warning\"),\r\n message: message || \"Something went wrong!\",\r\n yesTitle: yesTitle || this.translate(\"Ok\"),\r\n },\r\n });\r\n },\r\n error: (\r\n message?: string,\r\n title?: string,\r\n yesTitle?: string,\r\n icon?: string\r\n ) => {\r\n this.dialog.open(DialogConfirmComponent, {\r\n width: \"400px\",\r\n data: {\r\n icon: icon || \"error\",\r\n title: title || this.translate(\"Error\"),\r\n message: message || \"Something went wrong!\",\r\n yesTitle: yesTitle || this.translate(\"Ok\"),\r\n },\r\n });\r\n },\r\n };\r\n\r\n notify = {\r\n success: (message?: string, delay?: number, title?: string) => {\r\n // tslint:disable-next-line: max-line-length\r\n // const style = `border-radius: 5px; margin: 0; padding: 12px; z-index: 99999; top: 5px; right: 5px; display: none; position: fixed;color: #4F8A10; background-color: #DFF2BF`;\r\n // tslint:disable-next-line: max-line-length\r\n // const html = `<div id=\"${this.notifyId}\" style=\"${style}\"><i class=\"fa fa-check\"></i> ${message || this.translate('Success')}</div>`;\r\n // this.showNotify(html, delay);\r\n const content = message || this.translate(\"Success\");\r\n this.toastr.success(content, title, {\r\n enableHtml: true,\r\n timeOut: delay || 3000,\r\n closeButton: true,\r\n });\r\n },\r\n warning: (message?: string | string[], delay?: number, title?: string) => {\r\n // tslint:disable-next-line: max-line-length\r\n // const style = `border-radius: 5px; margin: 0; padding: 12px; z-index: 99999; top: 5px; right: 5px; display: none; position: fixed;color: #9F6000; background-color: #FEEFB3`;\r\n // tslint:disable-next-line: max-line-length\r\n // const html = `<div id=\"${this.notifyId}\" style=\"${style}\"><i class=\"fa fa-exclamation-triangle\"></i> ${message || this.translate('Warning')}</div>`;\r\n // this.showNotify(html, delay);\r\n if (Array.isArray(message)){\r\n this.#buildToastMultiMesssage('warning', message, delay, title);\r\n }\r\n else {\r\n const content = message || this.translate(\"Warning\");\r\n this.toastr.warning(content, title, {\r\n enableHtml: true,\r\n timeOut: delay || 3000,\r\n closeButton: true,\r\n });\r\n }\r\n },\r\n error: (message?: string | string[], delay?: number, title?: string) => {\r\n // tslint:disable-next-line: max-line-length\r\n // const style = `border-radius: 5px; margin: 0; padding: 12px; z-index: 99999; top: 5px; right: 5px; display: none; position: fixed;color: #D8000C; background-color: #FFD2D2`;\r\n // tslint:disable-next-line: max-line-length\r\n // const html = `<div id=\"${this.notifyId}\" style=\"${style}\"><i class=\"fa fa-times\"></i> ${message || this.translate('Error')}</div>`;\r\n // this.showNotify(html, delay);\r\n if (Array.isArray(message)){\r\n this.#buildToastMultiMesssage('error', message, delay, title);\r\n }\r\n else {\r\n const content = message || this.translate(\"Error\");\r\n this.toastr.error(content, title, {\r\n enableHtml: true,\r\n timeOut: delay || 3000,\r\n closeButton: true,\r\n });\r\n }\r\n },\r\n };\r\n\r\n #buildToastMultiMesssage = (type: 'warning' | 'error', messages: string[], delay?: number, title?: string) => {\r\n /** số lượng item hiển thị mặc định */\r\n const showNum = 2;\r\n const id = notifyId++;\r\n const messageLength = messages.length;\r\n const messageRests = messages.splice(showNum);\r\n const messageContainer = `<ul class=\"sd-notify__list\">{0}{1}</ul>`;\r\n const messageTemp = `<li class=\"sd-notify__item\">- {0}</li>`;\r\n let contentRest = '';\r\n if (messageRests?.length) {\r\n contentRest = `<input id=\"sd-notify-ckb-${id}\" class=\"cdk-visually-hidden sd-notify__checkbox\" type=\"checkbox\" />\r\n <label class=\"sd-notify__text sd-notify__text--show text-secondary\" for=\"sd-notify-ckb-${id}\">${this.translate('Show more')}</label>\r\n <div class=\"sd-notify__item--rest\">\r\n ${messageRests.map(m => String.format(messageTemp, m)).join('')}\r\n </div>\r\n <label class=\"sd-notify__text sd-notify__text--less text-secondary\" for=\"sd-notify-ckb-${id}\">${this.translate('Show less')}</label>`;\r\n }\r\n const content = String.format(messageContainer, messages.map(m => String.format(messageTemp, m)).join(''), contentRest);\r\n let toast: ActiveToast<any>;\r\n // khi truyền message html sẽ bị sanitize nên phải truyền innerHTML khi toast hiện lên\r\n // @see https://github.com/scttcper/ngx-toastr/blob/v12.1.0/src/lib/toastr/toastr.service.ts#L271\r\n switch (type) {\r\n case 'error':\r\n toast = this.toastr.error(content, `${title || this.translate('Error')} (${messageLength})`, {\r\n enableHtml: true,\r\n timeOut: delay || 3000,\r\n messageClass: `toast-message toast-message-${id}`,\r\n closeButton: true,\r\n tapToDismiss: false\r\n });\r\n break;\r\n case 'warning':\r\n toast = this.toastr.warning(content, `${title || this.translate('Warning')} (${messageLength})`, {\r\n enableHtml: true,\r\n timeOut: delay || 3000,\r\n messageClass: `toast-message toast-message-${id}`,\r\n closeButton: true,\r\n tapToDismiss: false\r\n });\r\n break;\r\n }\r\n \r\n if (toast) {\r\n toast.onShown\r\n .pipe(\r\n takeUntil(toast.onHidden)\r\n )\r\n .subscribe(() => {\r\n const messageEle: HTMLDivElement = document.querySelector(`.toast-message-${id}`);\r\n messageEle.innerHTML = content;\r\n })\r\n }\r\n }\r\n\r\n handle = {\r\n error: (err: any) => {\r\n if (typeof err === \"string\") {\r\n this.notify.warning(err);\r\n } else if (typeof err === \"object\") {\r\n let message =\r\n err?.error ||\r\n err?.message ||\r\n err?.ExceptionMessage ||\r\n err?.Message ||\r\n \"Unknown error\";\r\n if (typeof err.json === \"function\") {\r\n err = err.json();\r\n if (err) {\r\n message =\r\n err?.error ||\r\n err?.message ||\r\n err?.ExceptionMessage ||\r\n err?.Message ||\r\n \"Unknown error\";\r\n }\r\n }\r\n this.notify.warning(message);\r\n } else {\r\n this.notify.warning(\"Unknown error\");\r\n }\r\n },\r\n };\r\n\r\n confirm = (\r\n message: string,\r\n option: {\r\n title?: string;\r\n yesTitle?: string;\r\n noTitle?: string;\r\n yesButtonColor?: string;\r\n noButtonColor?: string;\r\n } = {}\r\n ) => {\r\n const dialogRef = this.dialog.open(DialogConfirmComponent, {\r\n width: \"400px\",\r\n data: {\r\n title: option?.title || this.translate(\"Confirm\"),\r\n message,\r\n yesTitle: option?.yesTitle || this.translate(\"Yes\"),\r\n noTitle: option?.noTitle || this.translate(\"No\"),\r\n noButtonColor: option?.noButtonColor || \"secondary\",\r\n yesButtonColor: option?.yesButtonColor || \"primary\",\r\n },\r\n });\r\n return new Promise((resolve, reject) => {\r\n dialogRef.afterClosed().subscribe((result) => {\r\n if (result) {\r\n if (result === \"ACCEPT\") {\r\n resolve(null);\r\n } else if (result === \"CANCEL\") {\r\n reject(result);\r\n } else {\r\n resolve(null);\r\n }\r\n }\r\n });\r\n });\r\n };\r\n\r\n confirmDelete = () => this.confirm(this.translate(\"Delete record(s)\"));\r\n\r\n confirmApprove = () => this.confirm(this.translate(\"Approve record(s)\"));\r\n\r\n confirmWithInput = (\r\n title: string,\r\n option: {\r\n message?: string;\r\n yesTitle?: string;\r\n noTitle?: string;\r\n required?: boolean;\r\n maxlength?: number;\r\n yesButtonColor?: string;\r\n noButtonColor?: string;\r\n defaultValue?: string;\r\n } = {}\r\n ): Promise<string> => {\r\n const dialogRef = this.dialog.open(DialogConfirmComponent, {\r\n width: \"400px\",\r\n data: {\r\n title: title || this.translate(\"Confirm\"),\r\n message: option?.message,\r\n yesTitle: option?.yesTitle || this.translate(\"Yes\"),\r\n noTitle: option?.noTitle || this.translate(\"No\"),\r\n noButtonColor: option?.noButtonColor || \"secondary\",\r\n yesButtonColor: option?.yesButtonColor || \"primary\",\r\n input: {\r\n maxlength: option?.maxlength || 255,\r\n required: option?.required,\r\n defaultValue: option?.defaultValue || ''\r\n },\r\n },\r\n });\r\n return new Promise((resolve, reject) => {\r\n dialogRef.afterClosed().subscribe((result) => {\r\n if (result) {\r\n if (result === \"ACCEPT\") {\r\n resolve(result);\r\n } else if (result === \"CANCEL\") {\r\n reject(result);\r\n } else {\r\n resolve(result);\r\n }\r\n }\r\n });\r\n });\r\n };\r\n\r\n private translate = (value: string): string => {\r\n return this.translateService.translate(value);\r\n };\r\n}\r\n","import { NgModule } from \"@angular/core\";\r\nimport { CommonModule } from \"@angular/common\";\r\nimport { MatDialogModule } from \"@angular/material/dialog\";\r\nimport { MatIconModule } from \"@angular/material/icon\";\r\nimport { MatButtonModule } from \"@angular/material/button\";\r\nimport { MatFormFieldModule } from \"@angular/material/form-field\";\r\nimport { MatInputModule } from \"@angular/material/input\";\r\nimport { FormsModule } from \"@angular/forms\";\r\nimport { ToastrService, ToastrModule } from \"ngx-toastr\";\r\nimport { SdButtonModule } from \"@sd-angular/core/button\";\r\n\r\nimport { SdNotifyService } from \"./notify.service\";\r\nimport { DialogConfirmComponent } from \"./components/dialog-confirm/dialog-confirm.component\";\r\n\r\n@NgModule({\r\n imports: [\r\n CommonModule,\r\n FormsModule,\r\n MatFormFieldModule,\r\n MatInputModule,\r\n MatIconModule,\r\n MatButtonModule,\r\n MatDialogModule,\r\n ToastrModule.forRoot(),\r\n\r\n SdButtonModule,\r\n ],\r\n declarations: [DialogConfirmComponent],\r\n entryComponents: [DialogConfirmComponent],\r\n exports: [],\r\n providers: [SdNotifyService],\r\n})\r\nexport class SdNotifyModule {}\r\n","/*\r\n * Public API Surface of superdev-angular-core\r\n */\r\n\r\nexport { SdNotifyModule } from './lib/notify.module';\r\nexport * from './lib/notify.service';\r\nexport * from './lib/components/dialog-confirm/dialog-confirm.component';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;MAyBa,sBAAsB;IAGjC,YACS,SAA+C,EACtB,IAAgB;;QADzC,cAAS,GAAT,SAAS,CAAsC;QACtB,SAAI,GAAJ,IAAI,CAAY;QAHlD,aAAQ,GAAG,KAAK,CAAC;QAKf,IAAI,CAAC,QAAQ,GAAG,cAAO,IAAI,CAAC,IAAI,0CAAE,OAAO,CAAA,KAAK,QAAQ,CAAC;QACvD,IAAI,CAAC,KAAK,eAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,KAAK,0CAAE,YAAY,mCAAI,EAAE,CAAC;KAC9C;;;YAdF,SAAS,SAAC;gBACT,QAAQ,EAAE,mBAAmB;gBAC7B,m+CAA4C;;aAE7C;;;YAvBQ,YAAY;4CA6BhB,MAAM,SAAC,eAAe;;;;ACtB3B,IAAI,QAAQ,GAAG,CAAC,CAAC;MAGJ,eAAe;IAE1B,YACU,MAAiB,EACjB,MAAqB,EACrB,gBAAoC;QAFpC,WAAM,GAAN,MAAM,CAAW;QACjB,WAAM,GAAN,MAAM,CAAe;QACrB,qBAAgB,GAAhB,gBAAgB,CAAoB;QAJ9C,yBAAiB,IAAI,EAAC;QAOtB,UAAK,GAAG;YACN,IAAI,EAAE,CACJ,OAAgB,EAChB,KAAc,EACd,QAAiB,EACjB,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AO,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;SAC/C,CAAC;KAlSE;;;;YAPL,UAAU;;;YARF,SAAS;YAEI,aAAa;YAC1B,kBAAkB;;;MC2Bd,cAAc;;;YAlB1B,QAAQ,SAAC;gBACR,OAAO,EAAE;oBACP,YAAY;oBACZ,WAAW;oBACX,kBAAkB;oBAClB,cAAc;oBACd,aAAa;oBACb,eAAe;oBACf,eAAe;oBACf,YAAY,CAAC,OAAO,EAAE;oBAEtB,cAAc;iBACf;gBACD,YAAY,EAAE,CAAC,sBAAsB,CAAC;gBACtC,eAAe,EAAE,CAAC,sBAAsB,CAAC;gBACzC,OAAO,EAAE,EAAE;gBACX,SAAS,EAAE,CAAC,eAAe,CAAC;aAC7B;;;AC/BD;;;;ACAA;;;;;;"}
|
|
1
|
+
{"version":3,"file":"sd-angular-core-notify.js","sources":["../../../../projects/sd-core/notify/src/lib/components/dialog-confirm/dialog-confirm.component.ts","../../../../projects/sd-core/notify/src/lib/notify.service.ts","../../../../projects/sd-core/notify/src/lib/notify.module.ts","../../../../projects/sd-core/notify/src/public-api.ts","../../../../projects/sd-core/notify/sd-angular-core-notify.ts"],"sourcesContent":["import { Component, Inject } from \"@angular/core\";\r\nimport { MatDialogRef, MAT_DIALOG_DATA } from \"@angular/material/dialog\";\r\n\r\nexport interface DialogData {\r\n icon?: string;\r\n title?: string;\r\n message?: string;\r\n yesTitle?: string;\r\n noTitle?: string;\r\n yesButtonColor?: string;\r\n noButtonColor?: string;\r\n input?: {\r\n placeholder?: string;\r\n minlength?: number;\r\n maxlength?: number;\r\n required?: boolean;\r\n defaultValue?: string;\r\n };\r\n}\r\n\r\n@Component({\r\n selector: \"sd-dialog-confirm\",\r\n templateUrl: \"dialog-confirm.component.html\",\r\n styleUrls: [\"./dialog-confirm.component.css\"],\r\n})\r\nexport class DialogConfirmComponent {\r\n value: string;\r\n isString = false;\r\n constructor(\r\n public dialogRef: MatDialogRef<DialogConfirmComponent>,\r\n @Inject(MAT_DIALOG_DATA) public data: DialogData\r\n ) {\r\n this.isString = typeof this.data?.message === \"string\";\r\n this.value = data?.input?.defaultValue ?? '';\r\n }\r\n}\r\n","import \"@sd-angular/core/common\";\r\nimport { Injectable } from \"@angular/core\";\r\nimport { MatDialog } from \"@angular/material/dialog\";\r\nimport { DialogConfirmComponent } from \"./components/dialog-confirm/dialog-confirm.component\";\r\nimport { ActiveToast, ToastrService } from \"ngx-toastr\";\r\nimport { SdTranslateService } from \"@sd-angular/core/translate\";\r\nimport { takeUntil } from \"rxjs/operators\";\r\nimport { Subject } from \"rxjs\";\r\nimport * as uuid from 'uuid';\r\n\r\nlet notifyId = 0;\r\n\r\n@Injectable()\r\nexport class SdNotifyService {\r\n #delayDuration = 500; // Các error/warning message sẽ tự động gộp sau khoảng thời gian trên\r\n #cache: {\r\n [key: string]: {\r\n createdDate: Date;\r\n subject: Subject<any>;\r\n response?: {\r\n status?: 'success' | 'error';\r\n result: any,\r\n }\r\n }\r\n } = {};\r\n constructor(\r\n private dialog: MatDialog,\r\n private toastr: ToastrService,\r\n private translateService: SdTranslateService\r\n ) {}\r\n\r\n alert = {\r\n info: (\r\n message?: string,\r\n title?: string,\r\n yesTitle?: string,\r\n icon?: string\r\n ) => {\r\n this.dialog.open(DialogConfirmComponent, {\r\n width: \"400px\",\r\n data: {\r\n icon: icon || \"info\",\r\n title: title || this.translate(\"Notice\"),\r\n message: message || \"Done!\",\r\n yesTitle: yesTitle || this.translate(\"Ok\"),\r\n },\r\n });\r\n },\r\n success: (\r\n message?: string,\r\n title?: string,\r\n yesTitle?: string,\r\n icon?: string\r\n ) => {\r\n this.dialog.open(DialogConfirmComponent, {\r\n width: \"400px\",\r\n data: {\r\n icon: icon || \"done\",\r\n title: title || this.translate(\"Success\"),\r\n message: message || \"Done!\",\r\n yesTitle: yesTitle || this.translate(\"Ok\"),\r\n },\r\n });\r\n },\r\n warning: (\r\n message?: string,\r\n title?: string,\r\n yesTitle?: string,\r\n icon?: string\r\n ) => {\r\n this.dialog.open(DialogConfirmComponent, {\r\n width: \"400px\",\r\n data: {\r\n icon: icon || \"warning\",\r\n title: title || this.translate(\"Warning\"),\r\n message: message || \"Something went wrong!\",\r\n yesTitle: yesTitle || this.translate(\"Ok\"),\r\n },\r\n });\r\n },\r\n error: (\r\n message?: string,\r\n title?: string,\r\n yesTitle?: string,\r\n icon?: string\r\n ) => {\r\n this.dialog.open(DialogConfirmComponent, {\r\n width: \"400px\",\r\n data: {\r\n icon: icon || \"error\",\r\n title: title || this.translate(\"Error\"),\r\n message: message || \"Something went wrong!\",\r\n yesTitle: yesTitle || this.translate(\"Ok\"),\r\n },\r\n });\r\n },\r\n };\r\n\r\n notify = {\r\n success: (message?: string, delay?: number, title?: string) => {\r\n // tslint:disable-next-line: max-line-length\r\n // const style = `border-radius: 5px; margin: 0; padding: 12px; z-index: 99999; top: 5px; right: 5px; display: none; position: fixed;color: #4F8A10; background-color: #DFF2BF`;\r\n // tslint:disable-next-line: max-line-length\r\n // const html = `<div id=\"${this.notifyId}\" style=\"${style}\"><i class=\"fa fa-check\"></i> ${message || this.translate('Success')}</div>`;\r\n // this.showNotify(html, delay);\r\n const content = message || this.translate(\"Success\");\r\n this.toastr.success(content, title, {\r\n enableHtml: true,\r\n timeOut: delay || 3000,\r\n closeButton: true,\r\n });\r\n },\r\n warning: (message?: string | string[], delay?: number, title?: string) => {\r\n // tslint:disable-next-line: max-line-length\r\n // const style = `border-radius: 5px; margin: 0; padding: 12px; z-index: 99999; top: 5px; right: 5px; display: none; position: fixed;color: #9F6000; background-color: #FEEFB3`;\r\n // tslint:disable-next-line: max-line-length\r\n // const html = `<div id=\"${this.notifyId}\" style=\"${style}\"><i class=\"fa fa-exclamation-triangle\"></i> ${message || this.translate('Warning')}</div>`;\r\n // this.showNotify(html, delay);\r\n if (Array.isArray(message)){\r\n this.#buildToastMultiMesssage('warning', message, delay, title);\r\n }\r\n else {\r\n const content = message || this.translate(\"Warning\");\r\n this.toastr.warning(content, title, {\r\n enableHtml: true,\r\n timeOut: delay || 3000,\r\n closeButton: true,\r\n });\r\n }\r\n },\r\n error: (message?: string | string[], delay?: number, title?: string) => {\r\n // tslint:disable-next-line: max-line-length\r\n // const style = `border-radius: 5px; margin: 0; padding: 12px; z-index: 99999; top: 5px; right: 5px; display: none; position: fixed;color: #D8000C; background-color: #FFD2D2`;\r\n // tslint:disable-next-line: max-line-length\r\n // const html = `<div id=\"${this.notifyId}\" style=\"${style}\"><i class=\"fa fa-times\"></i> ${message || this.translate('Error')}</div>`;\r\n // this.showNotify(html, delay);\r\n if (Array.isArray(message)){\r\n this.#buildToastMultiMesssage('error', message, delay, title);\r\n }\r\n else {\r\n const content = message || this.translate(\"Error\");\r\n this.toastr.error(content, title, {\r\n enableHtml: true,\r\n timeOut: delay || 3000,\r\n closeButton: true,\r\n });\r\n }\r\n },\r\n };\r\n\r\n #buildToastMultiMesssage = (type: 'warning' | 'error', messages: string[], delay?: number, title?: string) => {\r\n /** số lượng item hiển thị mặc định */\r\n const showNum = 2;\r\n const id = `sd-notify-ckb-${uuid.v4()}`;\r\n const messageLength = messages.length;\r\n const messageRests = messages.splice(showNum);\r\n const messageContainer = `<ul class=\"sd-notify__list\">{0}{1}</ul>`;\r\n const messageTemp = `<li class=\"sd-notify__item\">- {0}</li>`;\r\n let contentRest = '';\r\n if (messageRests?.length) {\r\n contentRest = `<input id=\"${id}\" class=\"cdk-visually-hidden sd-notify__checkbox\" type=\"checkbox\" />\r\n <label class=\"sd-notify__text sd-notify__text--show text-secondary\" for=\"${id}\">${this.translate('Show more')}</label>\r\n <div class=\"sd-notify__item--rest\">\r\n ${messageRests.map(m => String.format(messageTemp, m)).join('')}\r\n </div>\r\n <label class=\"sd-notify__text sd-notify__text--less text-secondary\" for=\"${id}\">${this.translate('Show less')}</label>`;\r\n }\r\n const content = String.format(messageContainer, messages.map(m => String.format(messageTemp, m)).join(''), contentRest);\r\n let toast: ActiveToast<any>;\r\n // khi truyền message html sẽ bị sanitize nên phải truyền innerHTML khi toast hiện lên\r\n // @see https://github.com/scttcper/ngx-toastr/blob/v12.1.0/src/lib/toastr/toastr.service.ts#L271\r\n switch (type) {\r\n case 'error':\r\n toast = this.toastr.error(content, `${title || this.translate('Error')} (${messageLength})`, {\r\n enableHtml: true,\r\n timeOut: delay || 3000,\r\n messageClass: `toast-message toast-message-${id}`,\r\n closeButton: true,\r\n tapToDismiss: false\r\n });\r\n break;\r\n case 'warning':\r\n toast = this.toastr.warning(content, `${title || this.translate('Warning')} (${messageLength})`, {\r\n enableHtml: true,\r\n timeOut: delay || 3000,\r\n messageClass: `toast-message toast-message-${id}`,\r\n closeButton: true,\r\n tapToDismiss: false\r\n });\r\n break;\r\n }\r\n \r\n if (toast) {\r\n toast.onShown\r\n .pipe(\r\n takeUntil(toast.onHidden)\r\n )\r\n .subscribe(() => {\r\n const messageEle: HTMLDivElement = document.querySelector(`.toast-message-${id}`);\r\n messageEle.innerHTML = content;\r\n })\r\n }\r\n }\r\n\r\n handle = {\r\n error: (err: any) => {\r\n if (typeof err === \"string\") {\r\n this.notify.warning(err);\r\n } else if (typeof err === \"object\") {\r\n let message =\r\n err?.error ||\r\n err?.message ||\r\n err?.ExceptionMessage ||\r\n err?.Message ||\r\n \"Unknown error\";\r\n if (typeof err.json === \"function\") {\r\n err = err.json();\r\n if (err) {\r\n message =\r\n err?.error ||\r\n err?.message ||\r\n err?.ExceptionMessage ||\r\n err?.Message ||\r\n \"Unknown error\";\r\n }\r\n }\r\n this.notify.warning(message);\r\n } else {\r\n this.notify.warning(\"Unknown error\");\r\n }\r\n },\r\n };\r\n\r\n confirm = (\r\n message: string,\r\n option: {\r\n title?: string;\r\n yesTitle?: string;\r\n noTitle?: string;\r\n yesButtonColor?: string;\r\n noButtonColor?: string;\r\n } = {}\r\n ) => {\r\n const dialogRef = this.dialog.open(DialogConfirmComponent, {\r\n width: \"400px\",\r\n data: {\r\n title: option?.title || this.translate(\"Confirm\"),\r\n message,\r\n yesTitle: option?.yesTitle || this.translate(\"Yes\"),\r\n noTitle: option?.noTitle || this.translate(\"No\"),\r\n noButtonColor: option?.noButtonColor || \"secondary\",\r\n yesButtonColor: option?.yesButtonColor || \"primary\",\r\n },\r\n });\r\n return new Promise((resolve, reject) => {\r\n dialogRef.afterClosed().subscribe((result) => {\r\n if (result) {\r\n if (result === \"ACCEPT\") {\r\n resolve(null);\r\n } else if (result === \"CANCEL\") {\r\n reject(result);\r\n } else {\r\n resolve(null);\r\n }\r\n }\r\n });\r\n });\r\n };\r\n\r\n confirmDelete = () => this.confirm(this.translate(\"Delete record(s)\"));\r\n\r\n confirmApprove = () => this.confirm(this.translate(\"Approve record(s)\"));\r\n\r\n confirmWithInput = (\r\n title: string,\r\n option: {\r\n message?: string;\r\n yesTitle?: string;\r\n noTitle?: string;\r\n required?: boolean;\r\n maxlength?: number;\r\n yesButtonColor?: string;\r\n noButtonColor?: string;\r\n defaultValue?: string;\r\n } = {}\r\n ): Promise<string> => {\r\n const dialogRef = this.dialog.open(DialogConfirmComponent, {\r\n width: \"400px\",\r\n data: {\r\n title: title || this.translate(\"Confirm\"),\r\n message: option?.message,\r\n yesTitle: option?.yesTitle || this.translate(\"Yes\"),\r\n noTitle: option?.noTitle || this.translate(\"No\"),\r\n noButtonColor: option?.noButtonColor || \"secondary\",\r\n yesButtonColor: option?.yesButtonColor || \"primary\",\r\n input: {\r\n maxlength: option?.maxlength || 255,\r\n required: option?.required,\r\n defaultValue: option?.defaultValue || ''\r\n },\r\n },\r\n });\r\n return new Promise((resolve, reject) => {\r\n dialogRef.afterClosed().subscribe((result) => {\r\n if (result) {\r\n if (result === \"ACCEPT\") {\r\n resolve(result);\r\n } else if (result === \"CANCEL\") {\r\n reject(result);\r\n } else {\r\n resolve(result);\r\n }\r\n }\r\n });\r\n });\r\n };\r\n\r\n private translate = (value: string): string => {\r\n return this.translateService.translate(value);\r\n };\r\n}\r\n","import { NgModule } from \"@angular/core\";\r\nimport { CommonModule } from \"@angular/common\";\r\nimport { MatDialogModule } from \"@angular/material/dialog\";\r\nimport { MatIconModule } from \"@angular/material/icon\";\r\nimport { MatButtonModule } from \"@angular/material/button\";\r\nimport { MatFormFieldModule } from \"@angular/material/form-field\";\r\nimport { MatInputModule } from \"@angular/material/input\";\r\nimport { FormsModule } from \"@angular/forms\";\r\nimport { ToastrService, ToastrModule } from \"ngx-toastr\";\r\nimport { SdButtonModule } from \"@sd-angular/core/button\";\r\n\r\nimport { SdNotifyService } from \"./notify.service\";\r\nimport { DialogConfirmComponent } from \"./components/dialog-confirm/dialog-confirm.component\";\r\n\r\n@NgModule({\r\n imports: [\r\n CommonModule,\r\n FormsModule,\r\n MatFormFieldModule,\r\n MatInputModule,\r\n MatIconModule,\r\n MatButtonModule,\r\n MatDialogModule,\r\n ToastrModule.forRoot(),\r\n\r\n SdButtonModule,\r\n ],\r\n declarations: [DialogConfirmComponent],\r\n entryComponents: [DialogConfirmComponent],\r\n exports: [],\r\n providers: [SdNotifyService],\r\n})\r\nexport class SdNotifyModule {}\r\n","/*\r\n * Public API Surface of superdev-angular-core\r\n */\r\n\r\nexport { SdNotifyModule } from './lib/notify.module';\r\nexport * from './lib/notify.service';\r\nexport * from './lib/components/dialog-confirm/dialog-confirm.component';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["uuid.v4"],"mappings":";;;;;;;;;;;;;;;;MAyBa,sBAAsB;IAGjC,YACS,SAA+C,EACtB,IAAgB;;QADzC,cAAS,GAAT,SAAS,CAAsC;QACtB,SAAI,GAAJ,IAAI,CAAY;QAHlD,aAAQ,GAAG,KAAK,CAAC;QAKf,IAAI,CAAC,QAAQ,GAAG,cAAO,IAAI,CAAC,IAAI,0CAAE,OAAO,CAAA,KAAK,QAAQ,CAAC;QACvD,IAAI,CAAC,KAAK,eAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,KAAK,0CAAE,YAAY,mCAAI,EAAE,CAAC;KAC9C;;;YAdF,SAAS,SAAC;g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O,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM;gBACjC,SAAS,CAAC,WAAW,EAAE,CAAC,SAAS,CAAC,CAAC,MAAM;oBACvC,IAAI,MAAM,EAAE;wBACV,IAAI,MAAM,KAAK,QAAQ,EAAE;4BACvB,OAAO,CAAC,MAAM,CAAC,CAAC;yBACjB;6BAAM,IAAI,MAAM,KAAK,QAAQ,EAAE;4BAC9B,MAAM,CAAC,MAAM,CAAC,CAAC;yBAChB;6BAAM;4BACL,OAAO,CAAC,MAAM,CAAC,CAAC;yBACjB;qBACF;iBACF,CAAC,CAAC;aACJ,CAAC,CAAC;SACJ,CAAC;QAEM,cAAS,GAAG,CAAC,KAAa;YAChC,OAAO,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;SAC/C,CAAC;KAlSE;;;;YAjBL,UAAU;;;YAVF,SAAS;YAEI,aAAa;YAC1B,kBAAkB;;;MC2Bd,cAAc;;;YAlB1B,QAAQ,SAAC;gBACR,OAAO,EAAE;oBACP,YAAY;oBACZ,WAAW;oBACX,kBAAkB;oBAClB,cAAc;oBACd,aAAa;oBACb,eAAe;oBACf,eAAe;oBACf,YAAY,CAAC,OAAO,EAAE;oBAEtB,cAAc;iBACf;gBACD,YAAY,EAAE,CAAC,sBAAsB,CAAC;gBACtC,eAAe,EAAE,CAAC,sBAAsB,CAAC;gBACzC,OAAO,EAAE,EAAE;gBACX,SAAS,EAAE,CAAC,eAAe,CAAC;aAC7B;;;AC/BD;;;;ACAA;;;;;;"}
|
|
@@ -302,7 +302,6 @@ class SdSelect {
|
|
|
302
302
|
this.searchTerm$.asObservable().pipe(startWith(''), debounceTime(__classPrivateFieldGet(this, _delay))),
|
|
303
303
|
this.formControl.valueChanges.pipe(startWith(this.formControl.value))
|
|
304
304
|
]).pipe(switchMap(([items, val, formValue]) => __awaiter(this, void 0, void 0, function* () {
|
|
305
|
-
this.ref.detectChanges();
|
|
306
305
|
if (typeof (items) === 'function') {
|
|
307
306
|
return yield __classPrivateFieldGet(this, _loadItems).call(this, val, items);
|
|
308
307
|
}
|
|
@@ -387,7 +386,7 @@ _input = new WeakMap(), _name = new WeakMap(), _form = new WeakMap(), _itemsChan
|
|
|
387
386
|
SdSelect.decorators = [
|
|
388
387
|
{ type: Component, args: [{
|
|
389
388
|
selector: 'sd-select',
|
|
390
|
-
template: "<div class=\"d-flex align-items-center\" [class.sd-view]=\"sdView?.templateRef\" [class.c-focused]=\"isFocused\"\r\n [class.c-disabled]=\"formControl.disabled\" (click)=\"onClick()\">\r\n <ng-container *ngIf=\"sdView?.templateRef && !isFocused; else default\">\r\n <ng-container\r\n *ngTemplateOutlet=\"sdView.templateRef;context: { value: formControl.value, selectedItems: selectedItems | async }\">\r\n </ng-container>\r\n </ng-container>\r\n <ng-template #default>\r\n <mat-form-field class=\"sd-md\" [ngClass]=\"{'sd-sm': size === 'sm', 'no-padding-wrapper': disableErrorMessage}\"\r\n appearance=\"outline\">\r\n <mat-label *ngIf=\"label\">{{label}}</mat-label>\r\n <mat-select #select [formControl]=\"formControl\" placeholder=\"{{placeholder || label}}\" multiple\r\n (selectionChange)=\"onSelectionChange($event)\" disableOptionCentering=\"true\" panelClass=\"sd-select-panel\"\r\n [ngClass]=\"{'sd-selected': !isRequired && (multiple ? formControl?.value?.length : formControl?.value)}\"\r\n [required]=\"isRequired\" (openedChange)=\"onOpenChange($event)\" *ngIf=\"multiple\">\r\n <mat-select-trigger>\r\n {{display | async }}\r\n </mat-select-trigger>\r\n <mat-option *ngIf=\"filtered\" class=\"sd-filtered-input\" (keyup.Space)=\"$event.stopPropagation()\" disabled=\"true\">\r\n <mat-form-field class=\"sd-md\" appearance=\"outline\">\r\n <mat-icon matPrefix>search</mat-icon>\r\n <input #input placeholder=\"{{'Search' | sdTranslate}}\" matInput autocomplete=\"off\"\r\n (keydown)=\"$event.stopPropagation()\" (keyup)=\"searchTerm$.next($event.target.value)\">\r\n </mat-form-field>\r\n </mat-option>\r\n <ng-container *ngIf=\"multiple && selectAll\">\r\n <mat-checkbox class=\"mat-option\" [(ngModel)]=\"allSelected\" [ngModelOptions]=\"{standalone: true}\"\r\n (change)=\"onSelectAll()\">\r\n T\u1EA5t c\u1EA3</mat-checkbox>\r\n </ng-container>\r\n <ng-container *ngIf=\"valueField && displayField\">\r\n <mat-option *ngFor=\"let item of filteredItems | async; trackBy: trackByKey\" [value]=\"item[valueField]\">\r\n <div matTooltipPosition=\"above\" [matTooltip]=\"item[displayField]\">\r\n <ng-container *ngIf=\"selectDisplayDef?.templateRef\">\r\n <ng-container *ngTemplateOutlet=\"selectDisplayDef.templateRef;context:{item: item}\">\r\n </ng-container>\r\n </ng-container>\r\n <ng-container *ngIf=\"!selectDisplayDef?.templateRef\">\r\n {{ item[displayField] }}\r\n </ng-container>\r\n </div>\r\n </mat-option>\r\n </ng-container>\r\n <ng-container *ngIf=\"!valueField && !displayField\">\r\n <mat-option *ngFor=\"let item of filteredItems | async; trackBy: trackByKey\" [value]=\"item\"
|
|
389
|
+
template: "<div class=\"d-flex align-items-center\" [class.sd-view]=\"sdView?.templateRef\" [class.c-focused]=\"isFocused\"\r\n [class.c-disabled]=\"formControl.disabled\" (click)=\"onClick()\">\r\n <ng-container *ngIf=\"sdView?.templateRef && !isFocused; else default\">\r\n <ng-container\r\n *ngTemplateOutlet=\"sdView.templateRef;context: { value: formControl.value, selectedItems: selectedItems | async }\">\r\n </ng-container>\r\n </ng-container>\r\n <ng-template #default>\r\n <mat-form-field class=\"sd-md\" [ngClass]=\"{'sd-sm': size === 'sm', 'no-padding-wrapper': disableErrorMessage}\"\r\n appearance=\"outline\">\r\n <mat-label *ngIf=\"label\">{{label}}</mat-label>\r\n <mat-select #select [formControl]=\"formControl\" placeholder=\"{{placeholder || label}}\" multiple\r\n (selectionChange)=\"onSelectionChange($event)\" disableOptionCentering=\"true\" panelClass=\"sd-select-panel\"\r\n [ngClass]=\"{'sd-selected': !isRequired && (multiple ? formControl?.value?.length : formControl?.value)}\"\r\n [required]=\"isRequired\" (openedChange)=\"onOpenChange($event)\" *ngIf=\"multiple\">\r\n <mat-select-trigger>\r\n {{display | async }}\r\n </mat-select-trigger>\r\n <mat-option *ngIf=\"filtered\" class=\"sd-filtered-input\" (keyup.Space)=\"$event.stopPropagation()\" disabled=\"true\">\r\n <mat-form-field class=\"sd-md\" appearance=\"outline\">\r\n <mat-icon matPrefix>search</mat-icon>\r\n <input #input placeholder=\"{{'Search' | sdTranslate}}\" matInput autocomplete=\"off\"\r\n (keydown)=\"$event.stopPropagation()\" (keyup)=\"searchTerm$.next($event.target.value)\">\r\n </mat-form-field>\r\n </mat-option>\r\n <ng-container *ngIf=\"multiple && selectAll\">\r\n <mat-checkbox class=\"mat-option\" [(ngModel)]=\"allSelected\" [ngModelOptions]=\"{standalone: true}\"\r\n (change)=\"onSelectAll()\">\r\n T\u1EA5t c\u1EA3</mat-checkbox>\r\n </ng-container>\r\n <ng-container *ngIf=\"valueField && displayField\">\r\n <mat-option *ngFor=\"let item of filteredItems | async; trackBy: trackByKey\" [value]=\"item[valueField]\">\r\n <div matTooltipPosition=\"above\" [matTooltip]=\"item[displayField]\">\r\n <ng-container *ngIf=\"selectDisplayDef?.templateRef\">\r\n <ng-container *ngTemplateOutlet=\"selectDisplayDef.templateRef;context:{item: item}\">\r\n </ng-container>\r\n </ng-container>\r\n <ng-container *ngIf=\"!selectDisplayDef?.templateRef\">\r\n {{ item[displayField] }}\r\n </ng-container>\r\n </div>\r\n </mat-option>\r\n </ng-container>\r\n <ng-container *ngIf=\"!valueField && !displayField\">\r\n <mat-option *ngFor=\"let item of filteredItems | async; trackBy: trackByKey\" [value]=\"item\">\r\n <div matTooltipPosition=\"above\" [matTooltip]=\"item\">\r\n <ng-container *ngIf=\"selectDisplayDef?.templateRef\">\r\n <ng-container *ngTemplateOutlet=\"selectDisplayDef.templateRef;context:{item: item}\">\r\n </ng-container>\r\n </ng-container>\r\n <ng-container *ngIf=\"!selectDisplayDef?.templateRef\">\r\n {{ item }}\r\n </ng-container>\r\n </div>\r\n </mat-option>\r\n </ng-container>\r\n </mat-select>\r\n <mat-select #select [formControl]=\"formControl\" placeholder=\"{{placeholder || label}}\"\r\n (selectionChange)=\"onSelectionChange($event)\" disableOptionCentering=\"true\" panelClass=\"sd-select-panel\"\r\n [ngClass]=\"{'sd-selected': !isRequired && formControl?.value}\" [required]=\"isRequired\"\r\n (openedChange)=\"onOpenChange($event)\" *ngIf=\"!multiple\">\r\n <mat-select-trigger>\r\n {{display | async }}\r\n </mat-select-trigger>\r\n <mat-option *ngIf=\"filtered\" class=\"sd-filtered-input\" (keyup.Space)=\"$event.stopPropagation()\" disabled=\"true\">\r\n <mat-form-field class=\"sd-md\" appearance=\"outline\">\r\n <mat-icon matPrefix>search</mat-icon>\r\n <input #input placeholder=\"{{'Search' | sdTranslate}}\" matInput autocomplete=\"off\"\r\n (keydown)=\"$event.stopPropagation()\" (keyup)=\"searchTerm$.next($event.target.value)\">\r\n </mat-form-field>\r\n </mat-option>\r\n <ng-container *ngIf=\"valueField && displayField\">\r\n <mat-option *ngFor=\"let item of filteredItems | async; trackBy: trackByKey\" [value]=\"item[valueField]\">\r\n <div matTooltipPosition=\"above\" [matTooltip]=\"item[displayField]\">\r\n <ng-container *ngIf=\"selectDisplayDef?.templateRef\">\r\n <ng-container *ngTemplateOutlet=\"selectDisplayDef.templateRef;context:{item: item}\">\r\n </ng-container>\r\n </ng-container>\r\n <ng-container *ngIf=\"!selectDisplayDef?.templateRef\">\r\n {{ item[displayField] }}\r\n </ng-container>\r\n </div>\r\n </mat-option>\r\n </ng-container>\r\n <ng-container *ngIf=\"!valueField && !displayField\">\r\n <mat-option *ngFor=\"let item of filteredItems | async; trackBy: trackByKey\" [value]=\"item\">\r\n <div matTooltipPosition=\"above\" [matTooltip]=\"item\">\r\n <ng-container *ngIf=\"selectDisplayDef?.templateRef\">\r\n <ng-container *ngTemplateOutlet=\"selectDisplayDef.templateRef;context:{item: item}\">\r\n </ng-container>\r\n </ng-container>\r\n <ng-container *ngIf=\"!selectDisplayDef?.templateRef\">\r\n {{ item }}\r\n </ng-container>\r\n </div>\r\n </mat-option>\r\n </ng-container>\r\n </mat-select>\r\n <mat-icon\r\n *ngIf=\"(multiple ? formControl?.value?.length : formControl?.value) && !isRequired && !formControl.disabled\"\r\n class=\"pointer sd-suffix-icon\" (click)=\"clear($event)\" matSuffix>cancel\r\n </mat-icon>\r\n <mat-error *ngIf=\"formControl.errors?.required && !disableErrorMessage\">\r\n {{'This field is required' | sdTranslate}}\r\n </mat-error>\r\n <mat-error *ngIf=\"formControl?.errors?.customValidator && !disableErrorMessage\">\r\n {{formControl?.errors?.customValidator}}\r\n </mat-error>\r\n </mat-form-field>\r\n </ng-template>\r\n</div>",
|
|
391
390
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
392
391
|
styles: [":host{display:block;padding-top:5px}:host ::ng-deep .mat-form-field.mat-form-field-appearance-outline .mat-select-arrow-wrapper{transform:none}:host ::ng-deep .sd-selected .mat-select-arrow{border:none}:host ::ng-deep .mat-form-field.no-padding-wrapper .mat-form-field-wrapper{padding-bottom:0}:host ::ng-deep .mat-form-field.mat-form-field-appearance-outline.mat-form-field-disabled .mat-form-field-outline{background:#f6f6f6;color:#e9e9e9}:host ::ng-deep .mat-form-field mat-select.mat-select-disabled .mat-select-value{color:#4d4d4d!important}:host ::ng-deep .mat-form-field .mat-placeholder-required{color:#f82c13}.sd-view:not(.c-focused):not(.c-disabled):hover{background-color:#ebecf0}::ng-deep .sd-select-panel .mat-option.sd-filtered-input{background-color:#fff;position:-webkit-sticky;position:sticky;top:0;z-index:10}::ng-deep .sd-select-panel .mat-option.sd-filtered-input .mat-form-field.mat-form-field-appearance-outline{width:100%}::ng-deep .sd-select-panel .mat-option.sd-filtered-input mat-pseudo-checkbox{display:none}::ng-deep .mat-select-panel .mat-option.sd-filtered-input{height:auto}::ng-deep .sd-select-panel .mat-option.sd-filtered-input input{color:#000}::ng-deep .sd-select-panel .mat-option.sd-filtered-input .mat-form-field-prefix .mat-icon{margin-right:0}::ng-deep .sd-select-panel .mat-option.sd-filtered-input .mat-form-field.mat-form-field-appearance-outline .mat-form-field-wrapper{padding:10px 0}::ng-deep .sd-select-panel .mat-option.sd-filtered-input .mat-form-field.mat-form-field-appearance-outline .mat-form-field-wrapper .mat-form-field-outline{background-color:rgba(0,0,0,.04)}"]
|
|
393
392
|
},] }
|