@sd-angular/core 0.0.1004 → 0.0.1008
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/autocomplete/sd-angular-core-autocomplete.metadata.json +1 -1
- package/autocomplete/src/lib/autocomplete.component.d.ts +9 -5
- package/bundles/sd-angular-core-api.umd.js +29 -12
- package/bundles/sd-angular-core-api.umd.js.map +1 -1
- package/bundles/sd-angular-core-api.umd.min.js +1 -1
- package/bundles/sd-angular-core-api.umd.min.js.map +1 -1
- package/bundles/sd-angular-core-autocomplete.umd.js +65 -42
- package/bundles/sd-angular-core-autocomplete.umd.js.map +1 -1
- package/bundles/sd-angular-core-autocomplete.umd.min.js +2 -2
- package/bundles/sd-angular-core-autocomplete.umd.min.js.map +1 -1
- package/bundles/sd-angular-core-button.umd.js +29 -12
- package/bundles/sd-angular-core-button.umd.js.map +1 -1
- package/bundles/sd-angular-core-button.umd.min.js +1 -1
- package/bundles/sd-angular-core-button.umd.min.js.map +1 -1
- package/bundles/sd-angular-core-cache.umd.js +29 -12
- package/bundles/sd-angular-core-cache.umd.js.map +1 -1
- package/bundles/sd-angular-core-cache.umd.min.js +2 -2
- package/bundles/sd-angular-core-cache.umd.min.js.map +1 -1
- package/bundles/sd-angular-core-chart.umd.js +29 -12
- package/bundles/sd-angular-core-chart.umd.js.map +1 -1
- package/bundles/sd-angular-core-chart.umd.min.js.map +1 -1
- package/bundles/sd-angular-core-checkbox.umd.js +29 -12
- package/bundles/sd-angular-core-checkbox.umd.js.map +1 -1
- package/bundles/sd-angular-core-checkbox.umd.min.js +1 -1
- package/bundles/sd-angular-core-checkbox.umd.min.js.map +1 -1
- package/bundles/sd-angular-core-chip.umd.js +29 -12
- package/bundles/sd-angular-core-chip.umd.js.map +1 -1
- package/bundles/sd-angular-core-chip.umd.min.js +1 -1
- package/bundles/sd-angular-core-chip.umd.min.js.map +1 -1
- package/bundles/sd-angular-core-comment.umd.js +446 -0
- package/bundles/sd-angular-core-comment.umd.js.map +1 -0
- package/bundles/sd-angular-core-comment.umd.min.js +16 -0
- package/bundles/sd-angular-core-comment.umd.min.js.map +1 -0
- package/bundles/sd-angular-core-common.umd.js +71 -16
- package/bundles/sd-angular-core-common.umd.js.map +1 -1
- package/bundles/sd-angular-core-common.umd.min.js +3 -2
- package/bundles/sd-angular-core-common.umd.min.js.map +1 -1
- package/bundles/sd-angular-core-date-range.umd.js +29 -12
- package/bundles/sd-angular-core-date-range.umd.js.map +1 -1
- package/bundles/sd-angular-core-date-range.umd.min.js +2 -2
- package/bundles/sd-angular-core-date-range.umd.min.js.map +1 -1
- package/bundles/sd-angular-core-date-time.umd.js +29 -12
- package/bundles/sd-angular-core-date-time.umd.js.map +1 -1
- package/bundles/sd-angular-core-date-time.umd.min.js +2 -2
- package/bundles/sd-angular-core-date-time.umd.min.js.map +1 -1
- package/bundles/sd-angular-core-editor.umd.js +29 -12
- package/bundles/sd-angular-core-editor.umd.js.map +1 -1
- package/bundles/sd-angular-core-editor.umd.min.js +1 -1
- package/bundles/sd-angular-core-editor.umd.min.js.map +1 -1
- package/bundles/sd-angular-core-excel.umd.js +29 -12
- package/bundles/sd-angular-core-excel.umd.js.map +1 -1
- package/bundles/sd-angular-core-excel.umd.min.js.map +1 -1
- package/bundles/sd-angular-core-export.umd.js +29 -12
- package/bundles/sd-angular-core-export.umd.js.map +1 -1
- package/bundles/sd-angular-core-export.umd.min.js +1 -1
- package/bundles/sd-angular-core-export.umd.min.js.map +1 -1
- package/bundles/sd-angular-core-grid-material.umd.js +31 -12
- package/bundles/sd-angular-core-grid-material.umd.js.map +1 -1
- package/bundles/sd-angular-core-grid-material.umd.min.js +1 -1
- package/bundles/sd-angular-core-grid-material.umd.min.js.map +1 -1
- package/bundles/sd-angular-core-grid.umd.js +29 -12
- package/bundles/sd-angular-core-grid.umd.js.map +1 -1
- package/bundles/sd-angular-core-grid.umd.min.js +1 -1
- package/bundles/sd-angular-core-grid.umd.min.js.map +1 -1
- package/bundles/sd-angular-core-input-currency.umd.js +29 -12
- 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-input-dropdown.umd.js +29 -12
- package/bundles/sd-angular-core-input-dropdown.umd.js.map +1 -1
- package/bundles/sd-angular-core-input-dropdown.umd.min.js +1 -1
- package/bundles/sd-angular-core-input-dropdown.umd.min.js.map +1 -1
- package/bundles/sd-angular-core-input-upload-file.umd.js +29 -12
- package/bundles/sd-angular-core-input-upload-file.umd.js.map +1 -1
- package/bundles/sd-angular-core-input-upload-file.umd.min.js +2 -2
- package/bundles/sd-angular-core-input-upload-file.umd.min.js.map +1 -1
- package/bundles/sd-angular-core-input.umd.js +54 -17
- package/bundles/sd-angular-core-input.umd.js.map +1 -1
- package/bundles/sd-angular-core-input.umd.min.js +2 -2
- package/bundles/sd-angular-core-input.umd.min.js.map +1 -1
- package/bundles/sd-angular-core-konva.umd.js +29 -12
- package/bundles/sd-angular-core-konva.umd.js.map +1 -1
- package/bundles/sd-angular-core-konva.umd.min.js +1 -1
- package/bundles/sd-angular-core-konva.umd.min.js.map +1 -1
- package/bundles/sd-angular-core-radio.umd.js +29 -12
- package/bundles/sd-angular-core-radio.umd.js.map +1 -1
- package/bundles/sd-angular-core-radio.umd.min.js +1 -1
- package/bundles/sd-angular-core-radio.umd.min.js.map +1 -1
- package/bundles/sd-angular-core-select-editor.umd.js +29 -12
- package/bundles/sd-angular-core-select-editor.umd.js.map +1 -1
- package/bundles/sd-angular-core-select-editor.umd.min.js +2 -2
- package/bundles/sd-angular-core-select-editor.umd.min.js.map +1 -1
- package/bundles/sd-angular-core-select.umd.js +162 -135
- 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/bundles/sd-angular-core-setting.umd.js +29 -12
- package/bundles/sd-angular-core-setting.umd.js.map +1 -1
- package/bundles/sd-angular-core-setting.umd.min.js +1 -1
- package/bundles/sd-angular-core-setting.umd.min.js.map +1 -1
- package/bundles/sd-angular-core-side-drawer.umd.js +29 -12
- package/bundles/sd-angular-core-side-drawer.umd.js.map +1 -1
- package/bundles/sd-angular-core-side-drawer.umd.min.js +2 -2
- package/bundles/sd-angular-core-side-drawer.umd.min.js.map +1 -1
- package/bundles/sd-angular-core-switch.umd.js +29 -12
- package/bundles/sd-angular-core-switch.umd.js.map +1 -1
- package/bundles/sd-angular-core-switch.umd.min.js +2 -2
- package/bundles/sd-angular-core-switch.umd.min.js.map +1 -1
- package/bundles/sd-angular-core-tab-router.umd.js +29 -12
- package/bundles/sd-angular-core-tab-router.umd.js.map +1 -1
- package/bundles/sd-angular-core-tab-router.umd.min.js +2 -2
- package/bundles/sd-angular-core-tab-router.umd.min.js.map +1 -1
- package/bundles/sd-angular-core-textarea.umd.js +29 -12
- package/bundles/sd-angular-core-textarea.umd.js.map +1 -1
- package/bundles/sd-angular-core-textarea.umd.min.js +2 -2
- package/bundles/sd-angular-core-textarea.umd.min.js.map +1 -1
- package/bundles/sd-angular-core-time.umd.js +29 -12
- package/bundles/sd-angular-core-time.umd.js.map +1 -1
- package/bundles/sd-angular-core-time.umd.min.js +2 -2
- package/bundles/sd-angular-core-time.umd.min.js.map +1 -1
- package/bundles/sd-angular-core-upload-excel.umd.js +29 -12
- package/bundles/sd-angular-core-upload-excel.umd.js.map +1 -1
- package/bundles/sd-angular-core-upload-excel.umd.min.js +1 -1
- package/bundles/sd-angular-core-upload-excel.umd.min.js.map +1 -1
- package/bundles/sd-angular-core-upload-file.umd.js +29 -12
- package/bundles/sd-angular-core-upload-file.umd.js.map +1 -1
- package/bundles/sd-angular-core-upload-file.umd.min.js +2 -2
- package/bundles/sd-angular-core-upload-file.umd.min.js.map +1 -1
- package/bundles/sd-angular-core-utility.umd.js +29 -12
- package/bundles/sd-angular-core-utility.umd.js.map +1 -1
- package/bundles/sd-angular-core-utility.umd.min.js +1 -1
- package/bundles/sd-angular-core-utility.umd.min.js.map +1 -1
- package/bundles/sd-angular-core.umd.js +33 -16
- package/bundles/sd-angular-core.umd.js.map +1 -1
- package/bundles/sd-angular-core.umd.min.js +1 -1
- package/bundles/sd-angular-core.umd.min.js.map +1 -1
- package/comment/index.d.ts +1 -0
- package/comment/package.json +12 -0
- package/comment/sd-angular-core-comment.d.ts +4 -0
- package/comment/sd-angular-core-comment.metadata.json +1 -0
- package/comment/src/lib/comment.component.d.ts +17 -0
- package/comment/src/lib/comment.model.d.ts +21 -0
- package/comment/src/lib/comment.module.d.ts +2 -0
- package/comment/src/public-api.d.ts +3 -0
- package/common/sd-angular-core-common.metadata.json +1 -1
- package/common/src/lib/common.module.d.ts +2 -0
- package/common/src/lib/directives/view-def.directive.d.ts +5 -0
- package/common/src/public-api.d.ts +2 -0
- package/esm2015/autocomplete/src/lib/autocomplete.component.js +35 -26
- package/esm2015/autocomplete/src/lib/autocomplete.module.js +6 -3
- package/esm2015/comment/index.js +2 -0
- package/esm2015/comment/sd-angular-core-comment.js +5 -0
- package/esm2015/comment/src/lib/comment.component.js +60 -0
- package/esm2015/comment/src/lib/comment.model.js +2 -0
- package/esm2015/comment/src/lib/comment.module.js +37 -0
- package/esm2015/comment/src/public-api.js +7 -0
- package/esm2015/common/src/lib/common.module.js +20 -0
- package/esm2015/common/src/lib/directives/view-def.directive.js +16 -0
- package/esm2015/common/src/public-api.js +3 -1
- package/esm2015/grid-material/src/lib/pipes/selection-disable.pipe.js +2 -1
- package/esm2015/grid-material/src/lib/pipes/selection-visible.pipe.js +2 -1
- package/esm2015/input/src/lib/input.component.js +23 -4
- package/esm2015/input/src/lib/input.module.js +6 -3
- package/esm2015/public-api.js +2 -1
- package/esm2015/select/src/lib/select.component.js +72 -72
- package/esm2015/select/src/lib/select.module.js +6 -3
- package/fesm2015/sd-angular-core-autocomplete.js +37 -27
- package/fesm2015/sd-angular-core-autocomplete.js.map +1 -1
- package/fesm2015/sd-angular-core-comment.js +106 -0
- package/fesm2015/sd-angular-core-comment.js.map +1 -0
- package/fesm2015/sd-angular-core-common.js +35 -1
- package/fesm2015/sd-angular-core-common.js.map +1 -1
- package/fesm2015/sd-angular-core-grid-material.js +2 -0
- package/fesm2015/sd-angular-core-grid-material.js.map +1 -1
- package/fesm2015/sd-angular-core-input.js +26 -6
- package/fesm2015/sd-angular-core-input.js.map +1 -1
- package/fesm2015/sd-angular-core-select.js +75 -73
- package/fesm2015/sd-angular-core-select.js.map +1 -1
- package/fesm2015/sd-angular-core.js +1 -0
- package/fesm2015/sd-angular-core.js.map +1 -1
- package/input/sd-angular-core-input.metadata.json +1 -1
- package/input/src/lib/input.component.d.ts +5 -0
- package/package.json +1 -1
- package/public-api.d.ts +1 -0
- package/{sd-angular-core-0.0.1004.tgz → sd-angular-core-0.0.1008.tgz} +0 -0
- package/select/sd-angular-core-select.metadata.json +1 -1
- package/select/src/lib/select.component.d.ts +11 -5
|
@@ -8,7 +8,7 @@ import { v4 } from 'uuid';
|
|
|
8
8
|
import $ from 'jquery';
|
|
9
9
|
import { debounceTime } from 'rxjs/operators';
|
|
10
10
|
import { Subscription } from 'rxjs';
|
|
11
|
-
import { SdFormControl } from '@sd-angular/core/common';
|
|
11
|
+
import { SdFormControl, SdViewDefDirective, SdCommonModule } from '@sd-angular/core/common';
|
|
12
12
|
import { MatInputModule } from '@angular/material/input';
|
|
13
13
|
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
14
14
|
import { SdTranslateModule } from '@sd-angular/core/translate';
|
|
@@ -52,6 +52,7 @@ class SdInput {
|
|
|
52
52
|
this.keyupEnter = new EventEmitter();
|
|
53
53
|
this.formControl = new SdFormControl();
|
|
54
54
|
_subscription.set(this, new Subscription());
|
|
55
|
+
this.isFocused = false;
|
|
55
56
|
this.reValidate = () => {
|
|
56
57
|
this.formControl.updateValueAndValidity();
|
|
57
58
|
};
|
|
@@ -98,6 +99,7 @@ class SdInput {
|
|
|
98
99
|
};
|
|
99
100
|
this.onFocus = () => {
|
|
100
101
|
var _a;
|
|
102
|
+
this.isFocused = true;
|
|
101
103
|
this.sdFocus.emit();
|
|
102
104
|
if (((_a = this.sdFocusForceBlur.observers) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
103
105
|
this.blur();
|
|
@@ -106,14 +108,29 @@ class SdInput {
|
|
|
106
108
|
};
|
|
107
109
|
this.onBlur = () => {
|
|
108
110
|
var _a;
|
|
111
|
+
this.isFocused = false;
|
|
109
112
|
const val = ((_a = this.formControl.value) !== null && _a !== void 0 ? _a : '').toString();
|
|
110
113
|
if (val.length > val.trim().length) {
|
|
111
114
|
this.formControl.setValue(val.trim());
|
|
112
115
|
}
|
|
113
116
|
};
|
|
117
|
+
this.onClick = () => {
|
|
118
|
+
var _a;
|
|
119
|
+
if ((_a = this.sdView) === null || _a === void 0 ? void 0 : _a.templateRef) {
|
|
120
|
+
if (!this.formControl.disabled && !this.isFocused) {
|
|
121
|
+
this.focus();
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
};
|
|
114
125
|
this.blur = () => {
|
|
115
126
|
$(this.control.nativeElement).trigger('blur');
|
|
116
127
|
};
|
|
128
|
+
this.focus = () => {
|
|
129
|
+
this.isFocused = true;
|
|
130
|
+
setTimeout(() => {
|
|
131
|
+
$(this.control.nativeElement).trigger('focus');
|
|
132
|
+
}, 100);
|
|
133
|
+
};
|
|
117
134
|
_customValidator.set(this, (func) => {
|
|
118
135
|
return (c) => __awaiter(this, void 0, void 0, function* () {
|
|
119
136
|
const value = c.value || null;
|
|
@@ -224,9 +241,9 @@ _name = new WeakMap(), _form = new WeakMap(), _model = new WeakMap(), _pattern =
|
|
|
224
241
|
SdInput.decorators = [
|
|
225
242
|
{ type: Component, args: [{
|
|
226
243
|
selector: 'sd-input',
|
|
227
|
-
template: "<div class=\"d-flex align-items-center\">\r\n <mat-form-field class=\"sd-md\"
|
|
244
|
+
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 }\">\r\n </ng-container>\r\n </ng-container>\r\n <ng-template #default>\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 [id]=\"id\" [formControl]=\"formControl\" [type]=\"type\" #control matInput [placeholder]=\"placeholder || label\"\r\n (keyup.enter)=\"onKeyupEnter()\" (focus)=\"onFocus()\" (blur)=\"onBlur()\" [required]=\"isRequired\"\r\n [readonly]=\"isReadonly\" [autocomplete]=\"id\" autocorrect=\"off\">\r\n <span class=\"mr-1\" *ngIf=\"maxlength\" matSuffix>{{formControl.value?.length || 0}}/{{maxlength}}</span>\r\n <ng-container *ngIf=\"sdInputSuffix?.templateRef\" matSuffix>\r\n <ng-container *ngTemplateOutlet=\"sdInputSuffix.templateRef\">\r\n </ng-container>\r\n </ng-container>\r\n <mat-icon *ngIf=\"!hideIcon && sdClickIcon?.observers?.length\" (click)=\"onClickIcon($event)\"\r\n class=\"pointer sd-suffix-icon\" matSuffix>\r\n {{icon}}\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?.maxlength && !disableErrorMessage\">\r\n {{'Max length' | sdTranslate}} <strong>{{maxlength}}</strong>\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 | sdInputTooltipPipe:tooltip\" matSuffix\r\n #sdTooltip=\"matTooltip\">info</mat-icon>\r\n </div>\r\n </ng-template>\r\n</div>",
|
|
228
245
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
229
|
-
styles: [":host ::ng-deep .mat-form-field.sd-form-tooltip{width:calc(100% - 30px)}: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}.sd-tooltip{display:inline-block;margin:auto;text-align:center;width:30px}:host{display:block;padding-top:5px}"]
|
|
246
|
+
styles: [":host ::ng-deep .mat-form-field.sd-form-tooltip{width:calc(100% - 30px)}: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}.sd-view:not(.c-focused):not(.c-disabled):hover{background-color:#ebecf0}.sd-tooltip{display:inline-block;margin:auto;text-align:center;width:30px}:host{display:block;padding-top:5px}"]
|
|
230
247
|
},] }
|
|
231
248
|
];
|
|
232
249
|
SdInput.ctorParameters = () => [
|
|
@@ -258,7 +275,8 @@ SdInput.propDecorators = {
|
|
|
258
275
|
sdFocusForceBlur: [{ type: Output }],
|
|
259
276
|
keyupEnter: [{ type: Output }],
|
|
260
277
|
control: [{ type: ViewChild, args: ['control',] }],
|
|
261
|
-
sdInputSuffix: [{ type: ContentChild, args: [SdInputSuffixDirective,] }]
|
|
278
|
+
sdInputSuffix: [{ type: ContentChild, args: [SdInputSuffixDirective,] }],
|
|
279
|
+
sdView: [{ type: ContentChild, args: [SdViewDefDirective,] }]
|
|
262
280
|
};
|
|
263
281
|
|
|
264
282
|
class SdInputTooltipPipe {
|
|
@@ -305,7 +323,8 @@ SdInputModule.decorators = [
|
|
|
305
323
|
MatInputModule,
|
|
306
324
|
MatIconModule,
|
|
307
325
|
MatTooltipModule,
|
|
308
|
-
SdTranslateModule
|
|
326
|
+
SdTranslateModule,
|
|
327
|
+
SdCommonModule
|
|
309
328
|
],
|
|
310
329
|
declarations: [
|
|
311
330
|
SdInput,
|
|
@@ -316,7 +335,8 @@ SdInputModule.decorators = [
|
|
|
316
335
|
exports: [
|
|
317
336
|
SdInput,
|
|
318
337
|
SdInputTooltipPipe,
|
|
319
|
-
SdInputSuffixDirective
|
|
338
|
+
SdInputSuffixDirective,
|
|
339
|
+
SdCommonModule
|
|
320
340
|
]
|
|
321
341
|
},] }
|
|
322
342
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sd-angular-core-input.js","sources":["../../../../projects/sd-core/input/src/lib/directives/input-suffix.directive.ts","../../../../projects/sd-core/input/src/lib/input.component.ts","../../../../projects/sd-core/input/src/lib/input-tooltip.pipe.ts","../../../../projects/sd-core/input/src/lib/directives/touch.directive.ts","../../../../projects/sd-core/input/src/lib/input.module.ts","../../../../projects/sd-core/input/src/public-api.ts","../../../../projects/sd-core/input/sd-angular-core-input.ts"],"sourcesContent":["import { Directive, TemplateRef } from '@angular/core';\r\n\r\n@Directive({\r\n selector: '[sdInputSuffix]'\r\n})\r\nexport class SdInputSuffixDirective {\r\n constructor(public templateRef: TemplateRef<any>) { }\r\n}\r\n","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 ChangeDetectionStrategy,\r\n HostListener\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 $ from 'jquery';\r\nimport { debounceTime } from 'rxjs/operators';\r\nimport { Subscription } from 'rxjs';\r\nimport { SdInputSuffixDirective } from './directives/input-suffix.directive';\r\nimport { SdFormControl } from '@sd-angular/core/common';\r\n\r\n@Component({\r\n selector: 'sd-input',\r\n templateUrl: './input.component.html',\r\n styleUrls: ['./input.component.scss'],\r\n changeDetection: ChangeDetectionStrategy.OnPush\r\n})\r\nexport class SdInput implements OnDestroy, OnInit, AfterViewInit {\r\n id = `I${uuid.v4()}`;\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 @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() type: 'text' | 'number' | 'password' | 'email' = 'text';\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 #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 emitEvent: false\r\n });\r\n }\r\n }\r\n @Output() modelChange = new EventEmitter();\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 isReadonly = false;\r\n @Input() set readonly(val: boolean | '') {\r\n this.isReadonly = (val === '') || val;\r\n }\r\n\r\n minlength: number;\r\n @Input('minlength') set pMinlength(val: number) {\r\n this.minlength = +val;\r\n this.#updateValidator();\r\n }\r\n maxlength: number;\r\n @Input('maxlength') set pMaxlength(val: number) {\r\n this.maxlength = +val;\r\n this.#updateValidator();\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() icon = 'search';\r\n hideIcon = false;\r\n @Input('hideIcon') set _hideIcon(val: boolean | '') {\r\n this.hideIcon = (val === '') || val;\r\n val = (val === '') || val;\r\n }\r\n @Output() sdClickIcon = new EventEmitter<any>();\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() sdFocusForceBlur = new EventEmitter<any>();\r\n @Output() keyupEnter = new EventEmitter();\r\n\r\n @ViewChild('control') control: ElementRef;\r\n @ContentChild(SdInputSuffixDirective) sdInputSuffix: SdInputSuffixDirective;\r\n formControl = new SdFormControl();\r\n #subscription = new Subscription();\r\n constructor(public 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 }\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.minlength > 0) {\r\n validators.push(Validators.minLength(this.minlength));\r\n }\r\n if (this.maxlength > 0) {\r\n validators.push(Validators.maxLength(this.maxlength));\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 = (value: any) => {\r\n this.modelChange.emit(value);\r\n this.sdChange.emit(value);\r\n }\r\n\r\n onKeyupEnter = () => {\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 this.keyupEnter.emit(this.formControl.value);\r\n }\r\n\r\n onClickIcon = (event: Event) => {\r\n event?.preventDefault();\r\n event?.stopPropagation();\r\n this.sdClickIcon.emit(this.formControl.value);\r\n }\r\n\r\n onFocus = () => {\r\n this.sdFocus.emit();\r\n if (this.sdFocusForceBlur.observers?.length > 0) {\r\n this.blur();\r\n this.sdFocusForceBlur.emit();\r\n }\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 blur = () => {\r\n $(this.control.nativeElement).trigger('blur');\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: 'sdInputTooltipPipe'\r\n})\r\nexport class SdInputTooltipPipe 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 { ChangeDetectorRef, Directive, Input, OnChanges, SimpleChanges } from \"@angular/core\";\r\n\r\n@Directive({\r\n selector: '[touch]'\r\n})\r\nexport class TouchDirective implements OnChanges {\r\n @Input() public touch: any;\r\n @Input() public ref: ChangeDetectorRef;\r\n\r\n ngOnChanges(changes: SimpleChanges){\r\n console.log(changes);\r\n if(changes.touch){\r\n this.ref.markForCheck();\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 { SdInput } from './input.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 { SdInputTooltipPipe } from './input-tooltip.pipe';\r\nimport { SdInputSuffixDirective } from './directives/input-suffix.directive';\r\nimport { TouchDirective } from './directives/touch.directive';\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 ],\r\n declarations: [\r\n SdInput,\r\n SdInputTooltipPipe,\r\n SdInputSuffixDirective,\r\n TouchDirective\r\n ],\r\n exports: [\r\n SdInput,\r\n SdInputTooltipPipe,\r\n SdInputSuffixDirective\r\n ]\r\n})\r\nexport class SdInputModule { }\r\n","/*\r\n * Public API Surface of superdev-angular-core\r\n */\r\n\r\nexport * from './lib/input.module';\r\nexport * from './lib/input-tooltip.pipe';\r\nexport * from './lib/directives/input-suffix.directive';\r\nexport * from './lib/input.component';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n\nexport {TouchDirective as ɵa} from './src/lib/directives/touch.directive';"],"names":["uuid.v4"],"mappings":";;;;;;;;;;;;;;;MAKa,sBAAsB;IACjC,YAAmB,WAA6B;QAA7B,gBAAW,GAAX,WAAW,CAAkB;KAAK;;;YAJtD,SAAS,SAAC;gBACT,QAAQ,EAAE,iBAAiB;aAC5B;;;YAJmB,WAAW;;;;MC6BlB,OAAO;IAiGlB,YAAmB,GAAsB;QAAtB,QAAG,GAAH,GAAG,CAAmB;QAhGzC,OAAE,GAAG,IAAIA,EAAO,EAAE,EAAE,CAAC;QACrB,gBAAQA,EAAO,EAAE,EAAC;QAOlB,wBAAiB;QAYR,SAAI,GAA6C,MAAM,CAAC;QACjE,wBAAmB,GAAG,KAAK,CAAC;QAK5B,yBAAY;QASF,gBAAW,GAAG,IAAI,YAAY,EAAE,CAAC;;QAG3C,eAAU,GAAG,KAAK,CAAC;QAMnB,eAAU,GAAG,KAAK,CAAC;QAenB,2BAAiB;QAKjB,6BAAqD;QAe5C,SAAI,GAAG,QAAQ,CAAC;QACzB,aAAQ,GAAG,KAAK,CAAC;QAKP,gBAAW,GAAG,IAAI,YAAY,EAAO,CAAC;QAEtC,aAAQ,GAAG,IAAI,YAAY,EAAO,CAAC;QACnC,YAAO,GAAG,IAAI,YAAY,EAAO,CAAC;QAClC,qBAAgB,GAAG,IAAI,YAAY,EAAO,CAAC;QAC3C,eAAU,GAAG,IAAI,YAAY,EAAE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,OAAO,CAAC,KAAK,CAAC,CAAC;KACvB;;;YATF,IAAI,SAAC;gBACJ,IAAI,EAAE,oBAAoB;aAC3B;;;MCEY,cAAc;IAIzB,WAAW,CAAC,OAAsB;QAChC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACrB,IAAG,OAAO,CAAC,KAAK,EAAC;YACf,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC;SACzB;KACF;;;YAZF,SAAS,SAAC;gBACT,QAAQ,EAAE,SAAS;aACpB;;;oBAEE,KAAK;kBACL,KAAK;;;MC6BK,aAAa;;;YAvBzB,QAAQ,SAAC;gBACR,OAAO,EAAE;oBACP,YAAY;oBACZ,WAAW;oBACX,mBAAmB;oBACnB,kBAAkB;oBAClB,cAAc;oBACd,aAAa;oBACb,gBAAgB;oBAChB,iBAAiB;iBAClB;gBACD,YAAY,EAAE;oBACZ,OAAO;oBACP,kBAAkB;oBAClB,sBAAsB;oBACtB,cAAc;iBACf;gBACD,OAAO,EAAE;oBACP,OAAO;oBACP,kBAAkB;oBAClB,sBAAsB;iBACvB;aACF;;;ACnCD;;;;ACAA;;;;;;"}
|
|
1
|
+
{"version":3,"file":"sd-angular-core-input.js","sources":["../../../../projects/sd-core/input/src/lib/directives/input-suffix.directive.ts","../../../../projects/sd-core/input/src/lib/input.component.ts","../../../../projects/sd-core/input/src/lib/input-tooltip.pipe.ts","../../../../projects/sd-core/input/src/lib/directives/touch.directive.ts","../../../../projects/sd-core/input/src/lib/input.module.ts","../../../../projects/sd-core/input/src/public-api.ts","../../../../projects/sd-core/input/sd-angular-core-input.ts"],"sourcesContent":["import { Directive, TemplateRef } from '@angular/core';\r\n\r\n@Directive({\r\n selector: '[sdInputSuffix]'\r\n})\r\nexport class SdInputSuffixDirective {\r\n constructor(public templateRef: TemplateRef<any>) { }\r\n}\r\n","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 ChangeDetectionStrategy,\r\n HostListener\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 $ from 'jquery';\r\nimport { debounceTime } from 'rxjs/operators';\r\nimport { Subscription } from 'rxjs';\r\nimport { SdInputSuffixDirective } from './directives/input-suffix.directive';\r\nimport { SdFormControl } from '@sd-angular/core/common';\r\nimport { SdViewDefDirective } from '@sd-angular/core/common';\r\n\r\n@Component({\r\n selector: 'sd-input',\r\n templateUrl: './input.component.html',\r\n styleUrls: ['./input.component.scss'],\r\n changeDetection: ChangeDetectionStrategy.OnPush\r\n})\r\nexport class SdInput implements OnDestroy, OnInit, AfterViewInit {\r\n id = `I${uuid.v4()}`;\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 @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() type: 'text' | 'number' | 'password' | 'email' = 'text';\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 #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 emitEvent: false\r\n });\r\n }\r\n }\r\n @Output() modelChange = new EventEmitter();\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 isReadonly = false;\r\n @Input() set readonly(val: boolean | '') {\r\n this.isReadonly = (val === '') || val;\r\n }\r\n\r\n minlength: number;\r\n @Input('minlength') set pMinlength(val: number) {\r\n this.minlength = +val;\r\n this.#updateValidator();\r\n }\r\n maxlength: number;\r\n @Input('maxlength') set pMaxlength(val: number) {\r\n this.maxlength = +val;\r\n this.#updateValidator();\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() icon = 'search';\r\n hideIcon = false;\r\n @Input('hideIcon') set _hideIcon(val: boolean | '') {\r\n this.hideIcon = (val === '') || val;\r\n val = (val === '') || val;\r\n }\r\n @Output() sdClickIcon = new EventEmitter<any>();\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() sdFocusForceBlur = new EventEmitter<any>();\r\n @Output() keyupEnter = new EventEmitter();\r\n\r\n @ViewChild('control') control: ElementRef;\r\n @ContentChild(SdInputSuffixDirective) sdInputSuffix: SdInputSuffixDirective;\r\n formControl = new SdFormControl();\r\n #subscription = new Subscription();\r\n @ContentChild(SdViewDefDirective) sdView: SdViewDefDirective;\r\n isFocused = false;\r\n constructor(public 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 }\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.minlength > 0) {\r\n validators.push(Validators.minLength(this.minlength));\r\n }\r\n if (this.maxlength > 0) {\r\n validators.push(Validators.maxLength(this.maxlength));\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 = (value: any) => {\r\n this.modelChange.emit(value);\r\n this.sdChange.emit(value);\r\n }\r\n\r\n onKeyupEnter = () => {\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 this.keyupEnter.emit(this.formControl.value);\r\n }\r\n\r\n onClickIcon = (event: Event) => {\r\n event?.preventDefault();\r\n event?.stopPropagation();\r\n this.sdClickIcon.emit(this.formControl.value);\r\n }\r\n\r\n onFocus = () => {\r\n this.isFocused = true;\r\n this.sdFocus.emit();\r\n if (this.sdFocusForceBlur.observers?.length > 0) {\r\n this.blur();\r\n this.sdFocusForceBlur.emit();\r\n }\r\n }\r\n\r\n onBlur = () => {\r\n this.isFocused = false;\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 onClick = () => {\r\n if(this.sdView?.templateRef) {\r\n if(!this.formControl.disabled && !this.isFocused) {\r\n this.focus();\r\n }\r\n }\r\n }\r\n\r\n blur = () => {\r\n $(this.control.nativeElement).trigger('blur');\r\n }\r\n\r\n focus = () => {\r\n this.isFocused = true;\r\n setTimeout(() => {\r\n $(this.control.nativeElement).trigger('focus');\r\n }, 100);\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: 'sdInputTooltipPipe'\r\n})\r\nexport class SdInputTooltipPipe 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 { ChangeDetectorRef, Directive, Input, OnChanges, SimpleChanges } from \"@angular/core\";\r\n\r\n@Directive({\r\n selector: '[touch]'\r\n})\r\nexport class TouchDirective implements OnChanges {\r\n @Input() public touch: any;\r\n @Input() public ref: ChangeDetectorRef;\r\n\r\n ngOnChanges(changes: SimpleChanges){\r\n console.log(changes);\r\n if(changes.touch){\r\n this.ref.markForCheck();\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 { SdInput } from './input.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 { SdInputTooltipPipe } from './input-tooltip.pipe';\r\nimport { SdInputSuffixDirective } from './directives/input-suffix.directive';\r\nimport { TouchDirective } from './directives/touch.directive';\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 SdTranslateModule,\r\n SdCommonModule\r\n ],\r\n declarations: [\r\n SdInput,\r\n SdInputTooltipPipe,\r\n SdInputSuffixDirective,\r\n TouchDirective\r\n ],\r\n exports: [\r\n SdInput,\r\n SdInputTooltipPipe,\r\n SdInputSuffixDirective,\r\n SdCommonModule\r\n ]\r\n})\r\nexport class SdInputModule { }\r\n","/*\r\n * Public API Surface of superdev-angular-core\r\n */\r\n\r\nexport * from './lib/input.module';\r\nexport * from './lib/input-tooltip.pipe';\r\nexport * from './lib/directives/input-suffix.directive';\r\nexport * from './lib/input.component';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n\nexport {TouchDirective as ɵa} from './src/lib/directives/touch.directive';"],"names":["uuid.v4"],"mappings":";;;;;;;;;;;;;;;MAKa,sBAAsB;IACjC,YAAmB,WAA6B;QAA7B,gBAAW,GAAX,WAAW,CAAkB;KAAK;;;YAJtD,SAAS,SAAC;gBACT,QAAQ,EAAE,iBAAiB;aAC5B;;;YAJmB,WAAW;;;;MC8BlB,OAAO;IAmGlB,YAAmB,GAAsB;QAAtB,QAAG,GAAH,GAAG,CAAmB;QAlGzC,OAAE,GAAG,IAAIA,EAAO,EAAE,EAAE,CAAC;QACrB,gBAAQA,EAAO,EAAE,EAAC;QAOlB,wBAAiB;QAYR,SAAI,GAA6C,MAAM,CAAC;QACjE,wBAAmB,GAAG,KAAK,CAAC;QAK5B,yBAAY;QASF,gBAAW,GAAG,IAAI,YAAY,EAAE,CAAC;;QAG3C,eAAU,GAAG,KAAK,CAAC;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EE,KAAK;kBACL,KAAK;;;MCgCK,aAAa;;;YAzBzB,QAAQ,SAAC;gBACR,OAAO,EAAE;oBACP,YAAY;oBACZ,WAAW;oBACX,mBAAmB;oBACnB,kBAAkB;oBAClB,cAAc;oBACd,aAAa;oBACb,gBAAgB;oBAChB,iBAAiB;oBACjB,cAAc;iBACf;gBACD,YAAY,EAAE;oBACZ,OAAO;oBACP,kBAAkB;oBAClB,sBAAsB;oBACtB,cAAc;iBACf;gBACD,OAAO,EAAE;oBACP,OAAO;oBACP,kBAAkB;oBAClB,sBAAsB;oBACtB,cAAc;iBACf;aACF;;;ACtCD;;;;ACAA;;;;;;"}
|
|
@@ -12,7 +12,7 @@ import { v4 } from 'uuid';
|
|
|
12
12
|
import { Subject, Subscription, combineLatest } from 'rxjs';
|
|
13
13
|
import { startWith, debounceTime, switchMap, map } from 'rxjs/operators';
|
|
14
14
|
import { SdUtilityService } from '@sd-angular/core/utility';
|
|
15
|
-
import { SdFormControl } from '@sd-angular/core/common';
|
|
15
|
+
import { SdFormControl, SdViewDefDirective, SdCommonModule } from '@sd-angular/core/common';
|
|
16
16
|
import { MatSelectModule } from '@angular/material/select';
|
|
17
17
|
import { SdTranslateModule } from '@sd-angular/core/translate';
|
|
18
18
|
import { MatCheckboxModule } from '@angular/material/checkbox';
|
|
@@ -31,7 +31,7 @@ SdSelectDisplayDefDirective.ctorParameters = () => [
|
|
|
31
31
|
{ type: TemplateRef }
|
|
32
32
|
];
|
|
33
33
|
|
|
34
|
-
var _input, _name, _form, _items,
|
|
34
|
+
var _input, _name, _form, _items, _delay, _validator, _subscription, _selectedItems, _allItems, _allItem, _updateValidator, _loadSelectedItems, _loadItems, _onChange, _customValidator;
|
|
35
35
|
class SdSelect {
|
|
36
36
|
constructor(ref, utilityService) {
|
|
37
37
|
this.ref = ref;
|
|
@@ -44,8 +44,6 @@ class SdSelect {
|
|
|
44
44
|
_form.set(this, void 0);
|
|
45
45
|
// Items
|
|
46
46
|
_items.set(this, []);
|
|
47
|
-
_currentItems.set(this, []);
|
|
48
|
-
_allItem.set(this, {});
|
|
49
47
|
// Server search
|
|
50
48
|
this.loading = false;
|
|
51
49
|
_delay.set(this, 500); // Sau khoảng thời gian delay nếu không có thay đổi thì thì mới bắt đầu thực hiện gọi hàm
|
|
@@ -56,12 +54,15 @@ class SdSelect {
|
|
|
56
54
|
this.limit = 100;
|
|
57
55
|
this.filtered = false;
|
|
58
56
|
this.selectAll = false;
|
|
59
|
-
_allItems.set(this, void 0);
|
|
60
|
-
this.allSelected = false;
|
|
61
57
|
this.modelChange = new EventEmitter();
|
|
62
58
|
this.sdChange = new EventEmitter();
|
|
63
59
|
this.sdSelection = new EventEmitter();
|
|
64
60
|
_subscription.set(this, new Subscription());
|
|
61
|
+
_selectedItems.set(this, void 0);
|
|
62
|
+
_allItems.set(this, void 0);
|
|
63
|
+
_allItem.set(this, {});
|
|
64
|
+
this.allSelected = false;
|
|
65
|
+
this.isFocused = false;
|
|
65
66
|
_updateValidator.set(this, () => {
|
|
66
67
|
this.formControl.clearValidators();
|
|
67
68
|
this.formControl.clearAsyncValidators();
|
|
@@ -77,42 +78,29 @@ class SdSelect {
|
|
|
77
78
|
this.formControl.setAsyncValidators(asyncValidators);
|
|
78
79
|
this.formControl.updateValueAndValidity();
|
|
79
80
|
});
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
_loadSelectedItems.set(this, (value, items) => __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
if (!(value === null || value === void 0 ? void 0 : value.toString())) {
|
|
83
|
+
return [];
|
|
84
|
+
}
|
|
85
|
+
const values = Array.isArray(value) ? value : [value];
|
|
86
|
+
if (!this.valueField && !this.displayField) {
|
|
87
|
+
return values;
|
|
88
|
+
}
|
|
89
|
+
this.loading = true;
|
|
90
|
+
if (values.some(val => __classPrivateFieldGet(this, _allItem)[val] === undefined)) {
|
|
91
|
+
const results = yield items(value, true).finally(() => this.loading = false);
|
|
92
|
+
const objItem = this.valueField ? this.utilityService.arrayToObject(results, this.valueField) : results.forEach(item => objItem[item === null || item === void 0 ? void 0 : item.toString()] = item);
|
|
93
|
+
__classPrivateFieldSet(this, _allItem, Object.assign(Object.assign(Object.assign({}, values.map(val => ({ [val]: { [this.valueField]: val, [this.displayField]: val } }))), __classPrivateFieldGet(this, _allItem)), objItem));
|
|
84
94
|
}
|
|
85
|
-
return
|
|
95
|
+
return values.map(val => __classPrivateFieldGet(this, _allItem)[val]);
|
|
86
96
|
}));
|
|
87
97
|
_loadItems.set(this, (searchText, items) => __awaiter(this, void 0, void 0, function* () {
|
|
88
|
-
var _a;
|
|
89
98
|
this.loading = true;
|
|
90
99
|
const results = yield items(searchText).finally(() => this.loading = false);
|
|
91
100
|
const objItem = this.valueField ? this.utilityService.arrayToObject(results, this.valueField) : results.forEach(item => objItem[item === null || item === void 0 ? void 0 : item.toString()] = item);
|
|
92
|
-
Object.assign(__classPrivateFieldGet(this, _allItem), objItem);
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
const values = Array.isArray(this.formControl.value) ? this.formControl.value : [this.formControl.value];
|
|
97
|
-
values.map(val => val === null || val === void 0 ? void 0 : val.toString()).forEach(val => {
|
|
98
|
-
if (!objItem[val]) {
|
|
99
|
-
if (__classPrivateFieldGet(this, _allItem)[val]) {
|
|
100
|
-
results.push(__classPrivateFieldGet(this, _allItem)[val]);
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
if (this.valueField && this.displayField) {
|
|
104
|
-
results.push({
|
|
105
|
-
[this.valueField]: val,
|
|
106
|
-
[this.displayField]: val
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
results.push(val);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
return results;
|
|
101
|
+
__classPrivateFieldSet(this, _allItem, Object.assign(Object.assign({}, __classPrivateFieldGet(this, _allItem)), objItem));
|
|
102
|
+
const selectedItems = yield __classPrivateFieldGet(this, _loadSelectedItems).call(this, this.formControl.value, items);
|
|
103
|
+
return [...selectedItems, ...results];
|
|
116
104
|
}));
|
|
117
105
|
this.onSelectionChange = (change) => {
|
|
118
106
|
var _a;
|
|
@@ -130,13 +118,12 @@ class SdSelect {
|
|
|
130
118
|
this.formControl.updateValueAndValidity({ emitEvent: true });
|
|
131
119
|
};
|
|
132
120
|
_onChange.set(this, (value) => {
|
|
133
|
-
var _a, _b;
|
|
134
121
|
if (Array.isArray(value)) {
|
|
135
122
|
this.modelChange.emit(value);
|
|
136
123
|
this.sdChange.emit(value);
|
|
137
124
|
this.sdSelection.emit({
|
|
138
125
|
value: value,
|
|
139
|
-
items:
|
|
126
|
+
items: this.selectedItems
|
|
140
127
|
});
|
|
141
128
|
}
|
|
142
129
|
else {
|
|
@@ -144,7 +131,7 @@ class SdSelect {
|
|
|
144
131
|
this.sdChange.emit(value);
|
|
145
132
|
this.sdSelection.emit({
|
|
146
133
|
value: value,
|
|
147
|
-
item:
|
|
134
|
+
item: this.selectedItems[0]
|
|
148
135
|
});
|
|
149
136
|
}
|
|
150
137
|
});
|
|
@@ -169,6 +156,22 @@ class SdSelect {
|
|
|
169
156
|
});
|
|
170
157
|
}
|
|
171
158
|
};
|
|
159
|
+
this.onClick = () => {
|
|
160
|
+
var _a;
|
|
161
|
+
if ((_a = this.sdView) === null || _a === void 0 ? void 0 : _a.templateRef) {
|
|
162
|
+
if (!this.formControl.disabled && !this.isFocused) {
|
|
163
|
+
this.focus();
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
this.focus = () => {
|
|
168
|
+
this.isFocused = true;
|
|
169
|
+
setTimeout(() => {
|
|
170
|
+
var _a, _b;
|
|
171
|
+
(_a = this.select) === null || _a === void 0 ? void 0 : _a.focus();
|
|
172
|
+
(_b = this.select) === null || _b === void 0 ? void 0 : _b.open();
|
|
173
|
+
}, 100);
|
|
174
|
+
};
|
|
172
175
|
_customValidator.set(this, (func) => {
|
|
173
176
|
return (c) => __awaiter(this, void 0, void 0, function* () {
|
|
174
177
|
const value = c.value || null;
|
|
@@ -195,11 +198,15 @@ class SdSelect {
|
|
|
195
198
|
});
|
|
196
199
|
this.onOpenChange = (isOpened) => {
|
|
197
200
|
if (isOpened) {
|
|
201
|
+
this.isFocused = true;
|
|
198
202
|
if (__classPrivateFieldGet(this, _input)) {
|
|
199
203
|
__classPrivateFieldGet(this, _input).value = null;
|
|
200
204
|
}
|
|
201
205
|
this.searchTerm$.next('');
|
|
202
206
|
}
|
|
207
|
+
else {
|
|
208
|
+
this.isFocused = false;
|
|
209
|
+
}
|
|
203
210
|
};
|
|
204
211
|
}
|
|
205
212
|
set input(input) {
|
|
@@ -228,20 +235,7 @@ class SdSelect {
|
|
|
228
235
|
}
|
|
229
236
|
}
|
|
230
237
|
set model(value) {
|
|
231
|
-
|
|
232
|
-
// if (Array.isArray(value)) {
|
|
233
|
-
// this.formControl.setValue(value.map(val => (val ?? '') + ''));
|
|
234
|
-
// } else {
|
|
235
|
-
// this.formControl.setValue((value ?? '') + '');
|
|
236
|
-
// }
|
|
237
|
-
// this.ref.detectChanges();
|
|
238
|
-
// this.#model = value;
|
|
239
|
-
if (Array.isArray(value)) {
|
|
240
|
-
this.formControl.setValue(value);
|
|
241
|
-
}
|
|
242
|
-
else {
|
|
243
|
-
this.formControl.setValue(value);
|
|
244
|
-
}
|
|
238
|
+
this.formControl.setValue(value);
|
|
245
239
|
}
|
|
246
240
|
set items(items) {
|
|
247
241
|
if (!items) {
|
|
@@ -286,13 +280,15 @@ class SdSelect {
|
|
|
286
280
|
__classPrivateFieldGet(this, _subscription).add(this.formControl.touchedChanges.subscribe(() => {
|
|
287
281
|
this.ref.markForCheck();
|
|
288
282
|
}));
|
|
289
|
-
__classPrivateFieldSet(this, _allItems,
|
|
283
|
+
__classPrivateFieldSet(this, _allItems, combineLatest([
|
|
284
|
+
this.searchTerm$.asObservable().pipe(startWith(''), debounceTime(typeof (__classPrivateFieldGet(this, _items)) === 'function' ? __classPrivateFieldGet(this, _delay) : 0)),
|
|
285
|
+
this.formControl.valueChanges.pipe(startWith(this.formControl.value))
|
|
286
|
+
]).pipe(switchMap(([val, formValue]) => __awaiter(this, void 0, void 0, function* () {
|
|
290
287
|
if (typeof (__classPrivateFieldGet(this, _items)) === 'function') {
|
|
291
288
|
return yield __classPrivateFieldGet(this, _loadItems).call(this, val, __classPrivateFieldGet(this, _items));
|
|
292
289
|
}
|
|
293
290
|
const { changeAliasLowerCase } = this.utilityService;
|
|
294
291
|
const searchText = changeAliasLowerCase(val);
|
|
295
|
-
const formValue = this.formControl.value;
|
|
296
292
|
const isArray = Array.isArray(formValue);
|
|
297
293
|
const hasFields = !!this.valueField && !!this.displayField;
|
|
298
294
|
return __classPrivateFieldGet(this, _items).filter(item => {
|
|
@@ -333,19 +329,22 @@ class SdSelect {
|
|
|
333
329
|
return 0;
|
|
334
330
|
});
|
|
335
331
|
}))));
|
|
336
|
-
this
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
this.display = combineLatest([__classPrivateFieldGet(this, _allItems), this.formControl.valueChanges.pipe(startWith(this.formControl.value))]).pipe(map(([items, formValue]) => {
|
|
341
|
-
const isArray = Array.isArray(formValue);
|
|
342
|
-
if (!this.valueField || !this.displayField) {
|
|
343
|
-
return isArray ? formValue === null || formValue === void 0 ? void 0 : formValue.join(', ') : formValue;
|
|
332
|
+
__classPrivateFieldSet(this, _selectedItems, __classPrivateFieldGet(this, _allItems).pipe(map(items => {
|
|
333
|
+
const formValue = this.formControl.value;
|
|
334
|
+
if (!(formValue === null || formValue === void 0 ? void 0 : formValue.toString())) {
|
|
335
|
+
return [];
|
|
344
336
|
}
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
.
|
|
348
|
-
|
|
337
|
+
const values = Array.isArray(formValue) ? formValue : [formValue];
|
|
338
|
+
this.selectedItems = values.map(val => {
|
|
339
|
+
if (this.valueField) {
|
|
340
|
+
return items === null || items === void 0 ? void 0 : items.find(item => item[this.valueField] === val);
|
|
341
|
+
}
|
|
342
|
+
return val;
|
|
343
|
+
});
|
|
344
|
+
return this.selectedItems;
|
|
345
|
+
})));
|
|
346
|
+
this.filteredItems = __classPrivateFieldGet(this, _allItems).pipe(map(allItems => allItems.filter((item, index) => index < this.limit)));
|
|
347
|
+
this.display = __classPrivateFieldGet(this, _selectedItems).pipe(map(selectedItems => { var _a; return (_a = selectedItems === null || selectedItems === void 0 ? void 0 : selectedItems.map(item => this.displayField ? item[this.displayField] : item)) === null || _a === void 0 ? void 0 : _a.join(', '); }));
|
|
349
348
|
}
|
|
350
349
|
ngAfterViewInit() {
|
|
351
350
|
var _a;
|
|
@@ -366,13 +365,13 @@ class SdSelect {
|
|
|
366
365
|
__classPrivateFieldGet(this, _onChange).call(this, this.formControl.value);
|
|
367
366
|
}
|
|
368
367
|
}
|
|
369
|
-
_input = new WeakMap(), _name = new WeakMap(), _form = new WeakMap(), _items = new WeakMap(),
|
|
368
|
+
_input = new WeakMap(), _name = new WeakMap(), _form = new WeakMap(), _items = new WeakMap(), _delay = new WeakMap(), _validator = new WeakMap(), _subscription = new WeakMap(), _selectedItems = new WeakMap(), _allItems = new WeakMap(), _allItem = new WeakMap(), _updateValidator = new WeakMap(), _loadSelectedItems = new WeakMap(), _loadItems = new WeakMap(), _onChange = new WeakMap(), _customValidator = new WeakMap();
|
|
370
369
|
SdSelect.decorators = [
|
|
371
370
|
{ type: Component, args: [{
|
|
372
371
|
selector: 'sd-select',
|
|
373
|
-
template: "<div class=\"d-flex align-items-center\">\r\n <mat-form-field class=\"sd-md\" [ngClass]=\"{'sd-sm': size === 'sm', 'no-padding-wrapper': disableErrorMessage}\"\r\n
|
|
372
|
+
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 }\">\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\" [value]=\"item[valueField]\" matTooltipPosition=\"above\"\r\n [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 </mat-option>\r\n </ng-container>\r\n <ng-container *ngIf=\"!valueField && !displayField\">\r\n <mat-option *ngFor=\"let item of filteredItems | async\" [value]=\"item\" matTooltipPosition=\"above\"\r\n [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 </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\" [value]=\"item[valueField]\" matTooltipPosition=\"above\"\r\n [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 </mat-option>\r\n </ng-container>\r\n <ng-container *ngIf=\"!valueField && !displayField\">\r\n <mat-option *ngFor=\"let item of filteredItems | async\" [value]=\"item\" matTooltipPosition=\"above\"\r\n [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 </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>",
|
|
374
373
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
375
|
-
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}::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)}"]
|
|
374
|
+
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)}"]
|
|
376
375
|
},] }
|
|
377
376
|
];
|
|
378
377
|
SdSelect.ctorParameters = () => [
|
|
@@ -402,7 +401,8 @@ SdSelect.propDecorators = {
|
|
|
402
401
|
_selectAll: [{ type: Input, args: ['selectAll',] }],
|
|
403
402
|
modelChange: [{ type: Output }],
|
|
404
403
|
sdChange: [{ type: Output }],
|
|
405
|
-
sdSelection: [{ type: Output }]
|
|
404
|
+
sdSelection: [{ type: Output }],
|
|
405
|
+
sdView: [{ type: ContentChild, args: [SdViewDefDirective,] }]
|
|
406
406
|
};
|
|
407
407
|
|
|
408
408
|
class SdSelectModule {
|
|
@@ -420,7 +420,8 @@ SdSelectModule.decorators = [
|
|
|
420
420
|
MatSelectModule,
|
|
421
421
|
MatProgressSpinnerModule,
|
|
422
422
|
MatCheckboxModule,
|
|
423
|
-
SdTranslateModule
|
|
423
|
+
SdTranslateModule,
|
|
424
|
+
SdCommonModule
|
|
424
425
|
],
|
|
425
426
|
declarations: [
|
|
426
427
|
SdSelect,
|
|
@@ -428,7 +429,8 @@ SdSelectModule.decorators = [
|
|
|
428
429
|
],
|
|
429
430
|
exports: [
|
|
430
431
|
SdSelect,
|
|
431
|
-
SdSelectDisplayDefDirective
|
|
432
|
+
SdSelectDisplayDefDirective,
|
|
433
|
+
SdCommonModule
|
|
432
434
|
],
|
|
433
435
|
providers: []
|
|
434
436
|
},] }
|