@dmlibs/dm-cmps 0.0.1

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.
@@ -0,0 +1,588 @@
1
+ import * as i0 from '@angular/core';
2
+ import { signal, input, booleanAttribute, model, computed, output, effect, Component } from '@angular/core';
3
+ import { toObservable } from '@angular/core/rxjs-interop';
4
+ import { Subject, Subscription, switchMap, debounceTime, distinctUntilChanged } from 'rxjs';
5
+ import * as i1 from '@angular/material/form-field';
6
+ import { MatFormFieldModule, MatSuffix } from '@angular/material/form-field';
7
+ import * as i2 from '@angular/material/select';
8
+ import { MatSelectModule } from '@angular/material/select';
9
+ import * as i3 from '@angular/common';
10
+ import { CommonModule } from '@angular/common';
11
+ import * as i4 from '@angular/forms';
12
+ import { FormControl, FormsModule, ReactiveFormsModule } from '@angular/forms';
13
+ import * as i5 from '@angular/material/input';
14
+ import { MatInputModule } from '@angular/material/input';
15
+ import * as i6 from '@angular/material/checkbox';
16
+ import { MatCheckboxModule } from '@angular/material/checkbox';
17
+ import { MatIcon } from '@angular/material/icon';
18
+ import * as i7 from '@angular/material/button';
19
+ import { MatButtonModule } from '@angular/material/button';
20
+ import { MatTooltip } from '@angular/material/tooltip';
21
+
22
+ class DmCmpsDataSource {
23
+ data;
24
+ filteredData;
25
+ _resultData;
26
+ result = signal([], ...(ngDevMode ? [{ debugName: "result" }] : []));
27
+ paginationEnabled = false;
28
+ currentPageIndex = 0;
29
+ pageSize = 10;
30
+ autoPaginationAboveItemsCount = 100;
31
+ searchTerm = '';
32
+ speratedSearch = false;
33
+ filterPredicate = (item, filter) => {
34
+ if (!item || !filter) {
35
+ return true;
36
+ }
37
+ if (typeof item === 'string') {
38
+ return item.toLowerCase().includes(filter.toLowerCase());
39
+ }
40
+ const match = (term) => Object.values(item).some((value) => value != null && value.toString().toLowerCase().includes(term.toLowerCase()));
41
+ if (this.speratedSearch) {
42
+ const terms = filter
43
+ .split(' ')
44
+ .map((t) => t.trim())
45
+ .filter((t) => !!t);
46
+ return terms.every((term) => match(term));
47
+ }
48
+ return match(filter);
49
+ };
50
+ filterByObject = null;
51
+ fieldsToSearchIn = [];
52
+ sortMap = [];
53
+ sortFn = null;
54
+ searchTerms$ = new Subject();
55
+ searchDebounceTime = signal(300, ...(ngDevMode ? [{ debugName: "searchDebounceTime" }] : []));
56
+ subscription = new Subscription();
57
+ /**
58
+ * builds a new DmCmpsDataSource
59
+ * @param initialData The data to be used as datasource
60
+ */
61
+ constructor(initialData = []) {
62
+ this.data = initialData;
63
+ this.filteredData = [...initialData];
64
+ this._resultData = [...initialData];
65
+ if (this.autoPaginationAboveItemsCount > 0 &&
66
+ initialData.length > this.autoPaginationAboveItemsCount) {
67
+ this.paginationEnabled = true;
68
+ }
69
+ this.updateResultSignal();
70
+ this.subscription.add(toObservable(this.searchDebounceTime)
71
+ .pipe(switchMap((debounceMs) => this.searchTerms$.pipe(debounceTime(debounceMs), distinctUntilChanged((p, c) => p === c))))
72
+ .subscribe((term) => {
73
+ this.searchTerm = term;
74
+ this.applySearch();
75
+ }));
76
+ // this.searchTerms$
77
+ // .pipe(
78
+ // debounceTime(this.searchDebounceTime),
79
+ // distinctUntilChanged((p, c) => p === c && c != '')
80
+ // )
81
+ // .subscribe((term) => {
82
+ // this.searchTerm = term;
83
+ // this.applySearch();
84
+ // });
85
+ }
86
+ updateResultData() {
87
+ this.applySorting();
88
+ this.applySearch();
89
+ this.updateResultSignal();
90
+ }
91
+ disconnect() {
92
+ this.subscription.unsubscribe();
93
+ }
94
+ setAutoPaginationAboveItemsCount(count) {
95
+ this.autoPaginationAboveItemsCount = count;
96
+ if (count > 0 && this._resultData.length > count) {
97
+ this.paginationEnabled = true;
98
+ }
99
+ else {
100
+ this.paginationEnabled = false;
101
+ }
102
+ this.updateResultSignal();
103
+ }
104
+ applyPagination(pageSize) {
105
+ if (pageSize !== undefined && pageSize < 5) {
106
+ throw new Error('Page size must be at least 5');
107
+ }
108
+ this.currentPageIndex = 0;
109
+ this.paginationEnabled = true;
110
+ if (pageSize) {
111
+ this.pageSize = pageSize;
112
+ }
113
+ }
114
+ setPageSize(pageSize) {
115
+ if (pageSize < 5) {
116
+ throw new Error('Page size must be at least 5');
117
+ }
118
+ this.pageSize = pageSize;
119
+ this.updateResultSignal();
120
+ }
121
+ disablePagination() {
122
+ this.currentPageIndex = 0;
123
+ this.paginationEnabled = false;
124
+ this.updateResultSignal();
125
+ }
126
+ nextPage() {
127
+ if (this.pageSize <= 0 || !this.paginationEnabled) {
128
+ return 0;
129
+ }
130
+ const totalPages = Math.ceil(this._resultData.length / this.pageSize);
131
+ if (this.currentPageIndex < totalPages - 1) {
132
+ this.currentPageIndex++;
133
+ }
134
+ this.updateResultSignal();
135
+ return this.currentPageIndex;
136
+ }
137
+ previousPage() {
138
+ if (this.pageSize <= 0 || !this.paginationEnabled) {
139
+ return 0;
140
+ }
141
+ if (this.currentPageIndex > 0) {
142
+ this.currentPageIndex--;
143
+ }
144
+ this.updateResultSignal();
145
+ return this.currentPageIndex;
146
+ }
147
+ firstPage() {
148
+ if (this.pageSize <= 0 || !this.paginationEnabled) {
149
+ return 0;
150
+ }
151
+ this.currentPageIndex = 0;
152
+ this.updateResultSignal();
153
+ return this.currentPageIndex;
154
+ }
155
+ lastPage() {
156
+ if (this.pageSize <= 0 || !this.paginationEnabled) {
157
+ return 0;
158
+ }
159
+ const totalPages = Math.ceil(this._resultData.length / this.pageSize);
160
+ this.currentPageIndex = totalPages - 1;
161
+ this.updateResultSignal();
162
+ return this.currentPageIndex;
163
+ }
164
+ getCurrentPageIndex() {
165
+ return this.currentPageIndex;
166
+ }
167
+ getTotalPagesCount() {
168
+ if (this.pageSize <= 0) {
169
+ return 1;
170
+ }
171
+ return Math.ceil(this._resultData.length / this.pageSize);
172
+ }
173
+ setSearchDebounceTime(milliseconds) {
174
+ this.searchDebounceTime.set(milliseconds);
175
+ }
176
+ setDatasource(newData) {
177
+ this.data = [...newData];
178
+ this.applyObjectFilter();
179
+ }
180
+ updateResultSignal() {
181
+ const res = (() => {
182
+ if (this.pageSize > 0 &&
183
+ (this.paginationEnabled ||
184
+ (this.autoPaginationAboveItemsCount > 0 &&
185
+ this._resultData.length > this.autoPaginationAboveItemsCount))) {
186
+ const startIndex = this.currentPageIndex * this.pageSize;
187
+ return this._resultData.slice(startIndex, startIndex + this.pageSize);
188
+ }
189
+ return this._resultData;
190
+ })();
191
+ this.result.set(res);
192
+ }
193
+ // get resultData(): T[] {
194
+ // if (
195
+ // this.pageSize > 0 &&
196
+ // (this.paginationEnabled ||
197
+ // (this.autoPaginationAboveItemsCount > 0 &&
198
+ // this._resultData.length > this.autoPaginationAboveItemsCount))
199
+ // ) {
200
+ // const startIndex = this.currentPageIndex * this.pageSize;
201
+ // return this.filteredData.slice(startIndex, startIndex + this.pageSize);
202
+ // }
203
+ // return this.filteredData;
204
+ // }
205
+ search(filterTerm) {
206
+ this.searchTerms$.next(filterTerm);
207
+ }
208
+ applySearch() {
209
+ if (!this.searchTerm) {
210
+ this._resultData = [...this.filteredData];
211
+ }
212
+ else {
213
+ this.currentPageIndex = 0;
214
+ this._resultData = this.filteredData.filter((item) => this.filterPredicate(item, this.searchTerm));
215
+ }
216
+ this.updateResultSignal();
217
+ }
218
+ setFilterPredicate(predicate) {
219
+ this.filterPredicate = predicate;
220
+ }
221
+ setFieldsToSearchIn(fields) {
222
+ if (!fields || fields.length === 0) {
223
+ throw new Error('Fields to search in cannot be empty');
224
+ }
225
+ this.fieldsToSearchIn = fields;
226
+ this.setFilterPredicate((item, filter) => {
227
+ if (!item || !filter) {
228
+ return true;
229
+ }
230
+ if (this.speratedSearch) {
231
+ const terms = filter
232
+ .split(' ')
233
+ .map((t) => t.trim())
234
+ .filter((t) => !!t);
235
+ return terms.every((term) => {
236
+ return this.fieldsToSearchIn.some((field) => {
237
+ const value = item[field];
238
+ if (value != null) {
239
+ return value.toString().toLowerCase().includes(term.toLowerCase());
240
+ }
241
+ return false;
242
+ });
243
+ });
244
+ }
245
+ return this.fieldsToSearchIn.some((field) => {
246
+ const value = item[field];
247
+ if (value != null) {
248
+ return value.toString().toLowerCase().includes(filter.toLowerCase());
249
+ }
250
+ return false;
251
+ });
252
+ });
253
+ }
254
+ setSortFunction(sortFn) {
255
+ this.sortFn = sortFn;
256
+ }
257
+ applySorting() {
258
+ if (this.sortMap.length === 0 && !this.sortFn) {
259
+ return;
260
+ }
261
+ if (this.sortFn) {
262
+ this.filteredData.sort(this.sortFn);
263
+ return;
264
+ }
265
+ this.filteredData.sort((a, b) => {
266
+ for (const sort of this.sortMap) {
267
+ let comparison = 0;
268
+ if (sort.sortFn) {
269
+ comparison = sort.sortFn(a, b);
270
+ }
271
+ else {
272
+ const aValue = a[sort.field];
273
+ const bValue = b[sort.field];
274
+ if (isNaN(aValue) || isNaN(bValue)) {
275
+ if (typeof aValue === 'string' && typeof bValue === 'string') {
276
+ comparison = aValue.localeCompare(bValue);
277
+ }
278
+ else {
279
+ comparison = 0;
280
+ }
281
+ }
282
+ else if (aValue < bValue) {
283
+ comparison = -1;
284
+ }
285
+ else if (aValue > bValue) {
286
+ comparison = 1;
287
+ }
288
+ else {
289
+ comparison = 0;
290
+ }
291
+ }
292
+ if (comparison !== 0) {
293
+ return sort.direction === 'asc' ? comparison : -comparison;
294
+ }
295
+ }
296
+ return 0;
297
+ });
298
+ }
299
+ sortByFields(sortMap) {
300
+ this.sortMap = sortMap;
301
+ this.sortFn = null;
302
+ this.updateResultData();
303
+ }
304
+ resetSorting() {
305
+ this.sortMap = [];
306
+ this.sortFn = null;
307
+ this.applyObjectFilter();
308
+ }
309
+ setFilterByObjectFields(filterObj) {
310
+ this.filterByObject = filterObj;
311
+ this.applyObjectFilter();
312
+ }
313
+ applyObjectFilter() {
314
+ if (!this.filterByObject) {
315
+ this.filteredData = [...this.data];
316
+ }
317
+ else {
318
+ this.filteredData = this.data.filter((item) => {
319
+ for (const [key, value] of Object.entries(this.filterByObject)) {
320
+ if (item[key] !== value) {
321
+ return false;
322
+ }
323
+ }
324
+ return true;
325
+ });
326
+ }
327
+ this.updateResultData();
328
+ }
329
+ applySperatedSearch(enabled) {
330
+ this.speratedSearch = enabled;
331
+ }
332
+ }
333
+
334
+ const SEARCH_SECTION_BG_COLOR_VAR = '--dm-mat-select-search-section-bg-color';
335
+ const SEARCH_SECTION_BG_COLOR_DEFAULT_VALUE = '#faf9fd';
336
+
337
+ class DmMatSelect {
338
+ formFieldClass = input('', ...(ngDevMode ? [{ debugName: "formFieldClass" }] : []));
339
+ wrapperClass = input('', ...(ngDevMode ? [{ debugName: "wrapperClass" }] : []));
340
+ appearance = input('fill', ...(ngDevMode ? [{ debugName: "appearance" }] : []));
341
+ multiple = input(false, { ...(ngDevMode ? { debugName: "multiple" } : {}), transform: booleanAttribute });
342
+ selectAllEnabled = input(false, { ...(ngDevMode ? { debugName: "selectAllEnabled" } : {}), transform: booleanAttribute });
343
+ selectAllLabel = input('בחר הכל', ...(ngDevMode ? [{ debugName: "selectAllLabel" }] : []));
344
+ label = input('', ...(ngDevMode ? [{ debugName: "label" }] : []));
345
+ options = input([], ...(ngDevMode ? [{ debugName: "options" }] : []));
346
+ optionValueKey = input('_id', ...(ngDevMode ? [{ debugName: "optionValueKey" }] : []));
347
+ optionLabelKey = input('name', ...(ngDevMode ? [{ debugName: "optionLabelKey" }] : []));
348
+ searchable = input(false, { ...(ngDevMode ? { debugName: "searchable" } : {}), transform: booleanAttribute });
349
+ required = input(false, { ...(ngDevMode ? { debugName: "required" } : {}), transform: booleanAttribute });
350
+ disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : {}), transform: booleanAttribute });
351
+ error = input(null, ...(ngDevMode ? [{ debugName: "error" }] : []));
352
+ searchPlaceholder = input('חפש...', ...(ngDevMode ? [{ debugName: "searchPlaceholder" }] : []));
353
+ emptyOption = input(false, { ...(ngDevMode ? { debugName: "emptyOption" } : {}), transform: booleanAttribute });
354
+ emptyOptionLabel = input('ללא', ...(ngDevMode ? [{ debugName: "emptyOptionLabel" }] : []));
355
+ emptyOptionValue = input(null, ...(ngDevMode ? [{ debugName: "emptyOptionValue" }] : []));
356
+ optionNameFormat = input(null, ...(ngDevMode ? [{ debugName: "optionNameFormat" }] : []));
357
+ _optionNameFormat = null;
358
+ datasource = signal(new DmCmpsDataSource(), ...(ngDevMode ? [{ debugName: "datasource" }] : []));
359
+ value = model(null, ...(ngDevMode ? [{ debugName: "value" }] : []));
360
+ formControl = input(null, ...(ngDevMode ? [{ debugName: "formControl" }] : []));
361
+ panelWidth = input('auto', ...(ngDevMode ? [{ debugName: "panelWidth" }] : []));
362
+ panelClass = input('', ...(ngDevMode ? [{ debugName: "panelClass" }] : []));
363
+ searchSectionBackgroundColor = input(SEARCH_SECTION_BG_COLOR_DEFAULT_VALUE, ...(ngDevMode ? [{ debugName: "searchSectionBackgroundColor" }] : []));
364
+ sortBySelectedOnTop = input(false, { ...(ngDevMode ? { debugName: "sortBySelectedOnTop" } : {}), transform: booleanAttribute });
365
+ internalControl = new FormControl(null);
366
+ control = computed(() => this.formControl() ?? this.internalControl, ...(ngDevMode ? [{ debugName: "control" }] : []));
367
+ selectionChange = output();
368
+ icon = input(null, ...(ngDevMode ? [{ debugName: "icon" }] : []));
369
+ isBootstrapIcon = computed(() => {
370
+ return this.icon() ? this.icon().includes('bi-') : false;
371
+ }, ...(ngDevMode ? [{ debugName: "isBootstrapIcon" }] : []));
372
+ noDataLabel = input('אין נתונים להצגה', ...(ngDevMode ? [{ debugName: "noDataLabel" }] : []));
373
+ clearSearchAfterSelect = input(true, { ...(ngDevMode ? { debugName: "clearSearchAfterSelect" } : {}), transform: booleanAttribute });
374
+ clearSearchButtonTooltip = input('נקה חיפוש', ...(ngDevMode ? [{ debugName: "clearSearchButtonTooltip" }] : []));
375
+ focusSearchInputOnPanelOpen = input(true, { ...(ngDevMode ? { debugName: "focusSearchInputOnPanelOpen" } : {}), transform: booleanAttribute });
376
+ filterPredicate = input(null, ...(ngDevMode ? [{ debugName: "filterPredicate" }] : []));
377
+ _filterPredicate = null;
378
+ simpleArray = computed(() => {
379
+ return typeof this.options()[0] === 'string' || typeof this.options()[0] === 'number';
380
+ }, ...(ngDevMode ? [{ debugName: "simpleArray" }] : []));
381
+ selectedOptionsIdsSet = signal(new Set(), ...(ngDevMode ? [{ debugName: "selectedOptionsIdsSet" }] : []));
382
+ filterText = model('', ...(ngDevMode ? [{ debugName: "filterText" }] : []));
383
+ checkIfAllSelected = computed(() => {
384
+ const options = this.datasource().result();
385
+ const selected = this.control().value;
386
+ const allSelected = options.length > 0 &&
387
+ Array.isArray(selected) &&
388
+ selected.length >= options.length &&
389
+ options.every((option) => {
390
+ const optionValue = this.getOptionValue(option);
391
+ return this.selectedOptionsIdsSet().has(optionValue);
392
+ });
393
+ return allSelected;
394
+ }, ...(ngDevMode ? [{ debugName: "checkIfAllSelected" }] : []));
395
+ constructor() {
396
+ this.runEffects();
397
+ }
398
+ ngOnDestroy() {
399
+ this.datasource().disconnect();
400
+ }
401
+ setOptionsFormattedNames(options) {
402
+ if (this._optionNameFormat) {
403
+ for (const option of options) {
404
+ option.__dmMatSelectFormattedName = this._optionNameFormat(option);
405
+ }
406
+ }
407
+ }
408
+ runEffects() {
409
+ effect(() => {
410
+ this._filterPredicate = this.filterPredicate();
411
+ this._optionNameFormat = this.optionNameFormat();
412
+ });
413
+ effect(() => {
414
+ const opts = this.options();
415
+ this.setOptionsFormattedNames(opts);
416
+ this.datasource().setAutoPaginationAboveItemsCount(-1);
417
+ this.datasource().setSearchDebounceTime(3000);
418
+ if (this._filterPredicate) {
419
+ console.log('filter predicate updated!!!!!!!!');
420
+ this.datasource().setFilterPredicate(this._filterPredicate);
421
+ }
422
+ if (this.sortBySelectedOnTop() && this.multiple()) {
423
+ this.datasource().setSortFunction(((a, b) => {
424
+ const aSelected = this.selectedOptionsIdsSet().has(this.getOptionValue(a));
425
+ const bSelected = this.selectedOptionsIdsSet().has(this.getOptionValue(b));
426
+ if (aSelected && !bSelected) {
427
+ return -1;
428
+ }
429
+ else if (!aSelected && bSelected) {
430
+ return 1;
431
+ }
432
+ else {
433
+ return 0;
434
+ }
435
+ }).bind(this));
436
+ }
437
+ this.datasource().setDatasource(opts);
438
+ });
439
+ effect(() => {
440
+ if (this.formControl()) {
441
+ return;
442
+ }
443
+ this.internalControl.setValue(this.value(), { emitEvent: false });
444
+ });
445
+ effect((onCleanup) => {
446
+ const ctrl = this.control();
447
+ const setSelectedIdsSet = (selectedVal) => {
448
+ const newSelectedIdsSet = new Set();
449
+ if (this.multiple()) {
450
+ const arr = Array.isArray(selectedVal) ? selectedVal : [];
451
+ for (const item of arr) {
452
+ const id = this.getOptionValue(item);
453
+ newSelectedIdsSet.add(id);
454
+ }
455
+ this.selectedOptionsIdsSet.set(newSelectedIdsSet);
456
+ }
457
+ };
458
+ setSelectedIdsSet(ctrl.value);
459
+ const sub = ctrl.valueChanges.subscribe((val) => {
460
+ setSelectedIdsSet(val);
461
+ this.value.set(val);
462
+ });
463
+ onCleanup(() => sub.unsubscribe());
464
+ });
465
+ effect(() => {
466
+ document.documentElement.style.setProperty(SEARCH_SECTION_BG_COLOR_VAR, this.searchSectionBackgroundColor() ?? SEARCH_SECTION_BG_COLOR_DEFAULT_VALUE);
467
+ });
468
+ }
469
+ applyFilter(event) {
470
+ const target = event.target;
471
+ this.filterText.set(target.value);
472
+ this.datasource().search(this.filterText());
473
+ }
474
+ selectionChangeHandler(event) {
475
+ this.selectionChange.emit(event);
476
+ }
477
+ getOptionValue(option) {
478
+ if (this.simpleArray())
479
+ return option;
480
+ return typeof option === 'object' && option != null
481
+ ? option[this.optionValueKey()]
482
+ : option;
483
+ }
484
+ onSelectionChangeHandler(event, option) {
485
+ if (!event.isUserInput)
486
+ return;
487
+ console.log('selection change!!');
488
+ const selected = event.source.selected;
489
+ const currentValue = this.control().value;
490
+ if (this.multiple()) {
491
+ if (!option)
492
+ return;
493
+ const arr = Array.isArray(currentValue) ? currentValue : [];
494
+ let newValue;
495
+ if (selected) {
496
+ newValue = [...arr, this.getOptionValue(option)];
497
+ }
498
+ else {
499
+ newValue = arr.filter((v) => v !== this.getOptionValue(option));
500
+ }
501
+ this.control().setValue(newValue);
502
+ }
503
+ else {
504
+ if (!option) {
505
+ this.control().setValue(this.emptyOptionValue());
506
+ return;
507
+ }
508
+ if (selected) {
509
+ console.log('set value => ', option);
510
+ this.control().setValue(this.getOptionValue(option));
511
+ }
512
+ else {
513
+ this.control().setValue(null);
514
+ }
515
+ }
516
+ if (this.clearSearchAfterSelect()) {
517
+ this.resetSearch();
518
+ }
519
+ }
520
+ selectAllChange(event) {
521
+ if (event.checked) {
522
+ const allValues = this.datasource()
523
+ .result()
524
+ .map((option) => this.getOptionValue(option));
525
+ const newValues = Array.isArray(this.control().value)
526
+ ? this.control().value
527
+ : [];
528
+ for (const val of allValues) {
529
+ if (!this.selectedOptionsIdsSet().has(val)) {
530
+ newValues.push(val);
531
+ }
532
+ }
533
+ this.control().setValue(newValues);
534
+ }
535
+ else {
536
+ const selectedValues = this.control().value.filter((val) => {
537
+ const allOptionValues = this.datasource()
538
+ .result()
539
+ .map((option) => this.getOptionValue(option));
540
+ return !allOptionValues.includes(val);
541
+ });
542
+ this.control().setValue(selectedValues);
543
+ }
544
+ }
545
+ resetSearch() {
546
+ this.filterText.set('');
547
+ this.datasource().search('');
548
+ }
549
+ onPanelOpened() {
550
+ if (this.focusSearchInputOnPanelOpen()) {
551
+ const searchInput = document.getElementById('dm-mat-select-search-input');
552
+ setTimeout(() => {
553
+ if (searchInput) {
554
+ searchInput.focus();
555
+ }
556
+ }, 0);
557
+ }
558
+ }
559
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: DmMatSelect, deps: [], target: i0.ɵɵFactoryTarget.Component });
560
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.0.3", type: DmMatSelect, isStandalone: true, selector: "dm-mat-select", inputs: { formFieldClass: { classPropertyName: "formFieldClass", publicName: "formFieldClass", isSignal: true, isRequired: false, transformFunction: null }, wrapperClass: { classPropertyName: "wrapperClass", publicName: "wrapperClass", isSignal: true, isRequired: false, transformFunction: null }, appearance: { classPropertyName: "appearance", publicName: "appearance", isSignal: true, isRequired: false, transformFunction: null }, multiple: { classPropertyName: "multiple", publicName: "multiple", isSignal: true, isRequired: false, transformFunction: null }, selectAllEnabled: { classPropertyName: "selectAllEnabled", publicName: "selectAllEnabled", isSignal: true, isRequired: false, transformFunction: null }, selectAllLabel: { classPropertyName: "selectAllLabel", publicName: "selectAllLabel", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null }, optionValueKey: { classPropertyName: "optionValueKey", publicName: "optionValueKey", isSignal: true, isRequired: false, transformFunction: null }, optionLabelKey: { classPropertyName: "optionLabelKey", publicName: "optionLabelKey", isSignal: true, isRequired: false, transformFunction: null }, searchable: { classPropertyName: "searchable", publicName: "searchable", 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 }, error: { classPropertyName: "error", publicName: "error", isSignal: true, isRequired: false, transformFunction: null }, searchPlaceholder: { classPropertyName: "searchPlaceholder", publicName: "searchPlaceholder", isSignal: true, isRequired: false, transformFunction: null }, emptyOption: { classPropertyName: "emptyOption", publicName: "emptyOption", isSignal: true, isRequired: false, transformFunction: null }, emptyOptionLabel: { classPropertyName: "emptyOptionLabel", publicName: "emptyOptionLabel", isSignal: true, isRequired: false, transformFunction: null }, emptyOptionValue: { classPropertyName: "emptyOptionValue", publicName: "emptyOptionValue", isSignal: true, isRequired: false, transformFunction: null }, optionNameFormat: { classPropertyName: "optionNameFormat", publicName: "optionNameFormat", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, formControl: { classPropertyName: "formControl", publicName: "formControl", isSignal: true, isRequired: false, transformFunction: null }, panelWidth: { classPropertyName: "panelWidth", publicName: "panelWidth", isSignal: true, isRequired: false, transformFunction: null }, panelClass: { classPropertyName: "panelClass", publicName: "panelClass", isSignal: true, isRequired: false, transformFunction: null }, searchSectionBackgroundColor: { classPropertyName: "searchSectionBackgroundColor", publicName: "searchSectionBackgroundColor", isSignal: true, isRequired: false, transformFunction: null }, sortBySelectedOnTop: { classPropertyName: "sortBySelectedOnTop", publicName: "sortBySelectedOnTop", isSignal: true, isRequired: false, transformFunction: null }, icon: { classPropertyName: "icon", publicName: "icon", isSignal: true, isRequired: false, transformFunction: null }, noDataLabel: { classPropertyName: "noDataLabel", publicName: "noDataLabel", isSignal: true, isRequired: false, transformFunction: null }, clearSearchAfterSelect: { classPropertyName: "clearSearchAfterSelect", publicName: "clearSearchAfterSelect", isSignal: true, isRequired: false, transformFunction: null }, clearSearchButtonTooltip: { classPropertyName: "clearSearchButtonTooltip", publicName: "clearSearchButtonTooltip", isSignal: true, isRequired: false, transformFunction: null }, focusSearchInputOnPanelOpen: { classPropertyName: "focusSearchInputOnPanelOpen", publicName: "focusSearchInputOnPanelOpen", isSignal: true, isRequired: false, transformFunction: null }, filterPredicate: { classPropertyName: "filterPredicate", publicName: "filterPredicate", isSignal: true, isRequired: false, transformFunction: null }, filterText: { classPropertyName: "filterText", publicName: "filterText", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange", selectionChange: "selectionChange", filterText: "filterTextChange" }, ngImport: i0, template: "<div class=\"dm-mat-select-wrapper\" [class]=\"wrapperClass()\">\n <mat-form-field [appearance]=\"appearance()\" [class]=\"formFieldClass()\">\n <mat-label>{{ label() }}</mat-label>\n <mat-select\n [multiple]=\"multiple()\"\n [formControl]=\"control()\"\n (selectionChange)=\"selectionChangeHandler($event)\"\n [disabled]=\"disabled()\"\n [panelWidth]=\"panelWidth()\"\n [panelClass]=\"panelClass()\"\n (opened)=\"onPanelOpened()\"\n >\n <div\n class=\"search-section\"\n [ngStyle]=\"{\n 'background-color': 'none'\n }\"\n >\n @if (searchable()) {\n <mat-form-field>\n <input\n id=\"dm-mat-select-search-input\"\n matInput\n [placeholder]=\"searchPlaceholder()\"\n [(ngModel)]=\"filterText\"\n (keyup)=\"applyFilter($event)\"\n />\n @if (filterText()) {\n <button\n mat-icon-button\n matSuffix\n (click)=\"resetSearch()\"\n [matTooltip]=\"clearSearchButtonTooltip() || ''\"\n >\n <mat-icon>close</mat-icon>\n </button>\n }\n </mat-form-field>\n } @if (selectAllEnabled() && multiple()) {\n <mat-checkbox [checked]=\"checkIfAllSelected()\" (change)=\"selectAllChange($event)\">{{\n selectAllLabel()\n }}</mat-checkbox>\n }\n </div>\n @if (emptyOption()) {\n <mat-option\n [value]=\"emptyOptionValue()\"\n (onSelectionChange)=\"onSelectionChangeHandler($event, emptyOptionValue())\"\n >{{ emptyOptionLabel() }}</mat-option\n >\n } @for (option of datasource().result(); track simpleArray() ? option :\n option[this.optionValueKey()]) {\n <mat-option\n [value]=\"simpleArray() ? option : option[optionValueKey()]\"\n (onSelectionChange)=\"onSelectionChangeHandler($event, option)\"\n >{{\n optionNameFormat()\n ? option.__dmMatSelectFormattedName\n : simpleArray()\n ? option\n : option[optionLabelKey()]\n }}</mat-option\n >\n } @if (datasource().result().length === 0) {\n <mat-option disabled>{{ noDataLabel() }}</mat-option>\n }\n </mat-select>\n\n @if (icon(); as icon) {\n <span matSuffix>\n @if (isBootstrapIcon()) {\n <span [innerHTML]=\"icon\"></span> } @else {\n <mat-icon matSuffix>{{ icon }}</mat-icon>\n }\n </span>\n }\n\n <span matSuffix>\n <ng-content select=\"[dm-mat-select-suffix]\"></ng-content>\n </span>\n\n <mat-error>{{ error() }}</mat-error>\n </mat-form-field>\n</div>\n", styles: [":host{display:block;width:auto;height:auto}:host .dm-mat-select-wrapper{width:100%;height:100%;position:relative}:host .dm-mat-select-wrapper .search-section{display:flex;flex-direction:column;position:sticky;top:0;z-index:1;background-color:var(--dm-mat-select-search-section-bg-color, #faf9fd)}:host .dm-mat-select-wrapper .search-section ::ng-deep mat-form-field>.mat-mdc-form-field-subscript-wrapper{display:none}:host .dm-mat-select-wrapper ::ng-deep mat-form-field>.mat-mdc-text-field-wrapper>.mat-mdc-form-field-flex>.mat-mdc-form-field-icon-suffix{padding:0 4px 0 8px}\n"], dependencies: [{ kind: "ngmodule", type: MatFormFieldModule }, { kind: "component", type: i1.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i1.MatLabel, selector: "mat-label" }, { kind: "directive", type: i1.MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "directive", type: i1.MatSuffix, selector: "[matSuffix], [matIconSuffix], [matTextSuffix]", inputs: ["matTextSuffix"] }, { kind: "ngmodule", type: MatSelectModule }, { kind: "component", type: i2.MatSelect, selector: "mat-select", inputs: ["aria-describedby", "panelClass", "disabled", "disableRipple", "tabIndex", "hideSingleSelectionIndicator", "placeholder", "required", "multiple", "disableOptionCentering", "compareWith", "value", "aria-label", "aria-labelledby", "errorStateMatcher", "typeaheadDebounceInterval", "sortComparator", "id", "panelWidth", "canSelectNullableOptions"], outputs: ["openedChange", "opened", "closed", "selectionChange", "valueChange"], exportAs: ["matSelect"] }, { kind: "component", type: i2.MatOption, selector: "mat-option", inputs: ["value", "id", "disabled"], outputs: ["onSelectionChange"], exportAs: ["matOption"] }, { kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i3.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i4.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: i4.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i4.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i4.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "ngmodule", type: MatInputModule }, { kind: "directive", type: i5.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: "ngmodule", type: MatCheckboxModule }, { kind: "component", type: i6.MatCheckbox, selector: "mat-checkbox", inputs: ["aria-label", "aria-labelledby", "aria-describedby", "aria-expanded", "aria-controls", "aria-owns", "id", "required", "labelPosition", "name", "value", "disableRipple", "tabIndex", "color", "disabledInteractive", "checked", "disabled", "indeterminate"], outputs: ["change", "indeterminateChange"], exportAs: ["matCheckbox"] }, { kind: "component", type: MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i7.MatIconButton, selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]", exportAs: ["matButton", "matAnchor"] }, { kind: "directive", type: MatTooltip, selector: "[matTooltip]", inputs: ["matTooltipPosition", "matTooltipPositionAtOrigin", "matTooltipDisabled", "matTooltipShowDelay", "matTooltipHideDelay", "matTooltipTouchGestures", "matTooltip", "matTooltipClass"], exportAs: ["matTooltip"] }] });
561
+ }
562
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: DmMatSelect, decorators: [{
563
+ type: Component,
564
+ args: [{ selector: 'dm-mat-select', standalone: true, imports: [
565
+ MatFormFieldModule,
566
+ MatSelectModule,
567
+ CommonModule,
568
+ FormsModule,
569
+ ReactiveFormsModule,
570
+ MatInputModule,
571
+ MatCheckboxModule,
572
+ MatIcon,
573
+ MatButtonModule,
574
+ MatTooltip,
575
+ MatSuffix,
576
+ ], template: "<div class=\"dm-mat-select-wrapper\" [class]=\"wrapperClass()\">\n <mat-form-field [appearance]=\"appearance()\" [class]=\"formFieldClass()\">\n <mat-label>{{ label() }}</mat-label>\n <mat-select\n [multiple]=\"multiple()\"\n [formControl]=\"control()\"\n (selectionChange)=\"selectionChangeHandler($event)\"\n [disabled]=\"disabled()\"\n [panelWidth]=\"panelWidth()\"\n [panelClass]=\"panelClass()\"\n (opened)=\"onPanelOpened()\"\n >\n <div\n class=\"search-section\"\n [ngStyle]=\"{\n 'background-color': 'none'\n }\"\n >\n @if (searchable()) {\n <mat-form-field>\n <input\n id=\"dm-mat-select-search-input\"\n matInput\n [placeholder]=\"searchPlaceholder()\"\n [(ngModel)]=\"filterText\"\n (keyup)=\"applyFilter($event)\"\n />\n @if (filterText()) {\n <button\n mat-icon-button\n matSuffix\n (click)=\"resetSearch()\"\n [matTooltip]=\"clearSearchButtonTooltip() || ''\"\n >\n <mat-icon>close</mat-icon>\n </button>\n }\n </mat-form-field>\n } @if (selectAllEnabled() && multiple()) {\n <mat-checkbox [checked]=\"checkIfAllSelected()\" (change)=\"selectAllChange($event)\">{{\n selectAllLabel()\n }}</mat-checkbox>\n }\n </div>\n @if (emptyOption()) {\n <mat-option\n [value]=\"emptyOptionValue()\"\n (onSelectionChange)=\"onSelectionChangeHandler($event, emptyOptionValue())\"\n >{{ emptyOptionLabel() }}</mat-option\n >\n } @for (option of datasource().result(); track simpleArray() ? option :\n option[this.optionValueKey()]) {\n <mat-option\n [value]=\"simpleArray() ? option : option[optionValueKey()]\"\n (onSelectionChange)=\"onSelectionChangeHandler($event, option)\"\n >{{\n optionNameFormat()\n ? option.__dmMatSelectFormattedName\n : simpleArray()\n ? option\n : option[optionLabelKey()]\n }}</mat-option\n >\n } @if (datasource().result().length === 0) {\n <mat-option disabled>{{ noDataLabel() }}</mat-option>\n }\n </mat-select>\n\n @if (icon(); as icon) {\n <span matSuffix>\n @if (isBootstrapIcon()) {\n <span [innerHTML]=\"icon\"></span> } @else {\n <mat-icon matSuffix>{{ icon }}</mat-icon>\n }\n </span>\n }\n\n <span matSuffix>\n <ng-content select=\"[dm-mat-select-suffix]\"></ng-content>\n </span>\n\n <mat-error>{{ error() }}</mat-error>\n </mat-form-field>\n</div>\n", styles: [":host{display:block;width:auto;height:auto}:host .dm-mat-select-wrapper{width:100%;height:100%;position:relative}:host .dm-mat-select-wrapper .search-section{display:flex;flex-direction:column;position:sticky;top:0;z-index:1;background-color:var(--dm-mat-select-search-section-bg-color, #faf9fd)}:host .dm-mat-select-wrapper .search-section ::ng-deep mat-form-field>.mat-mdc-form-field-subscript-wrapper{display:none}:host .dm-mat-select-wrapper ::ng-deep mat-form-field>.mat-mdc-text-field-wrapper>.mat-mdc-form-field-flex>.mat-mdc-form-field-icon-suffix{padding:0 4px 0 8px}\n"] }]
577
+ }], ctorParameters: () => [], propDecorators: { formFieldClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "formFieldClass", required: false }] }], wrapperClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "wrapperClass", required: false }] }], appearance: [{ type: i0.Input, args: [{ isSignal: true, alias: "appearance", required: false }] }], multiple: [{ type: i0.Input, args: [{ isSignal: true, alias: "multiple", required: false }] }], selectAllEnabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectAllEnabled", required: false }] }], selectAllLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectAllLabel", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }], optionValueKey: [{ type: i0.Input, args: [{ isSignal: true, alias: "optionValueKey", required: false }] }], optionLabelKey: [{ type: i0.Input, args: [{ isSignal: true, alias: "optionLabelKey", required: false }] }], searchable: [{ type: i0.Input, args: [{ isSignal: true, alias: "searchable", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], error: [{ type: i0.Input, args: [{ isSignal: true, alias: "error", required: false }] }], searchPlaceholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "searchPlaceholder", required: false }] }], emptyOption: [{ type: i0.Input, args: [{ isSignal: true, alias: "emptyOption", required: false }] }], emptyOptionLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "emptyOptionLabel", required: false }] }], emptyOptionValue: [{ type: i0.Input, args: [{ isSignal: true, alias: "emptyOptionValue", required: false }] }], optionNameFormat: [{ type: i0.Input, args: [{ isSignal: true, alias: "optionNameFormat", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], formControl: [{ type: i0.Input, args: [{ isSignal: true, alias: "formControl", required: false }] }], panelWidth: [{ type: i0.Input, args: [{ isSignal: true, alias: "panelWidth", required: false }] }], panelClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "panelClass", required: false }] }], searchSectionBackgroundColor: [{ type: i0.Input, args: [{ isSignal: true, alias: "searchSectionBackgroundColor", required: false }] }], sortBySelectedOnTop: [{ type: i0.Input, args: [{ isSignal: true, alias: "sortBySelectedOnTop", required: false }] }], selectionChange: [{ type: i0.Output, args: ["selectionChange"] }], icon: [{ type: i0.Input, args: [{ isSignal: true, alias: "icon", required: false }] }], noDataLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "noDataLabel", required: false }] }], clearSearchAfterSelect: [{ type: i0.Input, args: [{ isSignal: true, alias: "clearSearchAfterSelect", required: false }] }], clearSearchButtonTooltip: [{ type: i0.Input, args: [{ isSignal: true, alias: "clearSearchButtonTooltip", required: false }] }], focusSearchInputOnPanelOpen: [{ type: i0.Input, args: [{ isSignal: true, alias: "focusSearchInputOnPanelOpen", required: false }] }], filterPredicate: [{ type: i0.Input, args: [{ isSignal: true, alias: "filterPredicate", required: false }] }], filterText: [{ type: i0.Input, args: [{ isSignal: true, alias: "filterText", required: false }] }, { type: i0.Output, args: ["filterTextChange"] }] } });
578
+
579
+ /*
580
+ * Public API Surface of dm-cmps
581
+ */
582
+
583
+ /**
584
+ * Generated bundle index. Do not edit.
585
+ */
586
+
587
+ export { DmCmpsDataSource, DmMatSelect };
588
+ //# sourceMappingURL=dmlibs-dm-cmps.mjs.map