@sd-angular/core 19.0.31 → 19.0.32
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/components/data-state/index.d.ts +1 -0
- package/components/data-state/src/data-state.component.d.ts +41 -0
- package/components/import-excel/src/import-excel.component.d.ts +23 -1
- package/components/index.d.ts +1 -0
- package/components/quick-action/src/quick-action.component.d.ts +3 -1
- package/components/table/src/components/selector-action/selector-action.component.d.ts +11 -0
- package/components/table/src/table.component.d.ts +10 -1
- package/components/upload-file/src/upload-file.component.d.ts +5 -1
- package/fesm2022/sd-angular-core-components-button.mjs +2 -2
- package/fesm2022/sd-angular-core-components-button.mjs.map +1 -1
- package/fesm2022/sd-angular-core-components-data-state.mjs +72 -0
- package/fesm2022/sd-angular-core-components-data-state.mjs.map +1 -0
- package/fesm2022/sd-angular-core-components-form-generic.mjs +14 -14
- package/fesm2022/sd-angular-core-components-form-generic.mjs.map +1 -1
- package/fesm2022/sd-angular-core-components-import-excel.mjs +67 -18
- package/fesm2022/sd-angular-core-components-import-excel.mjs.map +1 -1
- package/fesm2022/sd-angular-core-components-inform.mjs +6 -6
- package/fesm2022/sd-angular-core-components-inform.mjs.map +1 -1
- package/fesm2022/sd-angular-core-components-query-bar.mjs +3 -3
- package/fesm2022/sd-angular-core-components-query-bar.mjs.map +1 -1
- package/fesm2022/sd-angular-core-components-query-builder.mjs +1 -1
- package/fesm2022/sd-angular-core-components-query-builder.mjs.map +1 -1
- package/fesm2022/sd-angular-core-components-quick-action.mjs +4 -2
- package/fesm2022/sd-angular-core-components-quick-action.mjs.map +1 -1
- package/fesm2022/sd-angular-core-components-stepper.mjs +2 -2
- package/fesm2022/sd-angular-core-components-stepper.mjs.map +1 -1
- package/fesm2022/sd-angular-core-components-table.mjs +119 -26
- package/fesm2022/sd-angular-core-components-table.mjs.map +1 -1
- package/fesm2022/sd-angular-core-components-tree.mjs +1 -1
- package/fesm2022/sd-angular-core-components-tree.mjs.map +1 -1
- package/fesm2022/sd-angular-core-components-upload-file.mjs +20 -6
- package/fesm2022/sd-angular-core-components-upload-file.mjs.map +1 -1
- package/fesm2022/sd-angular-core-components.mjs +1 -0
- package/fesm2022/sd-angular-core-components.mjs.map +1 -1
- package/fesm2022/sd-angular-core-forms-autocomplete.mjs +247 -59
- package/fesm2022/sd-angular-core-forms-autocomplete.mjs.map +1 -1
- package/fesm2022/sd-angular-core-forms-date-range.mjs +2 -2
- package/fesm2022/sd-angular-core-forms-date-range.mjs.map +1 -1
- package/fesm2022/sd-angular-core-forms-date.mjs +2 -2
- package/fesm2022/sd-angular-core-forms-date.mjs.map +1 -1
- package/fesm2022/sd-angular-core-forms-datetime.mjs +2 -2
- package/fesm2022/sd-angular-core-forms-datetime.mjs.map +1 -1
- package/fesm2022/sd-angular-core-forms-select.mjs +290 -67
- package/fesm2022/sd-angular-core-forms-select.mjs.map +1 -1
- package/fesm2022/sd-angular-core-i18n.mjs +155 -0
- package/fesm2022/sd-angular-core-i18n.mjs.map +1 -1
- package/fesm2022/sd-angular-core-modules-layout.mjs +6 -6
- package/fesm2022/sd-angular-core-modules-layout.mjs.map +1 -1
- package/fesm2022/sd-angular-core-services-confirm.mjs +43 -7
- package/fesm2022/sd-angular-core-services-confirm.mjs.map +1 -1
- package/fesm2022/sd-angular-core-services-notify.mjs +2 -2
- package/fesm2022/sd-angular-core-services-notify.mjs.map +1 -1
- package/fesm2022/sd-angular-core-utilities-read-state.mjs +87 -0
- package/fesm2022/sd-angular-core-utilities-read-state.mjs.map +1 -0
- package/fesm2022/sd-angular-core-utilities.mjs +1 -0
- package/fesm2022/sd-angular-core-utilities.mjs.map +1 -1
- package/forms/autocomplete/src/autocomplete.component.d.ts +13 -2
- package/forms/select/src/select.component.d.ts +11 -1
- package/i18n/src/en.d.ts +31 -0
- package/package.json +9 -1
- package/services/confirm/src/lib/components/dialog-confirm/dialog-confirm.component.d.ts +4 -0
- package/services/confirm/src/lib/confirm.service.d.ts +6 -0
- package/utilities/index.d.ts +1 -0
- package/utilities/read-state/index.d.ts +1 -0
- package/utilities/read-state/src/read-state.d.ts +37 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as i1 from '@angular/common';
|
|
2
2
|
import { CommonModule } from '@angular/common';
|
|
3
3
|
import * as i0 from '@angular/core';
|
|
4
|
-
import { viewChild, contentChild, inject, ChangeDetectorRef, input, computed, booleanAttribute,
|
|
4
|
+
import { viewChild, contentChild, inject, ChangeDetectorRef, ElementRef, input, computed, booleanAttribute, output, signal, model, EventEmitter, effect, untracked, Output, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
5
5
|
import { toObservable } from '@angular/core/rxjs-interop';
|
|
6
6
|
import * as i2 from '@angular/forms';
|
|
7
7
|
import { NgForm, FormGroup, Validators, FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
@@ -17,6 +17,8 @@ import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
|
|
17
17
|
import * as i4 from '@angular/material/tooltip';
|
|
18
18
|
import { MatTooltipModule } from '@angular/material/tooltip';
|
|
19
19
|
import { SdView } from '@sd-angular/core/components/view';
|
|
20
|
+
import { SdDataStateTemplateDirective, SdDataState } from '@sd-angular/core/components/data-state';
|
|
21
|
+
import { SdReadChannel, combineReadStates, cloneReadRequest } from '@sd-angular/core/utilities/read-state';
|
|
20
22
|
import { SdItemDefDefDirective, SdViewDefDirective } from '@sd-angular/core/forms/directives';
|
|
21
23
|
import { SdLabel } from '@sd-angular/core/forms/label';
|
|
22
24
|
import { SD_FORM_CONFIGURATION, sdFormControlState, sdViewedTransform, sdViewedInline, SdFormControl, HandleSdCustomValidator, SdInlineErrorValidator } from '@sd-angular/core/forms/models';
|
|
@@ -24,8 +26,8 @@ import { I18nService } from '@sd-angular/core/i18n';
|
|
|
24
26
|
import { sdIsEmpty, sdSerializeDataValue } from '@sd-angular/core/utilities/data-state';
|
|
25
27
|
import { ArrayUtilities } from '@sd-angular/core/utilities/extensions';
|
|
26
28
|
import { Utilities } from '@sdcorejs/utils/fns';
|
|
27
|
-
import { Subscription, combineLatest, timer, of, defer, from } from 'rxjs';
|
|
28
|
-
import { tap,
|
|
29
|
+
import { Subscription, Subject, combineLatest, merge, timer, of, defer, EMPTY, from } from 'rxjs';
|
|
30
|
+
import { map, tap, shareReplay, startWith, debounce, takeUntil, switchMap, filter, catchError, finalize } from 'rxjs/operators';
|
|
29
31
|
|
|
30
32
|
/* eslint-disable @angular-eslint/component-class-suffix */
|
|
31
33
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
@@ -57,6 +59,7 @@ class SdAutocomplete {
|
|
|
57
59
|
ref = inject(ChangeDetectorRef);
|
|
58
60
|
formConfig = inject(SD_FORM_CONFIGURATION, { optional: true });
|
|
59
61
|
#i18n = inject(I18nService);
|
|
62
|
+
#element = inject(ElementRef);
|
|
60
63
|
// ==========================================
|
|
61
64
|
// 3. SIGNAL INPUTS & MODEL
|
|
62
65
|
// ==========================================
|
|
@@ -105,6 +108,13 @@ class SdAutocomplete {
|
|
|
105
108
|
hyperlink = input();
|
|
106
109
|
items = input();
|
|
107
110
|
hideInlineError = input(false, { transform: booleanAttribute });
|
|
111
|
+
hideReadError = input(false, { transform: booleanAttribute });
|
|
112
|
+
dataStateTemplate = contentChild(SdDataStateTemplateDirective);
|
|
113
|
+
sdReadStateChange = output();
|
|
114
|
+
#valueRead = new SdReadChannel('VALUE', () => this.#emitReadState());
|
|
115
|
+
#searchRead = new SdReadChannel('SEARCH', () => this.#emitReadState());
|
|
116
|
+
readState = computed(() => combineReadStates(this.#valueRead.state(), this.#searchRead.state()));
|
|
117
|
+
hasSearched = signal(false);
|
|
108
118
|
addable = input(false, { transform: booleanAttribute });
|
|
109
119
|
required = input(false, { transform: booleanAttribute });
|
|
110
120
|
disabled = input(false, { transform: booleanAttribute });
|
|
@@ -162,8 +172,24 @@ class SdAutocomplete {
|
|
|
162
172
|
#cache = {};
|
|
163
173
|
#item = {};
|
|
164
174
|
#subscription = new Subscription();
|
|
175
|
+
#destroyed = false;
|
|
176
|
+
#searchDebouncing = false;
|
|
177
|
+
#lastSearchText = '';
|
|
178
|
+
#restoringReadFocus = false;
|
|
179
|
+
#valueCache = {};
|
|
180
|
+
#failedValue;
|
|
181
|
+
#failedSearch;
|
|
182
|
+
#valueRetryRequest;
|
|
183
|
+
#searchRetryRequest;
|
|
184
|
+
#retrySearch = new Subject();
|
|
185
|
+
#retryValue = new Subject();
|
|
165
186
|
// RXJS STREAMS
|
|
166
|
-
#items$ = toObservable(
|
|
187
|
+
#items$ = toObservable(computed(() => ({
|
|
188
|
+
items: this.items(),
|
|
189
|
+
checksum: this.cacheChecksum(),
|
|
190
|
+
valueField: this.valueField(),
|
|
191
|
+
displayField: this.displayField(),
|
|
192
|
+
}))).pipe(map(context => context.items));
|
|
167
193
|
#valueModel$ = toObservable(this.valueModel);
|
|
168
194
|
// PUBLIC SIGNALS (Render View)
|
|
169
195
|
filteredItems = signal([]);
|
|
@@ -187,6 +213,19 @@ class SdAutocomplete {
|
|
|
187
213
|
return result;
|
|
188
214
|
};
|
|
189
215
|
constructor() {
|
|
216
|
+
effect(() => {
|
|
217
|
+
this.items();
|
|
218
|
+
this.valueModel();
|
|
219
|
+
this.cacheChecksum();
|
|
220
|
+
this.valueField();
|
|
221
|
+
this.displayField();
|
|
222
|
+
untracked(() => {
|
|
223
|
+
if (this.#failedValue && !this.#failedValue.valid()) {
|
|
224
|
+
this.#failedValue = undefined;
|
|
225
|
+
this.#valueRead.invalidate();
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
});
|
|
190
229
|
effect(() => {
|
|
191
230
|
const val = this.normalizedValue();
|
|
192
231
|
untracked(() => {
|
|
@@ -224,22 +263,46 @@ class SdAutocomplete {
|
|
|
224
263
|
}));
|
|
225
264
|
this.#subscription.add(this.formControl.sdChanges.subscribe(() => this.ref.markForCheck()));
|
|
226
265
|
this.#subscription.add(this.inputControl.sdChanges.subscribe(() => this.ref.markForCheck()));
|
|
227
|
-
this.#
|
|
266
|
+
this.#element.nativeElement.addEventListener('keydown', this.focusReadRetry, true);
|
|
267
|
+
this.#subscription.add(this.inputControl.valueChanges.subscribe(value => {
|
|
268
|
+
this.isTyping.set(true);
|
|
269
|
+
this.hasSearched.set(true);
|
|
270
|
+
this.#searchDebouncing = typeof this.items() === 'function';
|
|
271
|
+
const text = value || '';
|
|
272
|
+
if (text !== this.#lastSearchText) {
|
|
273
|
+
this.#failedSearch = undefined;
|
|
274
|
+
this.#searchRead.invalidate();
|
|
275
|
+
this.#lastSearchText = text;
|
|
276
|
+
}
|
|
277
|
+
this.#syncReadLoading();
|
|
278
|
+
}));
|
|
228
279
|
const cleanItems$ = this.#items$.pipe(tap(() => {
|
|
229
280
|
this.#cache = {};
|
|
281
|
+
this.#item = {};
|
|
282
|
+
this.#valueCache = {};
|
|
283
|
+
this.#failedValue = this.#failedSearch = undefined;
|
|
284
|
+
this.#valueRetryRequest = this.#searchRetryRequest = undefined;
|
|
285
|
+
this.#valueRead.invalidate();
|
|
286
|
+
this.#searchRead.invalidate();
|
|
230
287
|
}), map(items => {
|
|
231
288
|
if (!items)
|
|
232
289
|
return [];
|
|
233
290
|
if (Array.isArray(items))
|
|
234
291
|
return items.filter(e => e !== null && e !== undefined);
|
|
235
292
|
return items;
|
|
236
|
-
}));
|
|
293
|
+
}), shareReplay({ bufferSize: 1, refCount: true }));
|
|
237
294
|
const filteredItems$ = combineLatest([
|
|
238
295
|
cleanItems$,
|
|
239
|
-
this.inputControl.valueChanges.pipe(startWith(''),
|
|
240
|
-
|
|
296
|
+
merge(this.inputControl.valueChanges.pipe(startWith(''),
|
|
297
|
+
// why: retry thay thế debounce đang chờ; text cũ không được phát thêm một request sau retry.
|
|
298
|
+
debounce(() => timer(typeof this.items() === 'function' ? 500 : 0).pipe(takeUntil(this.#retrySearch)))), this.#retrySearch),
|
|
299
|
+
]).pipe(tap(() => {
|
|
300
|
+
this.isTyping.set(false);
|
|
301
|
+
this.#searchDebouncing = false;
|
|
302
|
+
}), switchMap(([items, searchText]) => {
|
|
241
303
|
const sText = searchText || '';
|
|
242
304
|
if (typeof items !== 'function') {
|
|
305
|
+
this.#syncReadLoading();
|
|
243
306
|
// [UPDATED]: Hỗ trợ search lồng nhau (nested) local
|
|
244
307
|
const filtered = items.filter((e) => {
|
|
245
308
|
const v = String(this.getNestedValue(e, this.valueField()) || '').toLowerCase();
|
|
@@ -249,64 +312,39 @@ class SdAutocomplete {
|
|
|
249
312
|
});
|
|
250
313
|
return of(ArrayUtilities.paging(filtered, this.limit()));
|
|
251
314
|
}
|
|
252
|
-
const
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
}
|
|
259
|
-
this.loading.set(true);
|
|
260
|
-
let obs;
|
|
261
|
-
const func = items({ type: 'SEARCH', searchText: sText });
|
|
262
|
-
if (func instanceof Promise)
|
|
263
|
-
obs = defer(() => from(func));
|
|
264
|
-
else
|
|
265
|
-
obs = func;
|
|
266
|
-
return obs.pipe(map(data => {
|
|
267
|
-
this.#cache[key] = data || [];
|
|
268
|
-
// [UPDATED]: Lưu cache #item theo nested value
|
|
269
|
-
(this.#cache[key] || []).forEach((e) => {
|
|
270
|
-
const valKey = this.getNestedValue(e, this.valueField());
|
|
271
|
-
if (valKey != null) {
|
|
272
|
-
this.#item[valKey] = e;
|
|
273
|
-
}
|
|
274
|
-
});
|
|
275
|
-
return this.#cache[key];
|
|
276
|
-
}), catchError(() => of([])));
|
|
277
|
-
}), tap(() => this.loading.set(false)));
|
|
278
|
-
const selected$ = combineLatest([cleanItems$, this.#valueModel$]).pipe(switchMap(([items, val]) => {
|
|
315
|
+
const retry = this.#searchRetryRequest;
|
|
316
|
+
this.#searchRetryRequest = undefined;
|
|
317
|
+
const request = retry?.valid() ? retry : this.#createReadRequest(items, { type: 'SEARCH', searchText: sText });
|
|
318
|
+
return this.#readItems(request, retry === request);
|
|
319
|
+
}));
|
|
320
|
+
const selected$ = combineLatest([cleanItems$, this.#valueModel$, this.#retryValue.pipe(startWith(undefined))]).pipe(switchMap(([items, val]) => {
|
|
279
321
|
const vField = this.valueField();
|
|
280
322
|
const dField = this.displayField();
|
|
281
|
-
if (!vField)
|
|
323
|
+
if (!vField) {
|
|
324
|
+
this.#valueRead.invalidate();
|
|
282
325
|
return of(val);
|
|
326
|
+
}
|
|
283
327
|
if (val || val === 0) {
|
|
284
328
|
if (typeof items === 'function') {
|
|
285
|
-
|
|
329
|
+
const retry = this.#valueRetryRequest;
|
|
330
|
+
this.#valueRetryRequest = undefined;
|
|
331
|
+
const request = retry?.valid() ? retry : this.#createReadRequest(items, { type: 'VALUE', value: val });
|
|
332
|
+
if (!retry && this.#item[val] && !this.#failedValue?.valid()) {
|
|
333
|
+
const revision = this.#valueRead.begin(request.valid);
|
|
334
|
+
this.#valueRead.succeed(revision, 1);
|
|
286
335
|
return of(this.#item[val]);
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
const func = items({ type: 'VALUE', value: val });
|
|
290
|
-
if (func instanceof Promise)
|
|
291
|
-
obs = defer(() => from(func));
|
|
292
|
-
else
|
|
293
|
-
obs = func;
|
|
294
|
-
return obs.pipe(map(data => {
|
|
295
|
-
// [UPDATED]: Lưu cache #item theo nested value
|
|
296
|
-
(data || []).forEach((e) => {
|
|
297
|
-
const valKey = this.getNestedValue(e, vField);
|
|
298
|
-
if (valKey != null) {
|
|
299
|
-
this.#item[valKey] = e;
|
|
300
|
-
}
|
|
301
|
-
});
|
|
302
|
-
return this.#item[val] || { [vField]: val, [dField]: val };
|
|
303
|
-
}), catchError(() => of({ [vField]: val, [dField]: val })));
|
|
336
|
+
}
|
|
337
|
+
return this.#readItems(request, retry === request).pipe(map(() => this.#item[val] || { [vField]: val, [dField]: val }));
|
|
304
338
|
}
|
|
305
339
|
// [UPDATED]: Tìm local theo nested field
|
|
306
340
|
return of(items.find((e) => this.getNestedValue(e, vField) === val));
|
|
307
341
|
}
|
|
342
|
+
this.#failedValue = undefined;
|
|
343
|
+
this.#valueRead.invalidate();
|
|
308
344
|
return of('');
|
|
309
|
-
}),
|
|
345
|
+
}),
|
|
346
|
+
// why: ba subscriber (selected/display/placeholder) dùng chung một request VALUE.
|
|
347
|
+
shareReplay({ bufferSize: 1, refCount: true }));
|
|
310
348
|
const controlPlaceHolder$ = selected$.pipe(map((item) => {
|
|
311
349
|
// [UPDATED]: Đọc PlaceHolder bằng getNestedValue
|
|
312
350
|
const dispVal = this.getNestedValue(item, this.displayField());
|
|
@@ -345,6 +383,10 @@ class SdAutocomplete {
|
|
|
345
383
|
formGroup?.addControl(this.name(), this.formControl);
|
|
346
384
|
}
|
|
347
385
|
ngOnDestroy() {
|
|
386
|
+
this.#destroyed = true;
|
|
387
|
+
this.#element.nativeElement.removeEventListener('keydown', this.focusReadRetry, true);
|
|
388
|
+
this.#valueRead.invalidate();
|
|
389
|
+
this.#searchRead.invalidate();
|
|
348
390
|
this.#subscription.unsubscribe();
|
|
349
391
|
const formGroup = this.form();
|
|
350
392
|
formGroup?.removeControl(this.name());
|
|
@@ -379,19 +421,66 @@ class SdAutocomplete {
|
|
|
379
421
|
this.sdSelection.emit({ values: [val], selectedItems: [item], value: val, selectedItem: item });
|
|
380
422
|
}
|
|
381
423
|
}
|
|
382
|
-
this
|
|
424
|
+
this.#resetSearchText();
|
|
383
425
|
};
|
|
384
426
|
onFocus = () => {
|
|
427
|
+
this.hasSearched.set(true);
|
|
385
428
|
this.isFocused = true;
|
|
429
|
+
if (this.#restoringReadFocus || this.#failedSearch?.valid())
|
|
430
|
+
return;
|
|
386
431
|
this.filteredItems.set([]);
|
|
387
432
|
if (typeof this.items() === 'function') {
|
|
388
433
|
this.loading.set(true);
|
|
389
434
|
}
|
|
390
435
|
this.inputControl.setValue('', { emitEvent: true });
|
|
391
436
|
};
|
|
392
|
-
onBlur = () => {
|
|
437
|
+
onBlur = (event) => {
|
|
438
|
+
// why: Tab vào retry thuộc cùng control, không đổi snapshot text hoặc selection.
|
|
439
|
+
if (event?.relatedTarget instanceof Node && this.#readRegion()?.contains(event.relatedTarget))
|
|
440
|
+
return;
|
|
393
441
|
this.isFocused = false;
|
|
442
|
+
this.#resetSearchText();
|
|
443
|
+
};
|
|
444
|
+
#resetSearchText = () => {
|
|
445
|
+
const changed = !!this.inputControl.value;
|
|
394
446
|
this.inputControl.setValue('', { emitEvent: false });
|
|
447
|
+
this.#lastSearchText = '';
|
|
448
|
+
this.#searchDebouncing = false;
|
|
449
|
+
this.isTyping.set(false);
|
|
450
|
+
if (changed) {
|
|
451
|
+
this.#failedSearch = undefined;
|
|
452
|
+
this.#searchRead.invalidate();
|
|
453
|
+
}
|
|
454
|
+
this.#syncReadLoading();
|
|
455
|
+
};
|
|
456
|
+
#readRegion = () => this.autocompleteTrigger()?.autocomplete.panel?.nativeElement.querySelector('.sd-read-state-region') ?? null;
|
|
457
|
+
focusReadRetry = (event) => {
|
|
458
|
+
if (event.key !== 'Tab' || event.shiftKey || !this.autocompleteTrigger()?.panelOpen)
|
|
459
|
+
return;
|
|
460
|
+
const button = this.#readRegion()?.querySelector('button:not([disabled]), [tabindex="0"]');
|
|
461
|
+
if (!button)
|
|
462
|
+
return;
|
|
463
|
+
event.preventDefault();
|
|
464
|
+
event.stopImmediatePropagation();
|
|
465
|
+
button.focus();
|
|
466
|
+
};
|
|
467
|
+
onReadRegionKeydown = (event) => {
|
|
468
|
+
event.stopPropagation();
|
|
469
|
+
if (event.key === 'Escape' || (event.key === 'Tab' && event.shiftKey)) {
|
|
470
|
+
event.preventDefault();
|
|
471
|
+
this.#restoreReadFocus();
|
|
472
|
+
if (event.key === 'Escape')
|
|
473
|
+
this.autocompleteTrigger()?.closePanel();
|
|
474
|
+
}
|
|
475
|
+
else if (event.key === 'Tab') {
|
|
476
|
+
this.autocompleteTrigger()?.closePanel();
|
|
477
|
+
this.#restoreReadFocus();
|
|
478
|
+
}
|
|
479
|
+
};
|
|
480
|
+
#restoreReadFocus = () => {
|
|
481
|
+
this.#restoringReadFocus = true;
|
|
482
|
+
this.inputRef()?.nativeElement.focus();
|
|
483
|
+
this.#restoringReadFocus = false;
|
|
395
484
|
};
|
|
396
485
|
onClick = () => {
|
|
397
486
|
if (this.sdViewDef()?.templateRef) {
|
|
@@ -435,6 +524,103 @@ class SdAutocomplete {
|
|
|
435
524
|
reValidate = () => {
|
|
436
525
|
this.inputControl.updateValueAndValidity({ emitEvent: true });
|
|
437
526
|
};
|
|
527
|
+
#createReadRequest = (loader, args) => {
|
|
528
|
+
const checksum = Utilities.hash({ checksum: this.cacheChecksum(), valueField: this.valueField(), displayField: this.displayField() });
|
|
529
|
+
const key = Utilities.hash({ checksum, args });
|
|
530
|
+
return {
|
|
531
|
+
loader,
|
|
532
|
+
args: cloneReadRequest(args),
|
|
533
|
+
key,
|
|
534
|
+
valid: () => !this.#destroyed &&
|
|
535
|
+
this.items() === loader &&
|
|
536
|
+
checksum === Utilities.hash({ checksum: this.cacheChecksum(), valueField: this.valueField(), displayField: this.displayField() }) &&
|
|
537
|
+
key ===
|
|
538
|
+
Utilities.hash({
|
|
539
|
+
checksum,
|
|
540
|
+
args: args.type === 'VALUE'
|
|
541
|
+
? { type: 'VALUE', value: this.valueModel() }
|
|
542
|
+
: { type: 'SEARCH', searchText: this.inputControl.value || '' },
|
|
543
|
+
}),
|
|
544
|
+
};
|
|
545
|
+
};
|
|
546
|
+
#readItems = (request, retry) => defer(() => {
|
|
547
|
+
const valueRequest = request.args.type === 'VALUE';
|
|
548
|
+
const channel = valueRequest ? this.#valueRead : this.#searchRead;
|
|
549
|
+
const failed = valueRequest ? this.#failedValue : this.#failedSearch;
|
|
550
|
+
if (!request.valid())
|
|
551
|
+
return EMPTY;
|
|
552
|
+
if (!retry && failed?.key === request.key && failed.valid()) {
|
|
553
|
+
this.#syncReadLoading();
|
|
554
|
+
return EMPTY;
|
|
555
|
+
}
|
|
556
|
+
const revision = channel.begin(request.valid);
|
|
557
|
+
if (valueRequest)
|
|
558
|
+
this.#failedValue = undefined;
|
|
559
|
+
else
|
|
560
|
+
this.#failedSearch = undefined;
|
|
561
|
+
const cache = valueRequest ? this.#valueCache : this.#cache;
|
|
562
|
+
if (!retry && cache[request.key] !== undefined) {
|
|
563
|
+
channel.succeed(revision, cache[request.key].length);
|
|
564
|
+
return of(cache[request.key]);
|
|
565
|
+
}
|
|
566
|
+
// why: defer bao quanh chính lời gọi loader để bắt cả throw đồng bộ; from giữ Promise/Observable.
|
|
567
|
+
return defer(() => from(request.loader(cloneReadRequest(request.args)))).pipe(filter(() => channel.isCurrent(revision)), map(data => data || []), tap(data => {
|
|
568
|
+
cache[request.key] = data;
|
|
569
|
+
data.forEach(item => {
|
|
570
|
+
const key = this.getNestedValue(item, this.valueField());
|
|
571
|
+
if (key != null)
|
|
572
|
+
this.#item[key] = item;
|
|
573
|
+
});
|
|
574
|
+
channel.succeed(revision, data.length);
|
|
575
|
+
}), filter(() => channel.isCurrent(revision)), catchError(error => {
|
|
576
|
+
if (channel.isCurrent(revision)) {
|
|
577
|
+
if (valueRequest)
|
|
578
|
+
this.#failedValue = request;
|
|
579
|
+
else
|
|
580
|
+
this.#failedSearch = request;
|
|
581
|
+
channel.fail(revision, error);
|
|
582
|
+
}
|
|
583
|
+
return EMPTY;
|
|
584
|
+
}), finalize(() => {
|
|
585
|
+
// why: cleanup của request cũ không đổi state/loading của request mới.
|
|
586
|
+
if (channel.isCurrent(revision)) {
|
|
587
|
+
if (channel.state().status === 'loading')
|
|
588
|
+
channel.invalidate();
|
|
589
|
+
this.#syncReadLoading();
|
|
590
|
+
}
|
|
591
|
+
}));
|
|
592
|
+
});
|
|
593
|
+
#syncReadLoading = () => {
|
|
594
|
+
if (this.#destroyed)
|
|
595
|
+
return;
|
|
596
|
+
this.loading.set(this.#searchDebouncing || this.#valueRead.state().status === 'loading' || this.#searchRead.state().status === 'loading');
|
|
597
|
+
this.ref.markForCheck();
|
|
598
|
+
};
|
|
599
|
+
#emitReadState = () => {
|
|
600
|
+
if (this.#destroyed)
|
|
601
|
+
return;
|
|
602
|
+
this.#syncReadLoading();
|
|
603
|
+
this.sdReadStateChange.emit(this.readState());
|
|
604
|
+
};
|
|
605
|
+
/** Retry bypasses text debounce/distinctness while using the original loader and request snapshot. */
|
|
606
|
+
retryRead = () => {
|
|
607
|
+
const state = this.readState();
|
|
608
|
+
if (state.status !== 'error')
|
|
609
|
+
return;
|
|
610
|
+
const request = state.operation === 'VALUE' ? this.#failedValue : this.#failedSearch;
|
|
611
|
+
if (!request?.valid())
|
|
612
|
+
return;
|
|
613
|
+
if (this.#readRegion()?.contains(this.#element.nativeElement.ownerDocument.activeElement))
|
|
614
|
+
this.#restoreReadFocus();
|
|
615
|
+
if (state.operation === 'VALUE') {
|
|
616
|
+
this.#valueRetryRequest = request;
|
|
617
|
+
this.#retryValue.next();
|
|
618
|
+
}
|
|
619
|
+
else {
|
|
620
|
+
this.#searchRetryRequest = request;
|
|
621
|
+
this.#retrySearch.next(request.args.searchText || '');
|
|
622
|
+
}
|
|
623
|
+
};
|
|
438
624
|
#updateValidator = (req, val, inl) => {
|
|
439
625
|
const validators = [];
|
|
440
626
|
const asyncValidators = [];
|
|
@@ -449,11 +635,13 @@ class SdAutocomplete {
|
|
|
449
635
|
this.formControl.updateValueAndValidity({ emitEvent: false });
|
|
450
636
|
};
|
|
451
637
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.21", ngImport: i0, type: SdAutocomplete, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
452
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.21", type: SdAutocomplete, isStandalone: true, selector: "sd-autocomplete", inputs: { autoIdInput: { classPropertyName: "autoIdInput", publicName: "autoId", isSignal: true, isRequired: false, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, form: { classPropertyName: "form", publicName: "form", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, helperText: { classPropertyName: "helperText", publicName: "helperText", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, valueField: { classPropertyName: "valueField", publicName: "valueField", isSignal: true, isRequired: false, transformFunction: null }, displayField: { classPropertyName: "displayField", publicName: "displayField", isSignal: true, isRequired: false, transformFunction: null }, disabledField: { classPropertyName: "disabledField", publicName: "disabledField", isSignal: true, isRequired: false, transformFunction: null }, limit: { classPropertyName: "limit", publicName: "limit", isSignal: true, isRequired: false, transformFunction: null }, cacheChecksum: { classPropertyName: "cacheChecksum", publicName: "cacheChecksum", isSignal: true, isRequired: false, transformFunction: null }, hyperlink: { classPropertyName: "hyperlink", publicName: "hyperlink", isSignal: true, isRequired: false, transformFunction: null }, items: { classPropertyName: "items", publicName: "items", isSignal: true, isRequired: false, transformFunction: null }, hideInlineError: { classPropertyName: "hideInlineError", publicName: "hideInlineError", isSignal: true, isRequired: false, transformFunction: null }, addable: { classPropertyName: "addable", publicName: "addable", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, viewed: { classPropertyName: "viewed", publicName: "viewed", isSignal: true, isRequired: false, transformFunction: null }, clearable: { classPropertyName: "clearable", publicName: "clearable", isSignal: true, isRequired: false, transformFunction: null }, validator: { classPropertyName: "validator", publicName: "validator", isSignal: true, isRequired: false, transformFunction: null }, inlineError: { classPropertyName: "inlineError", publicName: "inlineError", isSignal: true, isRequired: false, transformFunction: null }, appearanceInput: { classPropertyName: "appearanceInput", publicName: "appearance", isSignal: true, isRequired: false, transformFunction: null }, valueModel: { classPropertyName: "valueModel", publicName: "model", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { valueModel: "modelChange", sdChange: "sdChange", sdSelection: "sdSelection", sdAdd: "sdAdd" }, host: { properties: { "class.sd-has-label": "!!label()", "class.sd-viewed": "isViewed() || isInline()", "class.sd-bare": "isInline()" } }, queries: [{ propertyName: "sdLabelTemplate", first: true, predicate: ["sdLabel"], descendants: true, isSignal: true }, { propertyName: "sdValueTemplate", first: true, predicate: ["sdValue"], descendants: true, isSignal: true }, { propertyName: "itemDef", first: true, predicate: SdItemDefDefDirective, descendants: true, isSignal: true }, { propertyName: "sdViewDef", first: true, predicate: SdViewDefDirective, descendants: true, isSignal: true }], viewQueries: [{ propertyName: "inputRef", first: true, predicate: ["input"], descendants: true, isSignal: true }, { propertyName: "autocompleteTrigger", first: true, predicate: MatAutocompleteTrigger, descendants: true, isSignal: true }], ngImport: i0, template: "@let _label = label();\n@let _appearance = appearance();\n@let _hideInlineError = hideInlineError();\n@let _errorMessage = errorMessage();\n@let _helperText = helperText();\n@let _required = required();\n@let _displayField = displayField();\n@let _disabledField = disabledField();\n@let iDefTpl = itemDef()?.templateRef;\n@let _loading = loading();\n@let nVal = $any(normalizedValue());\n@let _isInline = isInline();\n@let _bare = _isInline;\n@let _hasValue = nVal !== undefined && nVal !== null && nVal !== '';\n\n@if (isViewed()) {\n <sd-view\n [label]=\"_label\"\n [labelTemplate]=\"sdLabelTemplate()\"\n [value]=\"nVal\"\n [display]=\"display()\"\n [hyperlink]=\"hyperlink()\"\n [valueTemplate]=\"viewTemplate()\">\n </sd-view>\n} @else {\n @if (_isInline) {\n <!-- why: inline \u2014 sd-view l\u00E0 \"m\u1EB7t\" + trigger; autocomplete editor render \u1EA9n (.sd-inline-editor) ch\u1EC9 \u0111\u1EC3 m\u1EDF panel. -->\n <span class=\"sd-inline-view\" role=\"button\" tabindex=\"0\" (click)=\"enterInlineEdit()\" (keydown.enter)=\"enterInlineEdit()\">\n <sd-view\n [label]=\"_label\"\n [labelTemplate]=\"sdLabelTemplate()\"\n [value]=\"nVal\"\n [display]=\"display()\"\n [hyperlink]=\"hyperlink()\"\n [valueTemplate]=\"viewTemplate()\">\n </sd-view>\n @if (clearable() && _hasValue && !_required && !formControl.disabled) {\n <button type=\"button\" class=\"sd-inline-clear\" (click)=\"clear($event)\" title=\"X\u00F3a\" aria-label=\"X\u00F3a\">\n <mat-icon>close</mat-icon>\n </button>\n }\n </span>\n }\n\n @if (!_appearance) {\n <ng-content select=\"[sdLabel]\">\n @if (_label) {\n <sd-label [label]=\"_label\" [required]=\"_required\"></sd-label>\n }\n </ng-content>\n }\n\n <div\n class=\"d-flex align-items-center\"\n [class.sd-inline-editor]=\"_isInline\"\n [class.c-focused]=\"isFocused\"\n [class.c-disabled]=\"formControl.disabled\"\n (click)=\"onClick()\"\n aria-hidden=\"true\">\n <mat-form-field\n [class.sd-md]=\"size() === 'md'\"\n [class.sd-sm]=\"size() === 'sm'\"\n [class.hide-inline-error]=\"_hideInlineError\"\n [floatLabel]=\"nVal ? 'always' : 'auto'\"\n [appearance]=\"_appearance || 'outline'\">\n @if (_appearance && _label) {\n <mat-label style=\"display: inline-block\">\n <div style=\"display: flex; align-items: center; gap: 4px\">\n <span>{{ _label }}</span>\n @if (_helperText) {\n <mat-icon [matTooltip]=\"_helperText\" matTooltipPosition=\"below\">info_outline</mat-icon>\n }\n </div>\n </mat-label>\n }\n\n <input\n [id]=\"id\"\n [formControl]=\"inputControl\"\n [placeholder]=\"controlPlaceHolder() || ''\"\n [class.c-selected]=\"nVal\"\n [matAutocomplete]=\"auto\"\n (focus)=\"onFocus()\"\n (blur)=\"onBlur()\"\n matInput\n [autocomplete]=\"id\"\n autocorrect=\"off\"\n [errorStateMatcher]=\"matcher\"\n [required]=\"_required\"\n #input\n #autocompleteTrigger=\"matAutocompleteTrigger\"\n [attr.data-autoId]=\"autoId()\"\n [attr.data-disabled]=\"dataDisabled()\"\n [attr.data-invalid]=\"dataInvalid()\"\n [attr.data-empty]=\"dataEmpty()\"\n [attr.data-value]=\"dataValue()\"\n [attr.data-loading]=\"dataLoading()\"\n [attr.data-required]=\"dataRequired()\"\n [attr.data-error-message]=\"dataErrorMessage()\"\n aria-hidden=\"true\" />\n\n @if (!_loading && nVal && !inputControl.disabled && !_bare) {\n <button type=\"button\" class=\"sd-clear-btn\" matSuffix (click)=\"clear($event)\" title=\"X\u00F3a\" aria-label=\"X\u00F3a\">\n <mat-icon>close</mat-icon>\n </button>\n } @else if (_loading) {\n <mat-spinner [diameter]=\"20\" matSuffix></mat-spinner>\n } @else {\n <mat-icon class=\"cursor-pointer sd-suffix-icon\" matSuffix>search</mat-icon>\n }\n\n <mat-autocomplete #auto=\"matAutocomplete\" (optionSelected)=\"onSelect($event.option.value)\" class=\"sd-autocomplete-panel\">\n @let _filteredItems = filteredItems();\n\n @if (_filteredItems?.length) {\n @for (item of _filteredItems; track $index) {\n <mat-option\n [value]=\"item\"\n matTooltipPosition=\"above\"\n [matTooltip]=\"_displayField ? getNestedValue(item, _displayField) : item\"\n [disabled]=\"_disabledField ? getNestedValue(item, _disabledField) : false\">\n @if (iDefTpl) {\n <ng-container *ngTemplateOutlet=\"iDefTpl ?? null; context: { item: item }\"> </ng-container>\n } @else {\n {{ _displayField ? getNestedValue(item, _displayField) : item }}\n }\n </mat-option>\n }\n } @else if (!_filteredItems?.length && inputControl.value && !isTyping() && !_loading) {}\n\n @if (addable() && sdAdd.observed) {\n <mat-option class=\"sd__option--add\" (keyup.Space)=\"$event.stopPropagation()\" disabled=\"true\">\n <div (click)=\"onAdd($event)\">\n <mat-icon class=\"mr-1\">add</mat-icon>\n {{ 'New item' }}\n </div>\n </mat-option>\n }\n </mat-autocomplete>\n\n @if (_hideInlineError && _errorMessage && formControl.touched) {\n <mat-icon matSuffix class=\"sd-error-icon\" [matTooltip]=\"_errorMessage\" matTooltipPosition=\"above\"> error </mat-icon>\n }\n\n @if (!_hideInlineError && _errorMessage && formControl.touched) {\n <mat-error>{{ _errorMessage }}</mat-error>\n }\n </mat-form-field>\n </div>\n}\n", styles: [".text-primary{color:var(--sd-primary)!important}.bg-primary{background:var(--sd-primary)!important}.border-primary{border-color:var(--sd-primary)!important}.text-primary-light{color:var(--sd-primary-light)!important}.bg-primary-light{background:var(--sd-primary-light)!important}.border-primary-light{border-color:var(--sd-primary-light)!important}.text-primary-dark{color:var(--sd-primary-dark)!important}.bg-primary-dark{background:var(--sd-primary-dark)!important}.border-primary-dark{border-color:var(--sd-primary-dark)!important}.text-info{color:var(--sd-info)!important}.bg-info{background:var(--sd-info)!important}.border-info{border-color:var(--sd-info)!important}.text-info-light{color:var(--sd-info-light)!important}.bg-info-light{background:var(--sd-info-light)!important}.border-info-light{border-color:var(--sd-info-light)!important}.text-info-dark{color:var(--sd-info-dark)!important}.bg-info-dark{background:var(--sd-info-dark)!important}.border-info-dark{border-color:var(--sd-info-dark)!important}.text-success{color:var(--sd-success)!important}.bg-success{background:var(--sd-success)!important}.border-success{border-color:var(--sd-success)!important}.text-success-light{color:var(--sd-success-light)!important}.bg-success-light{background:var(--sd-success-light)!important}.border-success-light{border-color:var(--sd-success-light)!important}.text-success-dark{color:var(--sd-success-dark)!important}.bg-success-dark{background:var(--sd-success-dark)!important}.border-success-dark{border-color:var(--sd-success-dark)!important}.text-warning{color:var(--sd-warning)!important}.bg-warning{background:var(--sd-warning)!important}.border-warning{border-color:var(--sd-warning)!important}.text-warning-light{color:var(--sd-warning-light)!important}.bg-warning-light{background:var(--sd-warning-light)!important}.border-warning-light{border-color:var(--sd-warning-light)!important}.text-warning-dark{color:var(--sd-warning-dark)!important}.bg-warning-dark{background:var(--sd-warning-dark)!important}.border-warning-dark{border-color:var(--sd-warning-dark)!important}.text-error{color:var(--sd-error)!important}.bg-error{background:var(--sd-error)!important}.border-error{border-color:var(--sd-error)!important}.text-error-light{color:var(--sd-error-light)!important}.bg-error-light{background:var(--sd-error-light)!important}.border-error-light{border-color:var(--sd-error-light)!important}.text-error-dark{color:var(--sd-error-dark)!important}.bg-error-dark{background:var(--sd-error-dark)!important}.border-error-dark{border-color:var(--sd-error-dark)!important}.text-secondary{color:var(--sd-secondary)!important}.bg-secondary{background:var(--sd-secondary)!important}.border-secondary{border-color:var(--sd-secondary)!important}.text-secondary-light{color:var(--sd-secondary-light)!important}.bg-secondary-light{background:var(--sd-secondary-light)!important}.border-secondary-light{border-color:var(--sd-secondary-light)!important}.text-secondary-dark{color:var(--sd-secondary-dark)!important}.bg-secondary-dark{background:var(--sd-secondary-dark)!important}.border-secondary-dark{border-color:var(--sd-secondary-dark)!important}.text-light{color:var(--sd-light)!important}.bg-light{background:var(--sd-light)!important}.border-light{border-color:var(--sd-light)!important}.text-dark{color:var(--sd-dark)!important}.bg-dark{background:var(--sd-dark)!important}.border-dark{border-color:var(--sd-dark)!important}.text-black500{color:var(--sd-black500)!important}.bg-black500{background:var(--sd-black500)!important}.border-black500{border-color:var(--sd-black500)!important}.text-black400{color:var(--sd-black400)!important}.bg-black400{background:var(--sd-black400)!important}.border-black400{border-color:var(--sd-black400)!important}.text-black300{color:var(--sd-black300)!important}.bg-black300{background:var(--sd-black300)!important}.border-black300{border-color:var(--sd-black300)!important}.text-black200{color:var(--sd-black200)!important}.bg-black200{background:var(--sd-black200)!important}.border-black200{border-color:var(--sd-black200)!important}.text-black100{color:var(--sd-black100)!important}.bg-black100{background:var(--sd-black100)!important}.border-black100{border-color:var(--sd-black100)!important}.text-white{color:#fff!important}.bg-white{background:#fff!important}.border-white{border-color:#fff!important}.text-black{color:#000!important}.bg-black{background:#000!important}.border-black{border-color:#000!important}:host(.sd-bare){position:relative}.sd-inline-view{cursor:pointer;display:inline-flex;align-items:center;width:100%;padding:1px 6px;border-radius:4px;background-color:#0000000a;transition:background-color .15s ease}.sd-inline-view:hover{background-color:#00000014}.sd-inline-view .sd-inline-clear{display:none;align-items:center;margin-left:4px;padding:0;border:0;background:transparent;cursor:pointer;line-height:0;color:var(--sd-text-secondary, #6b7280);transition:color .15s ease}.sd-inline-view .sd-inline-clear mat-icon{font-size:16px;width:16px;height:16px}.sd-inline-view .sd-inline-clear:hover{color:var(--sd-error, #b32626)}.sd-inline-view:hover .sd-inline-clear{display:inline-flex}.sd-inline-editor{position:absolute;inset:0;opacity:0;pointer-events:none}.sd-inline-editor ::ng-deep *{pointer-events:none!important}:host{display:block}:host(.sd-has-label){padding-top:4px}:host(.sd-viewed){padding-top:0}:host ::ng-deep .mat-mdc-form-field.mat-form-field-appearance-outline.mat-form-field-disabled .mat-mdc-text-field-wrapper{background:var(--sd-black100)}:host ::ng-deep .mat-mdc-form-field input.c-selected::placeholder{color:#000;opacity:1}:host ::ng-deep .mat-mdc-form-field input.c-selected:-ms-input-placeholder{color:#000}:host ::ng-deep .mat-mdc-form-field input.c-selected::-ms-input-placeholder{color:#000}:host ::ng-deep .mat-mdc-form-field input.mat-mdc-input-element:disabled{color:var(--sd-black400)!important}:host ::ng-deep .mat-mdc-form-field input.mat-mdc-input-element:disabled.c-selected::placeholder{color:var(--sd-black400)!important}:host ::ng-deep .mat-mdc-form-field input.mat-mdc-input-element:disabled.c-selected:-ms-input-placeholder{color:var(--sd-black400)!important}:host ::ng-deep .mat-mdc-form-field input.mat-mdc-input-element:disabled.c-selected::-ms-input-placeholder{color:var(--sd-black400)!important}:host ::ng-deep .mat-mdc-form-field .mat-mdc-placeholder-required{color:var(--sd-error)}:host ::ng-deep .mat-mdc-form-field:hover .icon-copy{opacity:1}:host ::ng-deep .mat-mdc-form-field .icon-copy{cursor:pointer;width:.9em;height:.9em;fill:#00000080;transition:opacity .2s linear;opacity:0}::ng-deep .sd-autocomplete-panel .mat-mdc-option{min-height:36px!important;padding:8px 12px!important}::ng-deep .sd-autocomplete-panel .mdc-list-item__primary-text{font-size:14px!important;line-height:normal}::ng-deep .sd-autocomplete-panel .mat-pseudo-checkbox{transform:scale(.7);margin-right:8px!important}::ng-deep .sd-autocomplete-panel .mat-pseudo-checkbox-minimal{transform:scale(.7);transform-origin:center right}.sd__option--add{position:sticky;bottom:0;background-color:#fff;z-index:10;color:#000000de;cursor:pointer!important}.c-loading-icon{position:absolute;right:5px;top:5px}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i2.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "ngmodule", type: MatInputModule }, { kind: "directive", type: i3.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly", "disabledInteractive"], exportAs: ["matInput"] }, { kind: "component", type: i3.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i3.MatLabel, selector: "mat-label" }, { kind: "directive", type: i3.MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "directive", type: i3.MatSuffix, selector: "[matSuffix], [matIconSuffix], [matTextSuffix]", inputs: ["matTextSuffix"] }, { kind: "ngmodule", type: MatTooltipModule }, { kind: "directive", type: i4.MatTooltip, selector: "[matTooltip]", inputs: ["matTooltipPosition", "matTooltipPositionAtOrigin", "matTooltipDisabled", "matTooltipShowDelay", "matTooltipHideDelay", "matTooltipTouchGestures", "matTooltip", "matTooltipClass"], exportAs: ["matTooltip"] }, { kind: "ngmodule", type: MatFormFieldModule }, { kind: "ngmodule", type: MatAutocompleteModule }, { kind: "component", type: i5.MatAutocomplete, selector: "mat-autocomplete", inputs: ["aria-label", "aria-labelledby", "displayWith", "autoActiveFirstOption", "autoSelectActiveOption", "requireSelection", "panelWidth", "disableRipple", "class", "hideSingleSelectionIndicator"], outputs: ["optionSelected", "opened", "closed", "optionActivated"], exportAs: ["matAutocomplete"] }, { kind: "component", type: i5.MatOption, selector: "mat-option", inputs: ["value", "id", "disabled"], outputs: ["onSelectionChange"], exportAs: ["matOption"] }, { kind: "directive", type: i5.MatAutocompleteTrigger, selector: "input[matAutocomplete], textarea[matAutocomplete]", inputs: ["matAutocomplete", "matAutocompletePosition", "matAutocompleteConnectedTo", "autocomplete", "matAutocompleteDisabled"], exportAs: ["matAutocompleteTrigger"] }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i6.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: MatProgressSpinnerModule }, { kind: "component", type: i7.MatProgressSpinner, selector: "mat-progress-spinner, mat-spinner", inputs: ["color", "mode", "value", "diameter", "strokeWidth"], exportAs: ["matProgressSpinner"] }, { kind: "component", type: SdLabel, selector: "sd-label", inputs: ["label", "description", "required", "helperText"] }, { kind: "component", type: SdView, selector: "sd-view", inputs: ["label", "value", "display", "hyperlink", "labelTemplate", "valueTemplate", "selectedItems"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
638
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.21", type: SdAutocomplete, isStandalone: true, selector: "sd-autocomplete", inputs: { autoIdInput: { classPropertyName: "autoIdInput", publicName: "autoId", isSignal: true, isRequired: false, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, form: { classPropertyName: "form", publicName: "form", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, helperText: { classPropertyName: "helperText", publicName: "helperText", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, valueField: { classPropertyName: "valueField", publicName: "valueField", isSignal: true, isRequired: false, transformFunction: null }, displayField: { classPropertyName: "displayField", publicName: "displayField", isSignal: true, isRequired: false, transformFunction: null }, disabledField: { classPropertyName: "disabledField", publicName: "disabledField", isSignal: true, isRequired: false, transformFunction: null }, limit: { classPropertyName: "limit", publicName: "limit", isSignal: true, isRequired: false, transformFunction: null }, cacheChecksum: { classPropertyName: "cacheChecksum", publicName: "cacheChecksum", isSignal: true, isRequired: false, transformFunction: null }, hyperlink: { classPropertyName: "hyperlink", publicName: "hyperlink", isSignal: true, isRequired: false, transformFunction: null }, items: { classPropertyName: "items", publicName: "items", isSignal: true, isRequired: false, transformFunction: null }, hideInlineError: { classPropertyName: "hideInlineError", publicName: "hideInlineError", isSignal: true, isRequired: false, transformFunction: null }, hideReadError: { classPropertyName: "hideReadError", publicName: "hideReadError", isSignal: true, isRequired: false, transformFunction: null }, addable: { classPropertyName: "addable", publicName: "addable", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, viewed: { classPropertyName: "viewed", publicName: "viewed", isSignal: true, isRequired: false, transformFunction: null }, clearable: { classPropertyName: "clearable", publicName: "clearable", isSignal: true, isRequired: false, transformFunction: null }, validator: { classPropertyName: "validator", publicName: "validator", isSignal: true, isRequired: false, transformFunction: null }, inlineError: { classPropertyName: "inlineError", publicName: "inlineError", isSignal: true, isRequired: false, transformFunction: null }, appearanceInput: { classPropertyName: "appearanceInput", publicName: "appearance", isSignal: true, isRequired: false, transformFunction: null }, valueModel: { classPropertyName: "valueModel", publicName: "model", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { sdReadStateChange: "sdReadStateChange", valueModel: "modelChange", sdChange: "sdChange", sdSelection: "sdSelection", sdAdd: "sdAdd" }, host: { properties: { "class.sd-has-label": "!!label()", "class.sd-viewed": "isViewed() || isInline()", "class.sd-bare": "isInline()" } }, queries: [{ propertyName: "sdLabelTemplate", first: true, predicate: ["sdLabel"], descendants: true, isSignal: true }, { propertyName: "sdValueTemplate", first: true, predicate: ["sdValue"], descendants: true, isSignal: true }, { propertyName: "itemDef", first: true, predicate: SdItemDefDefDirective, descendants: true, isSignal: true }, { propertyName: "sdViewDef", first: true, predicate: SdViewDefDirective, descendants: true, isSignal: true }, { propertyName: "dataStateTemplate", first: true, predicate: SdDataStateTemplateDirective, descendants: true, isSignal: true }], viewQueries: [{ propertyName: "inputRef", first: true, predicate: ["input"], descendants: true, isSignal: true }, { propertyName: "autocompleteTrigger", first: true, predicate: MatAutocompleteTrigger, descendants: true, isSignal: true }], ngImport: i0, template: "@let _label = label();\n@let _appearance = appearance();\n@let _hideInlineError = hideInlineError();\n@let _errorMessage = errorMessage();\n@let _helperText = helperText();\n@let _required = required();\n@let _displayField = displayField();\n@let _disabledField = disabledField();\n@let iDefTpl = itemDef()?.templateRef;\n@let _loading = loading();\n@let _readState = readState();\n@let _isTyping = isTyping();\n@let nVal = $any(normalizedValue());\n@let _isInline = isInline();\n@let _bare = _isInline;\n@let _hasValue = nVal !== undefined && nVal !== null && nVal !== '';\n\n@if (isViewed()) {\n <sd-view\n [label]=\"_label\"\n [labelTemplate]=\"sdLabelTemplate()\"\n [value]=\"nVal\"\n [display]=\"display()\"\n [hyperlink]=\"hyperlink()\"\n [valueTemplate]=\"viewTemplate()\">\n </sd-view>\n} @else {\n @if (_isInline) {\n <!-- why: inline \u2014 sd-view l\u00E0 \"m\u1EB7t\" + trigger; autocomplete editor render \u1EA9n (.sd-inline-editor) ch\u1EC9 \u0111\u1EC3 m\u1EDF panel. -->\n <span class=\"sd-inline-view\" role=\"button\" tabindex=\"0\" (click)=\"enterInlineEdit()\" (keydown.enter)=\"enterInlineEdit()\">\n <sd-view\n [label]=\"_label\"\n [labelTemplate]=\"sdLabelTemplate()\"\n [value]=\"nVal\"\n [display]=\"display()\"\n [hyperlink]=\"hyperlink()\"\n [valueTemplate]=\"viewTemplate()\">\n </sd-view>\n @if (clearable() && _hasValue && !_required && !formControl.disabled) {\n <button type=\"button\" class=\"sd-inline-clear\" (click)=\"clear($event)\" title=\"X\u00F3a\" aria-label=\"X\u00F3a\">\n <mat-icon>close</mat-icon>\n </button>\n }\n </span>\n }\n\n @if (!_appearance) {\n <ng-content select=\"[sdLabel]\">\n @if (_label) {\n <sd-label [label]=\"_label\" [required]=\"_required\"></sd-label>\n }\n </ng-content>\n }\n\n <div\n class=\"d-flex align-items-center\" role=\"presentation\"\n [class.sd-inline-editor]=\"_isInline\"\n [class.c-focused]=\"isFocused\"\n [class.c-disabled]=\"formControl.disabled\"\n (click)=\"onClick()\">\n <mat-form-field\n [class.sd-md]=\"size() === 'md'\"\n [class.sd-sm]=\"size() === 'sm'\"\n [class.hide-inline-error]=\"_hideInlineError\"\n [floatLabel]=\"nVal ? 'always' : 'auto'\"\n [appearance]=\"_appearance || 'outline'\">\n @if (_appearance && _label) {\n <mat-label style=\"display: inline-block\">\n <div style=\"display: flex; align-items: center; gap: 4px\">\n <span>{{ _label }}</span>\n @if (_helperText) {\n <mat-icon [matTooltip]=\"_helperText\" matTooltipPosition=\"below\">info_outline</mat-icon>\n }\n </div>\n </mat-label>\n }\n\n <input\n [id]=\"id\"\n [formControl]=\"inputControl\"\n [placeholder]=\"controlPlaceHolder() || ''\"\n [class.c-selected]=\"nVal\"\n [matAutocomplete]=\"auto\"\n (focus)=\"onFocus()\"\n (blur)=\"onBlur($event)\"\n matInput\n [autocomplete]=\"id\"\n autocorrect=\"off\"\n [errorStateMatcher]=\"matcher\"\n [required]=\"_required\"\n #input\n #autocompleteTrigger=\"matAutocompleteTrigger\"\n [attr.data-autoId]=\"autoId()\"\n [attr.data-disabled]=\"dataDisabled()\"\n [attr.data-invalid]=\"dataInvalid()\"\n [attr.data-empty]=\"dataEmpty()\"\n [attr.data-value]=\"dataValue()\"\n [attr.data-loading]=\"dataLoading()\"\n [attr.data-required]=\"dataRequired()\"\n [attr.data-error-message]=\"dataErrorMessage()\" />\n\n @if (!_loading && nVal && !inputControl.disabled && !_bare) {\n <button type=\"button\" class=\"sd-clear-btn\" matSuffix (click)=\"clear($event)\" title=\"X\u00F3a\" aria-label=\"X\u00F3a\">\n <mat-icon>close</mat-icon>\n </button>\n } @else if (_loading) {\n <mat-spinner [diameter]=\"20\" matSuffix></mat-spinner>\n } @else {\n <mat-icon class=\"cursor-pointer sd-suffix-icon\" matSuffix>search</mat-icon>\n }\n\n <mat-autocomplete #auto=\"matAutocomplete\" (optionSelected)=\"onSelect($event.option.value)\" class=\"sd-autocomplete-panel\">\n @let _filteredItems = filteredItems();\n\n <!-- why: kh\u00F4ng hi\u1EC3n th\u1ECB l\u1ED7i k\u00EAnh c\u0169 c\u00F9ng spinner c\u1EE7a k\u00EAnh \u0111ang \u0111\u1ECDc/retry. -->\n @if (!_loading && _readState.status === 'error') {\n <!-- why: anchor gi\u1EEF panel m\u1EDF khi kh\u00F4ng c\u00F3 option; n\u00FAt retry kh\u00F4ng n\u1EB1m trong mat-option. -->\n <mat-option disabled class=\"sd-read-state-anchor\" aria-hidden=\"true\"></mat-option>\n @if (!hideReadError()) {\n <div class=\"sd-read-state-region\" role=\"presentation\" (mousedown)=\"$event.preventDefault()\" (click)=\"$event.stopPropagation()\" (keydown)=\"onReadRegionKeydown($event)\">\n <ng-container [ngTemplateOutlet]=\"readRegion\" [ngTemplateOutletContext]=\"{ state: 'error' }\"></ng-container>\n </div>\n }\n }\n\n @if (_filteredItems?.length) {\n @for (item of _filteredItems; track $index) {\n <mat-option\n [value]=\"item\"\n matTooltipPosition=\"above\"\n [matTooltip]=\"_displayField ? getNestedValue(item, _displayField) : item\"\n [disabled]=\"_disabledField ? getNestedValue(item, _disabledField) : false\">\n @if (iDefTpl) {\n <ng-container *ngTemplateOutlet=\"iDefTpl ?? null; context: { item: item }\"> </ng-container>\n } @else {\n {{ _displayField ? getNestedValue(item, _displayField) : item }}\n }\n </mat-option>\n }\n } @else if (_loading) {\n <mat-option disabled><mat-spinner diameter=\"24\"></mat-spinner></mat-option>\n } @else if (hasSearched() && !_isTyping && _readState.status === 'empty') {\n <mat-option disabled class=\"sd-read-state-anchor\" aria-hidden=\"true\"></mat-option>\n <ng-container [ngTemplateOutlet]=\"readRegion\" [ngTemplateOutletContext]=\"{ state: 'empty' }\"></ng-container>\n }\n\n @if (addable() && sdAdd.observed) {\n <mat-option disabled class=\"sd-read-state-anchor\" aria-hidden=\"true\"></mat-option>\n <button type=\"button\" class=\"sd__option--add\" (click)=\"onAdd($event)\" (keydown)=\"$event.stopPropagation()\">\n <mat-icon class=\"mr-1\">add</mat-icon>\n {{ 'New item' }}\n </button>\n }\n </mat-autocomplete>\n\n @if (_hideInlineError && _errorMessage && formControl.touched) {\n <mat-icon matSuffix class=\"sd-error-icon\" [matTooltip]=\"_errorMessage\" matTooltipPosition=\"above\"> error </mat-icon>\n }\n\n @if (!_hideInlineError && _errorMessage && formControl.touched) {\n <mat-error>{{ _errorMessage }}</mat-error>\n }\n </mat-form-field>\n </div>\n}\n\n<ng-template #readRegion let-current=\"state\">\n <sd-data-state [state]=\"current\" compact [retryable]=\"current === 'error'\" (sdRetry)=\"retryRead()\">\n @if (dataStateTemplate(); as custom) {\n <ng-template sdDataStateTemplate let-state let-retry=\"retry\" let-action=\"action\">\n <ng-container [ngTemplateOutlet]=\"custom.template\"\n [ngTemplateOutletContext]=\"{ $implicit: state, state: state, retry: retry, action: action }\"></ng-container>\n </ng-template>\n }\n </sd-data-state>\n</ng-template>\n", styles: [".text-primary{color:var(--sd-primary)!important}.bg-primary{background:var(--sd-primary)!important}.border-primary{border-color:var(--sd-primary)!important}.text-primary-light{color:var(--sd-primary-light)!important}.bg-primary-light{background:var(--sd-primary-light)!important}.border-primary-light{border-color:var(--sd-primary-light)!important}.text-primary-dark{color:var(--sd-primary-dark)!important}.bg-primary-dark{background:var(--sd-primary-dark)!important}.border-primary-dark{border-color:var(--sd-primary-dark)!important}.text-info{color:var(--sd-info)!important}.bg-info{background:var(--sd-info)!important}.border-info{border-color:var(--sd-info)!important}.text-info-light{color:var(--sd-info-light)!important}.bg-info-light{background:var(--sd-info-light)!important}.border-info-light{border-color:var(--sd-info-light)!important}.text-info-dark{color:var(--sd-info-dark)!important}.bg-info-dark{background:var(--sd-info-dark)!important}.border-info-dark{border-color:var(--sd-info-dark)!important}.text-success{color:var(--sd-success)!important}.bg-success{background:var(--sd-success)!important}.border-success{border-color:var(--sd-success)!important}.text-success-light{color:var(--sd-success-light)!important}.bg-success-light{background:var(--sd-success-light)!important}.border-success-light{border-color:var(--sd-success-light)!important}.text-success-dark{color:var(--sd-success-dark)!important}.bg-success-dark{background:var(--sd-success-dark)!important}.border-success-dark{border-color:var(--sd-success-dark)!important}.text-warning{color:var(--sd-warning)!important}.bg-warning{background:var(--sd-warning)!important}.border-warning{border-color:var(--sd-warning)!important}.text-warning-light{color:var(--sd-warning-light)!important}.bg-warning-light{background:var(--sd-warning-light)!important}.border-warning-light{border-color:var(--sd-warning-light)!important}.text-warning-dark{color:var(--sd-warning-dark)!important}.bg-warning-dark{background:var(--sd-warning-dark)!important}.border-warning-dark{border-color:var(--sd-warning-dark)!important}.text-error{color:var(--sd-error)!important}.bg-error{background:var(--sd-error)!important}.border-error{border-color:var(--sd-error)!important}.text-error-light{color:var(--sd-error-light)!important}.bg-error-light{background:var(--sd-error-light)!important}.border-error-light{border-color:var(--sd-error-light)!important}.text-error-dark{color:var(--sd-error-dark)!important}.bg-error-dark{background:var(--sd-error-dark)!important}.border-error-dark{border-color:var(--sd-error-dark)!important}.text-secondary{color:var(--sd-secondary)!important}.bg-secondary{background:var(--sd-secondary)!important}.border-secondary{border-color:var(--sd-secondary)!important}.text-secondary-light{color:var(--sd-secondary-light)!important}.bg-secondary-light{background:var(--sd-secondary-light)!important}.border-secondary-light{border-color:var(--sd-secondary-light)!important}.text-secondary-dark{color:var(--sd-secondary-dark)!important}.bg-secondary-dark{background:var(--sd-secondary-dark)!important}.border-secondary-dark{border-color:var(--sd-secondary-dark)!important}.text-light{color:var(--sd-light)!important}.bg-light{background:var(--sd-light)!important}.border-light{border-color:var(--sd-light)!important}.text-dark{color:var(--sd-dark)!important}.bg-dark{background:var(--sd-dark)!important}.border-dark{border-color:var(--sd-dark)!important}.text-black500{color:var(--sd-black500)!important}.bg-black500{background:var(--sd-black500)!important}.border-black500{border-color:var(--sd-black500)!important}.text-black400{color:var(--sd-black400)!important}.bg-black400{background:var(--sd-black400)!important}.border-black400{border-color:var(--sd-black400)!important}.text-black300{color:var(--sd-black300)!important}.bg-black300{background:var(--sd-black300)!important}.border-black300{border-color:var(--sd-black300)!important}.text-black200{color:var(--sd-black200)!important}.bg-black200{background:var(--sd-black200)!important}.border-black200{border-color:var(--sd-black200)!important}.text-black100{color:var(--sd-black100)!important}.bg-black100{background:var(--sd-black100)!important}.border-black100{border-color:var(--sd-black100)!important}.text-white{color:#fff!important}.bg-white{background:#fff!important}.border-white{border-color:#fff!important}.text-black{color:#000!important}.bg-black{background:#000!important}.border-black{border-color:#000!important}:host(.sd-bare){position:relative}.sd-inline-view{cursor:pointer;display:inline-flex;align-items:center;width:100%;padding:1px 6px;border-radius:4px;background-color:#0000000a;transition:background-color .15s ease}.sd-inline-view:hover{background-color:#00000014}.sd-inline-view .sd-inline-clear{display:none;align-items:center;margin-left:4px;padding:0;border:0;background:transparent;cursor:pointer;line-height:0;color:var(--sd-text-secondary, #6b7280);transition:color .15s ease}.sd-inline-view .sd-inline-clear mat-icon{font-size:16px;width:16px;height:16px}.sd-inline-view .sd-inline-clear:hover{color:var(--sd-error, #b32626)}.sd-inline-view:hover .sd-inline-clear{display:inline-flex}.sd-inline-editor{position:absolute;inset:0;opacity:0;pointer-events:none}.sd-inline-editor ::ng-deep *{pointer-events:none!important}:host{display:block}:host(.sd-has-label){padding-top:4px}:host(.sd-viewed){padding-top:0}:host ::ng-deep .mat-mdc-form-field.mat-form-field-appearance-outline.mat-form-field-disabled .mat-mdc-text-field-wrapper{background:var(--sd-black100)}:host ::ng-deep .mat-mdc-form-field input.c-selected::placeholder{color:#000;opacity:1}:host ::ng-deep .mat-mdc-form-field input.c-selected:-ms-input-placeholder{color:#000}:host ::ng-deep .mat-mdc-form-field input.c-selected::-ms-input-placeholder{color:#000}:host ::ng-deep .mat-mdc-form-field input.mat-mdc-input-element:disabled{color:var(--sd-black400)!important}:host ::ng-deep .mat-mdc-form-field input.mat-mdc-input-element:disabled.c-selected::placeholder{color:var(--sd-black400)!important}:host ::ng-deep .mat-mdc-form-field input.mat-mdc-input-element:disabled.c-selected:-ms-input-placeholder{color:var(--sd-black400)!important}:host ::ng-deep .mat-mdc-form-field input.mat-mdc-input-element:disabled.c-selected::-ms-input-placeholder{color:var(--sd-black400)!important}:host ::ng-deep .mat-mdc-form-field .mat-mdc-placeholder-required{color:var(--sd-error)}:host ::ng-deep .mat-mdc-form-field:hover .icon-copy{opacity:1}:host ::ng-deep .mat-mdc-form-field .icon-copy{cursor:pointer;width:.9em;height:.9em;fill:#00000080;transition:opacity .2s linear;opacity:0}::ng-deep .sd-autocomplete-panel .mat-mdc-option{min-height:36px!important;padding:8px 12px!important}::ng-deep .sd-autocomplete-panel .mdc-list-item__primary-text{font-size:14px!important;line-height:normal}::ng-deep .sd-autocomplete-panel .mat-pseudo-checkbox{transform:scale(.7);margin-right:8px!important}::ng-deep .sd-autocomplete-panel .mat-pseudo-checkbox-minimal{transform:scale(.7);transform-origin:center right}.sd__option--add{position:sticky;bottom:0;background-color:var(--sd-light);z-index:10;color:var(--sd-black500);display:flex;align-items:center;width:100%;min-height:48px;padding:0 16px;border:0;font:inherit;text-align:left;cursor:pointer!important}.c-loading-icon{position:absolute;right:5px;top:5px}::ng-deep .sd-autocomplete-panel .sd-read-state-anchor{display:none}\n"], dependencies: [{ kind: "component", type: SdDataState, selector: "sd-data-state", inputs: ["state", "title", "message", "icon", "fontSet", "retryable", "retryLabel", "actionLabel", "compact", "fullPage"], outputs: ["sdRetry", "sdAction"] }, { kind: "directive", type: SdDataStateTemplateDirective, selector: "ng-template[sdDataStateTemplate]" }, { kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i2.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "ngmodule", type: MatInputModule }, { kind: "directive", type: i3.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly", "disabledInteractive"], exportAs: ["matInput"] }, { kind: "component", type: i3.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i3.MatLabel, selector: "mat-label" }, { kind: "directive", type: i3.MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "directive", type: i3.MatSuffix, selector: "[matSuffix], [matIconSuffix], [matTextSuffix]", inputs: ["matTextSuffix"] }, { kind: "ngmodule", type: MatTooltipModule }, { kind: "directive", type: i4.MatTooltip, selector: "[matTooltip]", inputs: ["matTooltipPosition", "matTooltipPositionAtOrigin", "matTooltipDisabled", "matTooltipShowDelay", "matTooltipHideDelay", "matTooltipTouchGestures", "matTooltip", "matTooltipClass"], exportAs: ["matTooltip"] }, { kind: "ngmodule", type: MatFormFieldModule }, { kind: "ngmodule", type: MatAutocompleteModule }, { kind: "component", type: i5.MatAutocomplete, selector: "mat-autocomplete", inputs: ["aria-label", "aria-labelledby", "displayWith", "autoActiveFirstOption", "autoSelectActiveOption", "requireSelection", "panelWidth", "disableRipple", "class", "hideSingleSelectionIndicator"], outputs: ["optionSelected", "opened", "closed", "optionActivated"], exportAs: ["matAutocomplete"] }, { kind: "component", type: i5.MatOption, selector: "mat-option", inputs: ["value", "id", "disabled"], outputs: ["onSelectionChange"], exportAs: ["matOption"] }, { kind: "directive", type: i5.MatAutocompleteTrigger, selector: "input[matAutocomplete], textarea[matAutocomplete]", inputs: ["matAutocomplete", "matAutocompletePosition", "matAutocompleteConnectedTo", "autocomplete", "matAutocompleteDisabled"], exportAs: ["matAutocompleteTrigger"] }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i6.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: MatProgressSpinnerModule }, { kind: "component", type: i7.MatProgressSpinner, selector: "mat-progress-spinner, mat-spinner", inputs: ["color", "mode", "value", "diameter", "strokeWidth"], exportAs: ["matProgressSpinner"] }, { kind: "component", type: SdLabel, selector: "sd-label", inputs: ["label", "description", "required", "helperText"] }, { kind: "component", type: SdView, selector: "sd-view", inputs: ["label", "value", "display", "hyperlink", "labelTemplate", "valueTemplate", "selectedItems"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
453
639
|
}
|
|
454
640
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.21", ngImport: i0, type: SdAutocomplete, decorators: [{
|
|
455
641
|
type: Component,
|
|
456
642
|
args: [{ selector: 'sd-autocomplete', changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, host: { '[class.sd-has-label]': '!!label()', '[class.sd-viewed]': 'isViewed() || isInline()', '[class.sd-bare]': 'isInline()' }, imports: [
|
|
643
|
+
SdDataState,
|
|
644
|
+
SdDataStateTemplateDirective,
|
|
457
645
|
CommonModule,
|
|
458
646
|
FormsModule,
|
|
459
647
|
ReactiveFormsModule,
|
|
@@ -465,7 +653,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.21", ngImpo
|
|
|
465
653
|
MatProgressSpinnerModule,
|
|
466
654
|
SdLabel,
|
|
467
655
|
SdView,
|
|
468
|
-
], template: "@let _label = label();\n@let _appearance = appearance();\n@let _hideInlineError = hideInlineError();\n@let _errorMessage = errorMessage();\n@let _helperText = helperText();\n@let _required = required();\n@let _displayField = displayField();\n@let _disabledField = disabledField();\n@let iDefTpl = itemDef()?.templateRef;\n@let _loading = loading();\n@let nVal = $any(normalizedValue());\n@let _isInline = isInline();\n@let _bare = _isInline;\n@let _hasValue = nVal !== undefined && nVal !== null && nVal !== '';\n\n@if (isViewed()) {\n <sd-view\n [label]=\"_label\"\n [labelTemplate]=\"sdLabelTemplate()\"\n [value]=\"nVal\"\n [display]=\"display()\"\n [hyperlink]=\"hyperlink()\"\n [valueTemplate]=\"viewTemplate()\">\n </sd-view>\n} @else {\n @if (_isInline) {\n <!-- why: inline \u2014 sd-view l\u00E0 \"m\u1EB7t\" + trigger; autocomplete editor render \u1EA9n (.sd-inline-editor) ch\u1EC9 \u0111\u1EC3 m\u1EDF panel. -->\n <span class=\"sd-inline-view\" role=\"button\" tabindex=\"0\" (click)=\"enterInlineEdit()\" (keydown.enter)=\"enterInlineEdit()\">\n <sd-view\n [label]=\"_label\"\n [labelTemplate]=\"sdLabelTemplate()\"\n [value]=\"nVal\"\n [display]=\"display()\"\n [hyperlink]=\"hyperlink()\"\n [valueTemplate]=\"viewTemplate()\">\n </sd-view>\n @if (clearable() && _hasValue && !_required && !formControl.disabled) {\n <button type=\"button\" class=\"sd-inline-clear\" (click)=\"clear($event)\" title=\"X\u00F3a\" aria-label=\"X\u00F3a\">\n <mat-icon>close</mat-icon>\n </button>\n }\n </span>\n }\n\n @if (!_appearance) {\n <ng-content select=\"[sdLabel]\">\n @if (_label) {\n <sd-label [label]=\"_label\" [required]=\"_required\"></sd-label>\n }\n </ng-content>\n }\n\n <div\n class=\"d-flex align-items-center\"\n [class.sd-inline-editor]=\"_isInline\"\n [class.c-focused]=\"isFocused\"\n [class.c-disabled]=\"formControl.disabled\"\n (click)=\"onClick()\"\n aria-hidden=\"true\">\n <mat-form-field\n [class.sd-md]=\"size() === 'md'\"\n [class.sd-sm]=\"size() === 'sm'\"\n [class.hide-inline-error]=\"_hideInlineError\"\n [floatLabel]=\"nVal ? 'always' : 'auto'\"\n [appearance]=\"_appearance || 'outline'\">\n @if (_appearance && _label) {\n <mat-label style=\"display: inline-block\">\n <div style=\"display: flex; align-items: center; gap: 4px\">\n <span>{{ _label }}</span>\n @if (_helperText) {\n <mat-icon [matTooltip]=\"_helperText\" matTooltipPosition=\"below\">info_outline</mat-icon>\n }\n </div>\n </mat-label>\n }\n\n <input\n [id]=\"id\"\n [formControl]=\"inputControl\"\n [placeholder]=\"controlPlaceHolder() || ''\"\n [class.c-selected]=\"nVal\"\n [matAutocomplete]=\"auto\"\n (focus)=\"onFocus()\"\n (blur)=\"onBlur()\"\n matInput\n [autocomplete]=\"id\"\n autocorrect=\"off\"\n [errorStateMatcher]=\"matcher\"\n [required]=\"_required\"\n #input\n #autocompleteTrigger=\"matAutocompleteTrigger\"\n [attr.data-autoId]=\"autoId()\"\n [attr.data-disabled]=\"dataDisabled()\"\n [attr.data-invalid]=\"dataInvalid()\"\n [attr.data-empty]=\"dataEmpty()\"\n [attr.data-value]=\"dataValue()\"\n [attr.data-loading]=\"dataLoading()\"\n [attr.data-required]=\"dataRequired()\"\n [attr.data-error-message]=\"dataErrorMessage()\"\n aria-hidden=\"true\" />\n\n @if (!_loading && nVal && !inputControl.disabled && !_bare) {\n <button type=\"button\" class=\"sd-clear-btn\" matSuffix (click)=\"clear($event)\" title=\"X\u00F3a\" aria-label=\"X\u00F3a\">\n <mat-icon>close</mat-icon>\n </button>\n } @else if (_loading) {\n <mat-spinner [diameter]=\"20\" matSuffix></mat-spinner>\n } @else {\n <mat-icon class=\"cursor-pointer sd-suffix-icon\" matSuffix>search</mat-icon>\n }\n\n <mat-autocomplete #auto=\"matAutocomplete\" (optionSelected)=\"onSelect($event.option.value)\" class=\"sd-autocomplete-panel\">\n @let _filteredItems = filteredItems();\n\n @if (_filteredItems?.length) {\n @for (item of _filteredItems; track $index) {\n <mat-option\n [value]=\"item\"\n matTooltipPosition=\"above\"\n [matTooltip]=\"_displayField ? getNestedValue(item, _displayField) : item\"\n [disabled]=\"_disabledField ? getNestedValue(item, _disabledField) : false\">\n @if (iDefTpl) {\n <ng-container *ngTemplateOutlet=\"iDefTpl ?? null; context: { item: item }\"> </ng-container>\n } @else {\n {{ _displayField ? getNestedValue(item, _displayField) : item }}\n }\n </mat-option>\n }\n } @else if (!_filteredItems?.length && inputControl.value && !isTyping() && !_loading) {}\n\n @if (addable() && sdAdd.observed) {\n <mat-option class=\"sd__option--add\" (keyup.Space)=\"$event.stopPropagation()\" disabled=\"true\">\n <div (click)=\"onAdd($event)\">\n <mat-icon class=\"mr-1\">add</mat-icon>\n {{ 'New item' }}\n </div>\n </mat-option>\n }\n </mat-autocomplete>\n\n @if (_hideInlineError && _errorMessage && formControl.touched) {\n <mat-icon matSuffix class=\"sd-error-icon\" [matTooltip]=\"_errorMessage\" matTooltipPosition=\"above\"> error </mat-icon>\n }\n\n @if (!_hideInlineError && _errorMessage && formControl.touched) {\n <mat-error>{{ _errorMessage }}</mat-error>\n }\n </mat-form-field>\n </div>\n}\n", styles: [".text-primary{color:var(--sd-primary)!important}.bg-primary{background:var(--sd-primary)!important}.border-primary{border-color:var(--sd-primary)!important}.text-primary-light{color:var(--sd-primary-light)!important}.bg-primary-light{background:var(--sd-primary-light)!important}.border-primary-light{border-color:var(--sd-primary-light)!important}.text-primary-dark{color:var(--sd-primary-dark)!important}.bg-primary-dark{background:var(--sd-primary-dark)!important}.border-primary-dark{border-color:var(--sd-primary-dark)!important}.text-info{color:var(--sd-info)!important}.bg-info{background:var(--sd-info)!important}.border-info{border-color:var(--sd-info)!important}.text-info-light{color:var(--sd-info-light)!important}.bg-info-light{background:var(--sd-info-light)!important}.border-info-light{border-color:var(--sd-info-light)!important}.text-info-dark{color:var(--sd-info-dark)!important}.bg-info-dark{background:var(--sd-info-dark)!important}.border-info-dark{border-color:var(--sd-info-dark)!important}.text-success{color:var(--sd-success)!important}.bg-success{background:var(--sd-success)!important}.border-success{border-color:var(--sd-success)!important}.text-success-light{color:var(--sd-success-light)!important}.bg-success-light{background:var(--sd-success-light)!important}.border-success-light{border-color:var(--sd-success-light)!important}.text-success-dark{color:var(--sd-success-dark)!important}.bg-success-dark{background:var(--sd-success-dark)!important}.border-success-dark{border-color:var(--sd-success-dark)!important}.text-warning{color:var(--sd-warning)!important}.bg-warning{background:var(--sd-warning)!important}.border-warning{border-color:var(--sd-warning)!important}.text-warning-light{color:var(--sd-warning-light)!important}.bg-warning-light{background:var(--sd-warning-light)!important}.border-warning-light{border-color:var(--sd-warning-light)!important}.text-warning-dark{color:var(--sd-warning-dark)!important}.bg-warning-dark{background:var(--sd-warning-dark)!important}.border-warning-dark{border-color:var(--sd-warning-dark)!important}.text-error{color:var(--sd-error)!important}.bg-error{background:var(--sd-error)!important}.border-error{border-color:var(--sd-error)!important}.text-error-light{color:var(--sd-error-light)!important}.bg-error-light{background:var(--sd-error-light)!important}.border-error-light{border-color:var(--sd-error-light)!important}.text-error-dark{color:var(--sd-error-dark)!important}.bg-error-dark{background:var(--sd-error-dark)!important}.border-error-dark{border-color:var(--sd-error-dark)!important}.text-secondary{color:var(--sd-secondary)!important}.bg-secondary{background:var(--sd-secondary)!important}.border-secondary{border-color:var(--sd-secondary)!important}.text-secondary-light{color:var(--sd-secondary-light)!important}.bg-secondary-light{background:var(--sd-secondary-light)!important}.border-secondary-light{border-color:var(--sd-secondary-light)!important}.text-secondary-dark{color:var(--sd-secondary-dark)!important}.bg-secondary-dark{background:var(--sd-secondary-dark)!important}.border-secondary-dark{border-color:var(--sd-secondary-dark)!important}.text-light{color:var(--sd-light)!important}.bg-light{background:var(--sd-light)!important}.border-light{border-color:var(--sd-light)!important}.text-dark{color:var(--sd-dark)!important}.bg-dark{background:var(--sd-dark)!important}.border-dark{border-color:var(--sd-dark)!important}.text-black500{color:var(--sd-black500)!important}.bg-black500{background:var(--sd-black500)!important}.border-black500{border-color:var(--sd-black500)!important}.text-black400{color:var(--sd-black400)!important}.bg-black400{background:var(--sd-black400)!important}.border-black400{border-color:var(--sd-black400)!important}.text-black300{color:var(--sd-black300)!important}.bg-black300{background:var(--sd-black300)!important}.border-black300{border-color:var(--sd-black300)!important}.text-black200{color:var(--sd-black200)!important}.bg-black200{background:var(--sd-black200)!important}.border-black200{border-color:var(--sd-black200)!important}.text-black100{color:var(--sd-black100)!important}.bg-black100{background:var(--sd-black100)!important}.border-black100{border-color:var(--sd-black100)!important}.text-white{color:#fff!important}.bg-white{background:#fff!important}.border-white{border-color:#fff!important}.text-black{color:#000!important}.bg-black{background:#000!important}.border-black{border-color:#000!important}:host(.sd-bare){position:relative}.sd-inline-view{cursor:pointer;display:inline-flex;align-items:center;width:100%;padding:1px 6px;border-radius:4px;background-color:#0000000a;transition:background-color .15s ease}.sd-inline-view:hover{background-color:#00000014}.sd-inline-view .sd-inline-clear{display:none;align-items:center;margin-left:4px;padding:0;border:0;background:transparent;cursor:pointer;line-height:0;color:var(--sd-text-secondary, #6b7280);transition:color .15s ease}.sd-inline-view .sd-inline-clear mat-icon{font-size:16px;width:16px;height:16px}.sd-inline-view .sd-inline-clear:hover{color:var(--sd-error, #b32626)}.sd-inline-view:hover .sd-inline-clear{display:inline-flex}.sd-inline-editor{position:absolute;inset:0;opacity:0;pointer-events:none}.sd-inline-editor ::ng-deep *{pointer-events:none!important}:host{display:block}:host(.sd-has-label){padding-top:4px}:host(.sd-viewed){padding-top:0}:host ::ng-deep .mat-mdc-form-field.mat-form-field-appearance-outline.mat-form-field-disabled .mat-mdc-text-field-wrapper{background:var(--sd-black100)}:host ::ng-deep .mat-mdc-form-field input.c-selected::placeholder{color:#000;opacity:1}:host ::ng-deep .mat-mdc-form-field input.c-selected:-ms-input-placeholder{color:#000}:host ::ng-deep .mat-mdc-form-field input.c-selected::-ms-input-placeholder{color:#000}:host ::ng-deep .mat-mdc-form-field input.mat-mdc-input-element:disabled{color:var(--sd-black400)!important}:host ::ng-deep .mat-mdc-form-field input.mat-mdc-input-element:disabled.c-selected::placeholder{color:var(--sd-black400)!important}:host ::ng-deep .mat-mdc-form-field input.mat-mdc-input-element:disabled.c-selected:-ms-input-placeholder{color:var(--sd-black400)!important}:host ::ng-deep .mat-mdc-form-field input.mat-mdc-input-element:disabled.c-selected::-ms-input-placeholder{color:var(--sd-black400)!important}:host ::ng-deep .mat-mdc-form-field .mat-mdc-placeholder-required{color:var(--sd-error)}:host ::ng-deep .mat-mdc-form-field:hover .icon-copy{opacity:1}:host ::ng-deep .mat-mdc-form-field .icon-copy{cursor:pointer;width:.9em;height:.9em;fill:#00000080;transition:opacity .2s linear;opacity:0}::ng-deep .sd-autocomplete-panel .mat-mdc-option{min-height:36px!important;padding:8px 12px!important}::ng-deep .sd-autocomplete-panel .mdc-list-item__primary-text{font-size:14px!important;line-height:normal}::ng-deep .sd-autocomplete-panel .mat-pseudo-checkbox{transform:scale(.7);margin-right:8px!important}::ng-deep .sd-autocomplete-panel .mat-pseudo-checkbox-minimal{transform:scale(.7);transform-origin:center right}.sd__option--add{position:sticky;bottom:0;background-color:#fff;z-index:10;color:#000000de;cursor:pointer!important}.c-loading-icon{position:absolute;right:5px;top:5px}\n"] }]
|
|
656
|
+
], template: "@let _label = label();\n@let _appearance = appearance();\n@let _hideInlineError = hideInlineError();\n@let _errorMessage = errorMessage();\n@let _helperText = helperText();\n@let _required = required();\n@let _displayField = displayField();\n@let _disabledField = disabledField();\n@let iDefTpl = itemDef()?.templateRef;\n@let _loading = loading();\n@let _readState = readState();\n@let _isTyping = isTyping();\n@let nVal = $any(normalizedValue());\n@let _isInline = isInline();\n@let _bare = _isInline;\n@let _hasValue = nVal !== undefined && nVal !== null && nVal !== '';\n\n@if (isViewed()) {\n <sd-view\n [label]=\"_label\"\n [labelTemplate]=\"sdLabelTemplate()\"\n [value]=\"nVal\"\n [display]=\"display()\"\n [hyperlink]=\"hyperlink()\"\n [valueTemplate]=\"viewTemplate()\">\n </sd-view>\n} @else {\n @if (_isInline) {\n <!-- why: inline \u2014 sd-view l\u00E0 \"m\u1EB7t\" + trigger; autocomplete editor render \u1EA9n (.sd-inline-editor) ch\u1EC9 \u0111\u1EC3 m\u1EDF panel. -->\n <span class=\"sd-inline-view\" role=\"button\" tabindex=\"0\" (click)=\"enterInlineEdit()\" (keydown.enter)=\"enterInlineEdit()\">\n <sd-view\n [label]=\"_label\"\n [labelTemplate]=\"sdLabelTemplate()\"\n [value]=\"nVal\"\n [display]=\"display()\"\n [hyperlink]=\"hyperlink()\"\n [valueTemplate]=\"viewTemplate()\">\n </sd-view>\n @if (clearable() && _hasValue && !_required && !formControl.disabled) {\n <button type=\"button\" class=\"sd-inline-clear\" (click)=\"clear($event)\" title=\"X\u00F3a\" aria-label=\"X\u00F3a\">\n <mat-icon>close</mat-icon>\n </button>\n }\n </span>\n }\n\n @if (!_appearance) {\n <ng-content select=\"[sdLabel]\">\n @if (_label) {\n <sd-label [label]=\"_label\" [required]=\"_required\"></sd-label>\n }\n </ng-content>\n }\n\n <div\n class=\"d-flex align-items-center\" role=\"presentation\"\n [class.sd-inline-editor]=\"_isInline\"\n [class.c-focused]=\"isFocused\"\n [class.c-disabled]=\"formControl.disabled\"\n (click)=\"onClick()\">\n <mat-form-field\n [class.sd-md]=\"size() === 'md'\"\n [class.sd-sm]=\"size() === 'sm'\"\n [class.hide-inline-error]=\"_hideInlineError\"\n [floatLabel]=\"nVal ? 'always' : 'auto'\"\n [appearance]=\"_appearance || 'outline'\">\n @if (_appearance && _label) {\n <mat-label style=\"display: inline-block\">\n <div style=\"display: flex; align-items: center; gap: 4px\">\n <span>{{ _label }}</span>\n @if (_helperText) {\n <mat-icon [matTooltip]=\"_helperText\" matTooltipPosition=\"below\">info_outline</mat-icon>\n }\n </div>\n </mat-label>\n }\n\n <input\n [id]=\"id\"\n [formControl]=\"inputControl\"\n [placeholder]=\"controlPlaceHolder() || ''\"\n [class.c-selected]=\"nVal\"\n [matAutocomplete]=\"auto\"\n (focus)=\"onFocus()\"\n (blur)=\"onBlur($event)\"\n matInput\n [autocomplete]=\"id\"\n autocorrect=\"off\"\n [errorStateMatcher]=\"matcher\"\n [required]=\"_required\"\n #input\n #autocompleteTrigger=\"matAutocompleteTrigger\"\n [attr.data-autoId]=\"autoId()\"\n [attr.data-disabled]=\"dataDisabled()\"\n [attr.data-invalid]=\"dataInvalid()\"\n [attr.data-empty]=\"dataEmpty()\"\n [attr.data-value]=\"dataValue()\"\n [attr.data-loading]=\"dataLoading()\"\n [attr.data-required]=\"dataRequired()\"\n [attr.data-error-message]=\"dataErrorMessage()\" />\n\n @if (!_loading && nVal && !inputControl.disabled && !_bare) {\n <button type=\"button\" class=\"sd-clear-btn\" matSuffix (click)=\"clear($event)\" title=\"X\u00F3a\" aria-label=\"X\u00F3a\">\n <mat-icon>close</mat-icon>\n </button>\n } @else if (_loading) {\n <mat-spinner [diameter]=\"20\" matSuffix></mat-spinner>\n } @else {\n <mat-icon class=\"cursor-pointer sd-suffix-icon\" matSuffix>search</mat-icon>\n }\n\n <mat-autocomplete #auto=\"matAutocomplete\" (optionSelected)=\"onSelect($event.option.value)\" class=\"sd-autocomplete-panel\">\n @let _filteredItems = filteredItems();\n\n <!-- why: kh\u00F4ng hi\u1EC3n th\u1ECB l\u1ED7i k\u00EAnh c\u0169 c\u00F9ng spinner c\u1EE7a k\u00EAnh \u0111ang \u0111\u1ECDc/retry. -->\n @if (!_loading && _readState.status === 'error') {\n <!-- why: anchor gi\u1EEF panel m\u1EDF khi kh\u00F4ng c\u00F3 option; n\u00FAt retry kh\u00F4ng n\u1EB1m trong mat-option. -->\n <mat-option disabled class=\"sd-read-state-anchor\" aria-hidden=\"true\"></mat-option>\n @if (!hideReadError()) {\n <div class=\"sd-read-state-region\" role=\"presentation\" (mousedown)=\"$event.preventDefault()\" (click)=\"$event.stopPropagation()\" (keydown)=\"onReadRegionKeydown($event)\">\n <ng-container [ngTemplateOutlet]=\"readRegion\" [ngTemplateOutletContext]=\"{ state: 'error' }\"></ng-container>\n </div>\n }\n }\n\n @if (_filteredItems?.length) {\n @for (item of _filteredItems; track $index) {\n <mat-option\n [value]=\"item\"\n matTooltipPosition=\"above\"\n [matTooltip]=\"_displayField ? getNestedValue(item, _displayField) : item\"\n [disabled]=\"_disabledField ? getNestedValue(item, _disabledField) : false\">\n @if (iDefTpl) {\n <ng-container *ngTemplateOutlet=\"iDefTpl ?? null; context: { item: item }\"> </ng-container>\n } @else {\n {{ _displayField ? getNestedValue(item, _displayField) : item }}\n }\n </mat-option>\n }\n } @else if (_loading) {\n <mat-option disabled><mat-spinner diameter=\"24\"></mat-spinner></mat-option>\n } @else if (hasSearched() && !_isTyping && _readState.status === 'empty') {\n <mat-option disabled class=\"sd-read-state-anchor\" aria-hidden=\"true\"></mat-option>\n <ng-container [ngTemplateOutlet]=\"readRegion\" [ngTemplateOutletContext]=\"{ state: 'empty' }\"></ng-container>\n }\n\n @if (addable() && sdAdd.observed) {\n <mat-option disabled class=\"sd-read-state-anchor\" aria-hidden=\"true\"></mat-option>\n <button type=\"button\" class=\"sd__option--add\" (click)=\"onAdd($event)\" (keydown)=\"$event.stopPropagation()\">\n <mat-icon class=\"mr-1\">add</mat-icon>\n {{ 'New item' }}\n </button>\n }\n </mat-autocomplete>\n\n @if (_hideInlineError && _errorMessage && formControl.touched) {\n <mat-icon matSuffix class=\"sd-error-icon\" [matTooltip]=\"_errorMessage\" matTooltipPosition=\"above\"> error </mat-icon>\n }\n\n @if (!_hideInlineError && _errorMessage && formControl.touched) {\n <mat-error>{{ _errorMessage }}</mat-error>\n }\n </mat-form-field>\n </div>\n}\n\n<ng-template #readRegion let-current=\"state\">\n <sd-data-state [state]=\"current\" compact [retryable]=\"current === 'error'\" (sdRetry)=\"retryRead()\">\n @if (dataStateTemplate(); as custom) {\n <ng-template sdDataStateTemplate let-state let-retry=\"retry\" let-action=\"action\">\n <ng-container [ngTemplateOutlet]=\"custom.template\"\n [ngTemplateOutletContext]=\"{ $implicit: state, state: state, retry: retry, action: action }\"></ng-container>\n </ng-template>\n }\n </sd-data-state>\n</ng-template>\n", styles: [".text-primary{color:var(--sd-primary)!important}.bg-primary{background:var(--sd-primary)!important}.border-primary{border-color:var(--sd-primary)!important}.text-primary-light{color:var(--sd-primary-light)!important}.bg-primary-light{background:var(--sd-primary-light)!important}.border-primary-light{border-color:var(--sd-primary-light)!important}.text-primary-dark{color:var(--sd-primary-dark)!important}.bg-primary-dark{background:var(--sd-primary-dark)!important}.border-primary-dark{border-color:var(--sd-primary-dark)!important}.text-info{color:var(--sd-info)!important}.bg-info{background:var(--sd-info)!important}.border-info{border-color:var(--sd-info)!important}.text-info-light{color:var(--sd-info-light)!important}.bg-info-light{background:var(--sd-info-light)!important}.border-info-light{border-color:var(--sd-info-light)!important}.text-info-dark{color:var(--sd-info-dark)!important}.bg-info-dark{background:var(--sd-info-dark)!important}.border-info-dark{border-color:var(--sd-info-dark)!important}.text-success{color:var(--sd-success)!important}.bg-success{background:var(--sd-success)!important}.border-success{border-color:var(--sd-success)!important}.text-success-light{color:var(--sd-success-light)!important}.bg-success-light{background:var(--sd-success-light)!important}.border-success-light{border-color:var(--sd-success-light)!important}.text-success-dark{color:var(--sd-success-dark)!important}.bg-success-dark{background:var(--sd-success-dark)!important}.border-success-dark{border-color:var(--sd-success-dark)!important}.text-warning{color:var(--sd-warning)!important}.bg-warning{background:var(--sd-warning)!important}.border-warning{border-color:var(--sd-warning)!important}.text-warning-light{color:var(--sd-warning-light)!important}.bg-warning-light{background:var(--sd-warning-light)!important}.border-warning-light{border-color:var(--sd-warning-light)!important}.text-warning-dark{color:var(--sd-warning-dark)!important}.bg-warning-dark{background:var(--sd-warning-dark)!important}.border-warning-dark{border-color:var(--sd-warning-dark)!important}.text-error{color:var(--sd-error)!important}.bg-error{background:var(--sd-error)!important}.border-error{border-color:var(--sd-error)!important}.text-error-light{color:var(--sd-error-light)!important}.bg-error-light{background:var(--sd-error-light)!important}.border-error-light{border-color:var(--sd-error-light)!important}.text-error-dark{color:var(--sd-error-dark)!important}.bg-error-dark{background:var(--sd-error-dark)!important}.border-error-dark{border-color:var(--sd-error-dark)!important}.text-secondary{color:var(--sd-secondary)!important}.bg-secondary{background:var(--sd-secondary)!important}.border-secondary{border-color:var(--sd-secondary)!important}.text-secondary-light{color:var(--sd-secondary-light)!important}.bg-secondary-light{background:var(--sd-secondary-light)!important}.border-secondary-light{border-color:var(--sd-secondary-light)!important}.text-secondary-dark{color:var(--sd-secondary-dark)!important}.bg-secondary-dark{background:var(--sd-secondary-dark)!important}.border-secondary-dark{border-color:var(--sd-secondary-dark)!important}.text-light{color:var(--sd-light)!important}.bg-light{background:var(--sd-light)!important}.border-light{border-color:var(--sd-light)!important}.text-dark{color:var(--sd-dark)!important}.bg-dark{background:var(--sd-dark)!important}.border-dark{border-color:var(--sd-dark)!important}.text-black500{color:var(--sd-black500)!important}.bg-black500{background:var(--sd-black500)!important}.border-black500{border-color:var(--sd-black500)!important}.text-black400{color:var(--sd-black400)!important}.bg-black400{background:var(--sd-black400)!important}.border-black400{border-color:var(--sd-black400)!important}.text-black300{color:var(--sd-black300)!important}.bg-black300{background:var(--sd-black300)!important}.border-black300{border-color:var(--sd-black300)!important}.text-black200{color:var(--sd-black200)!important}.bg-black200{background:var(--sd-black200)!important}.border-black200{border-color:var(--sd-black200)!important}.text-black100{color:var(--sd-black100)!important}.bg-black100{background:var(--sd-black100)!important}.border-black100{border-color:var(--sd-black100)!important}.text-white{color:#fff!important}.bg-white{background:#fff!important}.border-white{border-color:#fff!important}.text-black{color:#000!important}.bg-black{background:#000!important}.border-black{border-color:#000!important}:host(.sd-bare){position:relative}.sd-inline-view{cursor:pointer;display:inline-flex;align-items:center;width:100%;padding:1px 6px;border-radius:4px;background-color:#0000000a;transition:background-color .15s ease}.sd-inline-view:hover{background-color:#00000014}.sd-inline-view .sd-inline-clear{display:none;align-items:center;margin-left:4px;padding:0;border:0;background:transparent;cursor:pointer;line-height:0;color:var(--sd-text-secondary, #6b7280);transition:color .15s ease}.sd-inline-view .sd-inline-clear mat-icon{font-size:16px;width:16px;height:16px}.sd-inline-view .sd-inline-clear:hover{color:var(--sd-error, #b32626)}.sd-inline-view:hover .sd-inline-clear{display:inline-flex}.sd-inline-editor{position:absolute;inset:0;opacity:0;pointer-events:none}.sd-inline-editor ::ng-deep *{pointer-events:none!important}:host{display:block}:host(.sd-has-label){padding-top:4px}:host(.sd-viewed){padding-top:0}:host ::ng-deep .mat-mdc-form-field.mat-form-field-appearance-outline.mat-form-field-disabled .mat-mdc-text-field-wrapper{background:var(--sd-black100)}:host ::ng-deep .mat-mdc-form-field input.c-selected::placeholder{color:#000;opacity:1}:host ::ng-deep .mat-mdc-form-field input.c-selected:-ms-input-placeholder{color:#000}:host ::ng-deep .mat-mdc-form-field input.c-selected::-ms-input-placeholder{color:#000}:host ::ng-deep .mat-mdc-form-field input.mat-mdc-input-element:disabled{color:var(--sd-black400)!important}:host ::ng-deep .mat-mdc-form-field input.mat-mdc-input-element:disabled.c-selected::placeholder{color:var(--sd-black400)!important}:host ::ng-deep .mat-mdc-form-field input.mat-mdc-input-element:disabled.c-selected:-ms-input-placeholder{color:var(--sd-black400)!important}:host ::ng-deep .mat-mdc-form-field input.mat-mdc-input-element:disabled.c-selected::-ms-input-placeholder{color:var(--sd-black400)!important}:host ::ng-deep .mat-mdc-form-field .mat-mdc-placeholder-required{color:var(--sd-error)}:host ::ng-deep .mat-mdc-form-field:hover .icon-copy{opacity:1}:host ::ng-deep .mat-mdc-form-field .icon-copy{cursor:pointer;width:.9em;height:.9em;fill:#00000080;transition:opacity .2s linear;opacity:0}::ng-deep .sd-autocomplete-panel .mat-mdc-option{min-height:36px!important;padding:8px 12px!important}::ng-deep .sd-autocomplete-panel .mdc-list-item__primary-text{font-size:14px!important;line-height:normal}::ng-deep .sd-autocomplete-panel .mat-pseudo-checkbox{transform:scale(.7);margin-right:8px!important}::ng-deep .sd-autocomplete-panel .mat-pseudo-checkbox-minimal{transform:scale(.7);transform-origin:center right}.sd__option--add{position:sticky;bottom:0;background-color:var(--sd-light);z-index:10;color:var(--sd-black500);display:flex;align-items:center;width:100%;min-height:48px;padding:0 16px;border:0;font:inherit;text-align:left;cursor:pointer!important}.c-loading-icon{position:absolute;right:5px;top:5px}::ng-deep .sd-autocomplete-panel .sd-read-state-anchor{display:none}\n"] }]
|
|
469
657
|
}], ctorParameters: () => [], propDecorators: { sdAdd: [{
|
|
470
658
|
type: Output
|
|
471
659
|
}] } });
|