angular-ui-controls 0.0.0-stage → 0.1.0-rc.2
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/LICENSE +21 -0
- package/README.md +74 -2
- package/fesm2022/angular-ui-controls-editor-build-Cm2HSXEy.mjs +2 -0
- package/fesm2022/angular-ui-controls-editor-build-Cm2HSXEy.mjs.map +1 -0
- package/fesm2022/angular-ui-controls-forms.mjs +865 -0
- package/fesm2022/angular-ui-controls-forms.mjs.map +1 -0
- package/fesm2022/angular-ui-controls-text-input.mjs +1210 -0
- package/fesm2022/angular-ui-controls-text-input.mjs.map +1 -0
- package/fesm2022/angular-ui-controls.mjs +7181 -0
- package/fesm2022/angular-ui-controls.mjs.map +1 -0
- package/forms/index.d.ts +425 -0
- package/forms/index.d.ts.map +1 -0
- package/index.d.ts +4345 -0
- package/index.d.ts.map +1 -0
- package/package.json +66 -3
- package/text-input/index.d.ts +609 -0
- package/text-input/index.d.ts.map +1 -0
|
@@ -0,0 +1,865 @@
|
|
|
1
|
+
import { BaseControlValueAccessor, UiIconsService, EllipsisTooltipDirective, SearchFilterPipe } from 'angular-ui-controls/text-input';
|
|
2
|
+
export * from 'angular-ui-controls/text-input';
|
|
3
|
+
import * as i0 from '@angular/core';
|
|
4
|
+
import { inject, signal, EventEmitter, viewChildren, viewChild, computed, Input, Output, Optional, Self, ChangeDetectionStrategy, Component, Pipe } from '@angular/core';
|
|
5
|
+
import * as i2 from '@angular/common';
|
|
6
|
+
import { CommonModule } from '@angular/common';
|
|
7
|
+
import * as i1 from '@angular/forms';
|
|
8
|
+
import { FormsModule } from '@angular/forms';
|
|
9
|
+
import * as i6 from '@angular/material/button';
|
|
10
|
+
import { MatButtonModule } from '@angular/material/button';
|
|
11
|
+
import * as i3 from '@angular/material/form-field';
|
|
12
|
+
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
13
|
+
import * as i5 from '@angular/material/icon';
|
|
14
|
+
import { MatIconModule } from '@angular/material/icon';
|
|
15
|
+
import * as i4 from '@angular/material/select';
|
|
16
|
+
import { MatSelect, MatSelectModule } from '@angular/material/select';
|
|
17
|
+
import * as i7 from '@angular/material/tooltip';
|
|
18
|
+
import { MatTooltipModule } from '@angular/material/tooltip';
|
|
19
|
+
import * as i10 from '@ngx-translate/core';
|
|
20
|
+
import { TranslateModule } from '@ngx-translate/core';
|
|
21
|
+
import * as i8 from 'ngx-mat-select-search';
|
|
22
|
+
import { NgxMatSelectSearchModule } from 'ngx-mat-select-search';
|
|
23
|
+
import * as i9 from '@angular/cdk/scrolling';
|
|
24
|
+
import { CdkVirtualScrollViewport, ScrollingModule } from '@angular/cdk/scrolling';
|
|
25
|
+
|
|
26
|
+
class SearchableSelectComponent extends BaseControlValueAccessor {
|
|
27
|
+
ngControl;
|
|
28
|
+
changeDetectorRef;
|
|
29
|
+
_icons = inject(UiIconsService);
|
|
30
|
+
/**
|
|
31
|
+
* Height in pixels of each option for virtual scrolling (defaults to 36px)
|
|
32
|
+
* @default 36
|
|
33
|
+
* @type number
|
|
34
|
+
*/
|
|
35
|
+
itemSize = 36;
|
|
36
|
+
/** HTML id for the select element */
|
|
37
|
+
rawInputId = '';
|
|
38
|
+
/**
|
|
39
|
+
* Identifier assigned to the inner control; combined with idPrefix when supplied.
|
|
40
|
+
* @type string
|
|
41
|
+
* @remarks Required Angular input; provide a stable identifier.
|
|
42
|
+
*/
|
|
43
|
+
set inputId(id) {
|
|
44
|
+
this.rawInputId = id || '';
|
|
45
|
+
this.configureId();
|
|
46
|
+
}
|
|
47
|
+
get inputId() {
|
|
48
|
+
return this.rawInputId;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Label text or translation key displayed for this control.
|
|
52
|
+
* @default ''
|
|
53
|
+
* @type string
|
|
54
|
+
*/
|
|
55
|
+
label = '';
|
|
56
|
+
/**
|
|
57
|
+
* Enable the search in the option
|
|
58
|
+
* @default true
|
|
59
|
+
* @type boolean
|
|
60
|
+
*/
|
|
61
|
+
showSearch = true;
|
|
62
|
+
/**
|
|
63
|
+
* Error message shown when validation fails
|
|
64
|
+
* @default ''
|
|
65
|
+
* @type string
|
|
66
|
+
*/
|
|
67
|
+
errorMessage = '';
|
|
68
|
+
/**
|
|
69
|
+
* Marks this control as required in its existing template; parent-form validators remain separately configured.
|
|
70
|
+
* @default false
|
|
71
|
+
* @type boolean
|
|
72
|
+
*/
|
|
73
|
+
required = false;
|
|
74
|
+
/**
|
|
75
|
+
* Consumer-defined field identifier included in event metadata. Existing event payload key names are preserved.
|
|
76
|
+
* @type string | number
|
|
77
|
+
* @renamedFrom textFieldName
|
|
78
|
+
*/
|
|
79
|
+
fieldName;
|
|
80
|
+
/**
|
|
81
|
+
* Placeholder text for the select field
|
|
82
|
+
* @default ''
|
|
83
|
+
* @type string
|
|
84
|
+
*/
|
|
85
|
+
selectPlaceholder = '';
|
|
86
|
+
/**
|
|
87
|
+
* Placeholder text for search input
|
|
88
|
+
* @default ''
|
|
89
|
+
* @type string
|
|
90
|
+
*/
|
|
91
|
+
searchPlaceholder = '';
|
|
92
|
+
/**
|
|
93
|
+
* Requests the existing read-only behavior without disabling the parent form control.
|
|
94
|
+
* @default false
|
|
95
|
+
* @type boolean
|
|
96
|
+
* @remarks Retained input; no consumer of this setting is present in the supplied class/template.
|
|
97
|
+
*/
|
|
98
|
+
readonly = false;
|
|
99
|
+
/**
|
|
100
|
+
* Displays "Select All" checkbox
|
|
101
|
+
* @default false
|
|
102
|
+
* @type boolean
|
|
103
|
+
*/
|
|
104
|
+
showToggleAllCheckbox = false;
|
|
105
|
+
/**
|
|
106
|
+
* Label shown when no entries are found
|
|
107
|
+
* @default 'No Entries Found'
|
|
108
|
+
* @type string
|
|
109
|
+
*/
|
|
110
|
+
noEntriesFoundLabel = 'No Entries Found';
|
|
111
|
+
/**
|
|
112
|
+
* Tooltip message for select-all checkbox
|
|
113
|
+
* @default ''
|
|
114
|
+
* @type string
|
|
115
|
+
*/
|
|
116
|
+
toggleAllCheckboxTooltipMessage = '';
|
|
117
|
+
/**
|
|
118
|
+
* Shows checkbox in search area
|
|
119
|
+
* @default false
|
|
120
|
+
* @type boolean
|
|
121
|
+
* @renamedFrom showSearchCheckBox
|
|
122
|
+
*/
|
|
123
|
+
showSearchCheckbox = false;
|
|
124
|
+
/**
|
|
125
|
+
* Enables the existing multiple-selection mode.
|
|
126
|
+
* @default false
|
|
127
|
+
* @type boolean
|
|
128
|
+
* @renamedFrom showMultiSelect
|
|
129
|
+
*/
|
|
130
|
+
multiple = false;
|
|
131
|
+
/**
|
|
132
|
+
* Options rendered by the control; use the label/value key inputs for object options.
|
|
133
|
+
* @default []
|
|
134
|
+
* @type SearchableSelectOption[]
|
|
135
|
+
* @renamedFrom selectList
|
|
136
|
+
*/
|
|
137
|
+
options = [];
|
|
138
|
+
/**
|
|
139
|
+
* Property name read from an option object to obtain its visible label.
|
|
140
|
+
* @default ''
|
|
141
|
+
* @type string
|
|
142
|
+
* @renamedFrom displayKey
|
|
143
|
+
*/
|
|
144
|
+
labelKey = '';
|
|
145
|
+
/**
|
|
146
|
+
* Property name used to identify or extract an option value.
|
|
147
|
+
* @default ''
|
|
148
|
+
* @type string
|
|
149
|
+
* @renamedFrom idKey
|
|
150
|
+
*/
|
|
151
|
+
valueKey = '';
|
|
152
|
+
/**
|
|
153
|
+
* Key in option object used to determine if the option should be hidden from dropdown. Defaults to 'isHidden'.
|
|
154
|
+
* @default 'isHidden'
|
|
155
|
+
* @type string
|
|
156
|
+
*/
|
|
157
|
+
hiddenKey = 'isHidden';
|
|
158
|
+
/**
|
|
159
|
+
* Enables server-side/external search by bypassing local pipe filtering
|
|
160
|
+
* @default false
|
|
161
|
+
* @type boolean
|
|
162
|
+
*/
|
|
163
|
+
serverSideSearch = false;
|
|
164
|
+
/** Search text entered by the user */
|
|
165
|
+
searchText = '';
|
|
166
|
+
_modelValueTracker = signal(null, ...(ngDevMode ? [{ debugName: "_modelValueTracker" }] : []));
|
|
167
|
+
_selectedValue = null;
|
|
168
|
+
isBlankValue(value) {
|
|
169
|
+
return value === null || value === undefined || value === '';
|
|
170
|
+
}
|
|
171
|
+
get hasSelectedValue() {
|
|
172
|
+
const value = this._selectedValue;
|
|
173
|
+
if (Array.isArray(value)) {
|
|
174
|
+
return value.length > 0;
|
|
175
|
+
}
|
|
176
|
+
return !this.isBlankValue(value);
|
|
177
|
+
}
|
|
178
|
+
/** Internal model bound to mat-select */
|
|
179
|
+
get selectedValue() {
|
|
180
|
+
return this._selectedValue;
|
|
181
|
+
}
|
|
182
|
+
set selectedValue(value) {
|
|
183
|
+
this._selectedValue = value;
|
|
184
|
+
// Filter out "All" for the external form control value
|
|
185
|
+
let cleanValue = value;
|
|
186
|
+
if (this.multiple && Array.isArray(value)) {
|
|
187
|
+
cleanValue = value.filter((item) => !this.compareObjects(item, this._allOptionObj));
|
|
188
|
+
}
|
|
189
|
+
if (!this.areValuesEqual(cleanValue, this.value)) {
|
|
190
|
+
this.value = cleanValue;
|
|
191
|
+
}
|
|
192
|
+
this._modelValueTracker.set(value);
|
|
193
|
+
}
|
|
194
|
+
/** @deprecated Use selectedValue for direct component access. */
|
|
195
|
+
get inputModelValue() {
|
|
196
|
+
return this.selectedValue;
|
|
197
|
+
}
|
|
198
|
+
set inputModelValue(value) {
|
|
199
|
+
this.selectedValue = value;
|
|
200
|
+
}
|
|
201
|
+
internalSelectList = [];
|
|
202
|
+
allOptionKey = Symbol('select-all');
|
|
203
|
+
primitiveAllOption = { toString: () => 'All' };
|
|
204
|
+
_allOptionObj = null;
|
|
205
|
+
modelNameMapping = new Map();
|
|
206
|
+
multiSelectInternalList = [];
|
|
207
|
+
/**
|
|
208
|
+
* Internal model getter/setter backed by the shared control value.
|
|
209
|
+
*/
|
|
210
|
+
get modelValue() {
|
|
211
|
+
return this.selectedValue;
|
|
212
|
+
}
|
|
213
|
+
set modelValue(newValue) {
|
|
214
|
+
if (this.valueKey && !this.multiple) {
|
|
215
|
+
this.selectedValue = newValue?.[this.valueKey] ?? newValue;
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
this.selectedValue = newValue;
|
|
219
|
+
this.syncMultiSelectModel();
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
/** Enable/disable search in the starting/conatin mode */
|
|
223
|
+
filterConditionStartWith = false;
|
|
224
|
+
/**
|
|
225
|
+
* Configuration for search starts with.
|
|
226
|
+
* @type boolean
|
|
227
|
+
* @renamedFrom isSearchStartsWith
|
|
228
|
+
*/
|
|
229
|
+
set searchStartsWith(condition) {
|
|
230
|
+
this.filterConditionStartWith = condition;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* To clear the selected dropdown list
|
|
234
|
+
* @default false
|
|
235
|
+
* @type boolean
|
|
236
|
+
*/
|
|
237
|
+
showClearIcon = false;
|
|
238
|
+
/**
|
|
239
|
+
* Emits when the select-all action runs.
|
|
240
|
+
* @payload SearchableSelectToggleAllEvent
|
|
241
|
+
* @remarks Payload shape is unchanged; see the emitting handler for field metadata.
|
|
242
|
+
* @renamedFrom toggleSelectHandle
|
|
243
|
+
*/
|
|
244
|
+
selectAllChange = new EventEmitter();
|
|
245
|
+
/**
|
|
246
|
+
* Emits when the selection handler processes a selection.
|
|
247
|
+
* @payload SearchableSelectSelectionChangeEvent
|
|
248
|
+
* @remarks Payload shape is unchanged; see the emitting handler for field metadata.
|
|
249
|
+
* @renamedFrom onselectionChange
|
|
250
|
+
*/
|
|
251
|
+
selectionChange = new EventEmitter();
|
|
252
|
+
/**
|
|
253
|
+
* Emits when the select panel open state changes.
|
|
254
|
+
* @payload SearchableSelectOpenCloseEvent
|
|
255
|
+
* @remarks Payload shape is unchanged; see the emitting handler for field metadata.
|
|
256
|
+
* @renamedFrom onOpenedChange
|
|
257
|
+
*/
|
|
258
|
+
panelOpenChange = new EventEmitter();
|
|
259
|
+
/**
|
|
260
|
+
* Emits when the select panel opens.
|
|
261
|
+
* @payload SearchableSelectFieldInfo
|
|
262
|
+
* @remarks Payload shape is unchanged; see the emitting handler for field metadata.
|
|
263
|
+
* @renamedFrom onOpened
|
|
264
|
+
*/
|
|
265
|
+
panelOpened = new EventEmitter();
|
|
266
|
+
/**
|
|
267
|
+
* Emits when the select panel closes.
|
|
268
|
+
* @payload SearchableSelectFieldInfo
|
|
269
|
+
* @remarks Payload shape is unchanged; see the emitting handler for field metadata.
|
|
270
|
+
* @renamedFrom onClosed
|
|
271
|
+
*/
|
|
272
|
+
panelClosed = new EventEmitter();
|
|
273
|
+
/**
|
|
274
|
+
* Emits when the control loses focus.
|
|
275
|
+
* @payload SearchableSelectFieldInfo
|
|
276
|
+
* @remarks Payload shape is unchanged; see the emitting handler for field metadata.
|
|
277
|
+
* @renamedFrom onBlur
|
|
278
|
+
*/
|
|
279
|
+
blurred = new EventEmitter();
|
|
280
|
+
/**
|
|
281
|
+
* Emits when an option is clicked.
|
|
282
|
+
* @payload SearchableSelectOptionClickEvent
|
|
283
|
+
* @remarks Payload shape is unchanged; see the emitting handler for field metadata.
|
|
284
|
+
* @renamedFrom onOptionClick
|
|
285
|
+
*/
|
|
286
|
+
optionClicked = new EventEmitter();
|
|
287
|
+
/**
|
|
288
|
+
* Emits the updated search string for consumer filtering.
|
|
289
|
+
* @payload string
|
|
290
|
+
* @remarks Payload shape is unchanged; see the emitting handler for field metadata.
|
|
291
|
+
* @renamedFrom onSearchTextModelChange
|
|
292
|
+
*/
|
|
293
|
+
searchTextChange = new EventEmitter();
|
|
294
|
+
// Get references to all MatOption instances rendered in the view
|
|
295
|
+
virtualOptions = viewChildren('virtualOption', ...(ngDevMode ? [{ debugName: "virtualOptions" }] : []));
|
|
296
|
+
// Reference to the underlying mat-select so parents can open/close it programmatically
|
|
297
|
+
matSelectRef = viewChild(MatSelect, ...(ngDevMode ? [{ debugName: "matSelectRef" }] : []));
|
|
298
|
+
// Get reference to the virtual scroll viewport
|
|
299
|
+
virtualScroll = viewChild(CdkVirtualScrollViewport, ...(ngDevMode ? [{ debugName: "virtualScroll" }] : []));
|
|
300
|
+
// Signal that stores values selected by the user
|
|
301
|
+
// but currently NOT rendered inside the virtual scroll viewport
|
|
302
|
+
hiddenOptions;
|
|
303
|
+
/**
|
|
304
|
+
* Key used to map model value to option
|
|
305
|
+
* @default false
|
|
306
|
+
* @type boolean
|
|
307
|
+
*/
|
|
308
|
+
enableAllOption = false;
|
|
309
|
+
/**
|
|
310
|
+
* Removes the "All" option that is otherwise added automatically in multi-select mode
|
|
311
|
+
* @default false
|
|
312
|
+
* @type boolean
|
|
313
|
+
*/
|
|
314
|
+
hideAllOption = false;
|
|
315
|
+
/**
|
|
316
|
+
* Key used to enable / disable sorting
|
|
317
|
+
* @default false
|
|
318
|
+
* @type boolean
|
|
319
|
+
*/
|
|
320
|
+
enableSorting = false;
|
|
321
|
+
/**
|
|
322
|
+
* Keeps each option on a single line with ellipsis; full text is shown in a tooltip on hover when truncated
|
|
323
|
+
* @default false
|
|
324
|
+
* @type boolean
|
|
325
|
+
*/
|
|
326
|
+
singleLineOption = false;
|
|
327
|
+
/**
|
|
328
|
+
* Defines whether the list should be sorted in ascending order.
|
|
329
|
+
* @type boolean
|
|
330
|
+
*/
|
|
331
|
+
set sortAscending(sortOrder) {
|
|
332
|
+
this.isAscendingOrder = sortOrder;
|
|
333
|
+
if (this.enableSorting) {
|
|
334
|
+
this.sortInternalSelectList();
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
/** Key used to enable / disable sorting */
|
|
338
|
+
isAscendingOrder = true;
|
|
339
|
+
/**
|
|
340
|
+
* Key used to sort the array
|
|
341
|
+
* @type string
|
|
342
|
+
*/
|
|
343
|
+
set sortKey(key) {
|
|
344
|
+
this.sortKeyValue = key;
|
|
345
|
+
if (this.enableSorting) {
|
|
346
|
+
this.sortInternalSelectList();
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
sortKeyValue = '';
|
|
350
|
+
constructor(ngControl, changeDetectorRef) {
|
|
351
|
+
super(ngControl, changeDetectorRef);
|
|
352
|
+
this.ngControl = ngControl;
|
|
353
|
+
this.changeDetectorRef = changeDetectorRef;
|
|
354
|
+
// Computed signal that recalculates whenever:
|
|
355
|
+
// - virtualOptions change
|
|
356
|
+
// - selectedValue changes
|
|
357
|
+
this.hiddenOptions = computed(() => {
|
|
358
|
+
// Create a Set of currently rendered option values
|
|
359
|
+
// This makes lookup O(1) when checking if a value exists
|
|
360
|
+
const virtualOptions = new Set(this.virtualOptions().map((matOption) => this.getOptionKey(matOption.value)));
|
|
361
|
+
const selectedValue = this._modelValueTracker();
|
|
362
|
+
// A blank value (null / undefined / '' / 0) is "no selection" - do not
|
|
363
|
+
// create a hidden option for it, otherwise mat-select treats the field
|
|
364
|
+
// as filled and floats the label on an empty control.
|
|
365
|
+
if (this.isBlankValue(selectedValue)) {
|
|
366
|
+
return [];
|
|
367
|
+
}
|
|
368
|
+
const selectedArray = Array.isArray(selectedValue) ? selectedValue : [selectedValue];
|
|
369
|
+
// Return selected values that are real and NOT currently rendered
|
|
370
|
+
// in the virtual scroll viewport
|
|
371
|
+
return selectedArray.filter((value) => !this.isBlankValue(value) && !virtualOptions.has(this.getOptionKey(value)));
|
|
372
|
+
}, ...(ngDevMode ? [{ debugName: "hiddenOptions" }] : []));
|
|
373
|
+
}
|
|
374
|
+
/** Identifies an option by valueKey, so a parent replacing options with new objects keeps the same option */
|
|
375
|
+
getOptionKey(option) {
|
|
376
|
+
return this.valueKey && option !== null && typeof option === 'object'
|
|
377
|
+
? option[this.valueKey]
|
|
378
|
+
: option;
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Intercept values written by Angular Forms framework (e.g., ngModel)
|
|
382
|
+
*/
|
|
383
|
+
writeValue(value) {
|
|
384
|
+
// 1. Call the base implementation to update this._value
|
|
385
|
+
super.writeValue(value);
|
|
386
|
+
// 2. Initialize internal value
|
|
387
|
+
this._selectedValue = value;
|
|
388
|
+
// 3. Sync "All" option if needed
|
|
389
|
+
this.syncMultiSelectModel();
|
|
390
|
+
// 4. Keep your signal tracker in sync so hiddenOptions computes properly
|
|
391
|
+
this._modelValueTracker.set(this._selectedValue);
|
|
392
|
+
}
|
|
393
|
+
trackByFn = (index, item) => {
|
|
394
|
+
return this.valueKey && item ? item[this.valueKey] : (item?.id ?? item);
|
|
395
|
+
};
|
|
396
|
+
compareObjects = (option1, option2) => {
|
|
397
|
+
if (this.valueKey && option1 != null && option2 != null) {
|
|
398
|
+
const val1 = typeof option1 === 'object'
|
|
399
|
+
? option1 === ''
|
|
400
|
+
? this.selectedValue[this.valueKey]
|
|
401
|
+
: option1[this.valueKey]
|
|
402
|
+
: option1 === ''
|
|
403
|
+
? this.selectedValue
|
|
404
|
+
: option1;
|
|
405
|
+
const val2 = typeof option2 === 'object' ? option2[this.valueKey] : option2;
|
|
406
|
+
return val1 === val2;
|
|
407
|
+
}
|
|
408
|
+
return option1 === option2;
|
|
409
|
+
};
|
|
410
|
+
fieldInfo() {
|
|
411
|
+
let inputRef = null;
|
|
412
|
+
if (this.effectiveId) {
|
|
413
|
+
inputRef = typeof document === 'undefined' ? null : document.getElementById(this.effectiveId);
|
|
414
|
+
}
|
|
415
|
+
const value = this.multiple
|
|
416
|
+
? (Array.isArray(this.selectedValue) ? this.selectedValue : []).filter((selectionOption) => !this.compareObjects(selectionOption, this._allOptionObj))
|
|
417
|
+
: this.getSelectedModelValue(this.selectedValue);
|
|
418
|
+
return {
|
|
419
|
+
...(inputRef && { inputRef }),
|
|
420
|
+
value,
|
|
421
|
+
modelValue: value,
|
|
422
|
+
fieldName: this.fieldName,
|
|
423
|
+
textFieldName: this.fieldName,
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
getSelectedModelValue(selectedValue) {
|
|
427
|
+
if (!this.options)
|
|
428
|
+
return selectedValue ?? this.selectedValue;
|
|
429
|
+
return (this.options.find((selectionItem) => selectionItem[this.valueKey] === selectedValue) ?? this.selectedValue);
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Emits when the selected value changes in the dropdown.
|
|
433
|
+
*
|
|
434
|
+
* @param handleSelectionChange - MatSelect change event containing selected value(s)
|
|
435
|
+
* @returns void
|
|
436
|
+
*/
|
|
437
|
+
handleSelectionChange(event) {
|
|
438
|
+
if (this.multiple) {
|
|
439
|
+
const emittedSelection = this.multiSelectInternalList.filter((item) => !this.compareObjects(item, this._allOptionObj));
|
|
440
|
+
this.selectedValue = [...this.multiSelectInternalList];
|
|
441
|
+
this.multiSelectInternalList = [];
|
|
442
|
+
this.selectionChange.emit({
|
|
443
|
+
...this.fieldInfo(),
|
|
444
|
+
selectionChange: { value: emittedSelection, source: event.source },
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
else {
|
|
448
|
+
this.selectedValue = event.value;
|
|
449
|
+
this.selectionChange.emit({
|
|
450
|
+
...this.fieldInfo(),
|
|
451
|
+
selectionChange: event,
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
this.commitValue();
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* Handles select-all toggle action from search checkbox.
|
|
458
|
+
*
|
|
459
|
+
* @param selectAllValue - True to select all options, false to clear selection
|
|
460
|
+
* @returns void
|
|
461
|
+
*/
|
|
462
|
+
toggleSelectAll(selectAllValue) {
|
|
463
|
+
if (this.disabled || this.readonly)
|
|
464
|
+
return;
|
|
465
|
+
if (this.multiple && selectAllValue) {
|
|
466
|
+
this.selectedValue = [...this.internalSelectList];
|
|
467
|
+
}
|
|
468
|
+
else {
|
|
469
|
+
this.selectedValue = [];
|
|
470
|
+
}
|
|
471
|
+
this.commitValue();
|
|
472
|
+
this.selectAllChange.emit({
|
|
473
|
+
...this.fieldInfo(),
|
|
474
|
+
selectAllValue,
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
handleOpenedChange(isOpen) {
|
|
478
|
+
const virtualScroll = this.virtualScroll();
|
|
479
|
+
if (!isOpen) {
|
|
480
|
+
this.searchText = '';
|
|
481
|
+
this._cachedOptionWidth = 0;
|
|
482
|
+
if (virtualScroll) {
|
|
483
|
+
// Reset scroll position back to the top
|
|
484
|
+
virtualScroll.scrollToOffset(0);
|
|
485
|
+
// Force viewport to recalculate its size
|
|
486
|
+
// Ensures proper rendering next time it opens
|
|
487
|
+
virtualScroll.checkViewportSize();
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
else if (virtualScroll) {
|
|
491
|
+
setTimeout(() => {
|
|
492
|
+
virtualScroll.checkViewportSize();
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
/**
|
|
497
|
+
* Emits when the open state of the dropdown changes.
|
|
498
|
+
*
|
|
499
|
+
* @param changeEvent - Boolean indicating open (true) or closed (false) state
|
|
500
|
+
* @returns void
|
|
501
|
+
*/
|
|
502
|
+
openedChange(opened) {
|
|
503
|
+
this.panelOpenChange.emit({
|
|
504
|
+
...this.fieldInfo(),
|
|
505
|
+
isOpen: opened,
|
|
506
|
+
selectionChange: opened,
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* Emits when the dropdown panel is opened.
|
|
511
|
+
*
|
|
512
|
+
* @returns void
|
|
513
|
+
*/
|
|
514
|
+
opened() {
|
|
515
|
+
this.panelOpened.emit(this.fieldInfo());
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* Emits when the dropdown panel is closed.
|
|
519
|
+
*
|
|
520
|
+
* @returns void
|
|
521
|
+
*/
|
|
522
|
+
closed() {
|
|
523
|
+
this.panelClosed.emit(this.fieldInfo());
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* Emits when the select element loses focus.
|
|
527
|
+
*
|
|
528
|
+
* @returns void
|
|
529
|
+
*/
|
|
530
|
+
blur() {
|
|
531
|
+
this.blurred.emit(this.fieldInfo());
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* Emits when a select option is clicked.
|
|
535
|
+
*
|
|
536
|
+
* @param selectedOption - The option object that was clicked
|
|
537
|
+
* @returns void
|
|
538
|
+
*/
|
|
539
|
+
optionClick(selectedOption) {
|
|
540
|
+
// Basic event emission. All select logic is processed declaratively inside handleSelectionChange()
|
|
541
|
+
this.optionClicked.emit({ activeOption: selectedOption });
|
|
542
|
+
}
|
|
543
|
+
searchTextModelChange(changedSearchText) {
|
|
544
|
+
this.searchTextChange.emit(changedSearchText);
|
|
545
|
+
}
|
|
546
|
+
_cachedOptionWidth = 0;
|
|
547
|
+
isTooltipDisabled(optionRef, text) {
|
|
548
|
+
const textStr = String(text ?? '');
|
|
549
|
+
if (textStr.length < 20)
|
|
550
|
+
return true;
|
|
551
|
+
const nativeEl = optionRef?._element?.nativeElement;
|
|
552
|
+
if (!this._cachedOptionWidth && nativeEl?.clientWidth) {
|
|
553
|
+
this._cachedOptionWidth = nativeEl.clientWidth;
|
|
554
|
+
}
|
|
555
|
+
if (this._cachedOptionWidth) {
|
|
556
|
+
const avgCharWidth = 7;
|
|
557
|
+
return textStr.length * avgCharWidth < this._cachedOptionWidth;
|
|
558
|
+
}
|
|
559
|
+
return false;
|
|
560
|
+
}
|
|
561
|
+
getTriggerText() {
|
|
562
|
+
if (this.multiple) {
|
|
563
|
+
if (Array.isArray(this.selectedValue) && this.selectedValue.length > 0) {
|
|
564
|
+
const isAllSelected = this.selectedValue.find((item) => this.compareObjects(item, this._allOptionObj));
|
|
565
|
+
if (isAllSelected) {
|
|
566
|
+
return this.labelKey ? this._allOptionObj[this.labelKey] : 'All';
|
|
567
|
+
}
|
|
568
|
+
else {
|
|
569
|
+
return this.selectedValue
|
|
570
|
+
.map((options) => this.modelNameMapping.get(options[this.valueKey] ?? options) ?? options)
|
|
571
|
+
.join(', ');
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
return '';
|
|
575
|
+
}
|
|
576
|
+
return (this.modelNameMapping.get(this.selectedValue) ||
|
|
577
|
+
this.selectedValue?.[this.labelKey] ||
|
|
578
|
+
'' ||
|
|
579
|
+
String(this.selectedValue ?? ''));
|
|
580
|
+
}
|
|
581
|
+
ngOnChanges(changes) {
|
|
582
|
+
if (changes['options'] ||
|
|
583
|
+
changes['multiple'] ||
|
|
584
|
+
changes['labelKey'] ||
|
|
585
|
+
changes['valueKey'] ||
|
|
586
|
+
changes['hiddenKey'] ||
|
|
587
|
+
changes['hideAllOption']) {
|
|
588
|
+
this.updateInternalList();
|
|
589
|
+
this.syncMultiSelectModel();
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
/**
|
|
593
|
+
* Generates the internal scroll list, automatically injecting
|
|
594
|
+
* an "All" option if multiple mode is active, and filtering out hidden options.
|
|
595
|
+
*/
|
|
596
|
+
updateInternalList() {
|
|
597
|
+
const list = (this.options || []).filter((item) => !item?.[this.hiddenKey]);
|
|
598
|
+
if ((this.multiple || this.enableAllOption) && !this.hideAllOption) {
|
|
599
|
+
if (this.valueKey || this.labelKey) {
|
|
600
|
+
// Keep the same object when options is replaced. A new object is not recognised as a
|
|
601
|
+
// rendered option, so it would get a hidden duplicate that takes the checked state.
|
|
602
|
+
const canReuseAllOption = this._allOptionObj &&
|
|
603
|
+
(!this.valueKey || this._allOptionObj[this.valueKey] === this.allOptionKey) &&
|
|
604
|
+
(!this.labelKey || this._allOptionObj[this.labelKey] === 'All');
|
|
605
|
+
if (!canReuseAllOption) {
|
|
606
|
+
this._allOptionObj = {
|
|
607
|
+
...(this.valueKey ? { [this.valueKey]: this.allOptionKey } : {}),
|
|
608
|
+
...(this.labelKey ? { [this.labelKey]: 'All' } : {}),
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
else {
|
|
613
|
+
this._allOptionObj = this.primitiveAllOption;
|
|
614
|
+
}
|
|
615
|
+
const hasAll = list.some((item) => this.compareObjects(item, this._allOptionObj));
|
|
616
|
+
if (!hasAll) {
|
|
617
|
+
this.internalSelectList = [this._allOptionObj, ...list];
|
|
618
|
+
}
|
|
619
|
+
else {
|
|
620
|
+
this.internalSelectList = [...list];
|
|
621
|
+
this._allOptionObj = list.find((item) => this.compareObjects(item, this._allOptionObj));
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
else {
|
|
625
|
+
this._allOptionObj = null;
|
|
626
|
+
this.internalSelectList = [...list];
|
|
627
|
+
}
|
|
628
|
+
this.modelNameMapping.clear();
|
|
629
|
+
// Populate modelNameMapping from the full list so selected hidden items can still resolve label in trigger
|
|
630
|
+
for (const option of this.options || []) {
|
|
631
|
+
if (this.valueKey && option) {
|
|
632
|
+
const record = option;
|
|
633
|
+
this.modelNameMapping.set(record[this.valueKey] ?? option, record[this.labelKey] ?? option);
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
if (this._allOptionObj && this.valueKey) {
|
|
637
|
+
this.modelNameMapping.set(this._allOptionObj[this.valueKey] ?? this._allOptionObj, this._allOptionObj[this.labelKey] ?? this._allOptionObj);
|
|
638
|
+
}
|
|
639
|
+
if (this.enableSorting) {
|
|
640
|
+
this.sortInternalSelectList();
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
/**
|
|
644
|
+
* Ensures the selectedValue incorporates or removes the "All" item automatically
|
|
645
|
+
* based on whether every single standard item has been selected or not.
|
|
646
|
+
*/
|
|
647
|
+
syncMultiSelectModel() {
|
|
648
|
+
if (!this.multiple || !this.options?.length || !this.internalSelectList?.length)
|
|
649
|
+
return;
|
|
650
|
+
if (!Array.isArray(this._selectedValue))
|
|
651
|
+
return;
|
|
652
|
+
const currentRealItems = this._selectedValue.filter((item) => !this.compareObjects(item, this._allOptionObj));
|
|
653
|
+
const selectableCount = this.internalSelectList.filter((item) => !this.compareObjects(item, this._allOptionObj)).length;
|
|
654
|
+
if (currentRealItems.length > 0 && currentRealItems.length === selectableCount) {
|
|
655
|
+
this._selectedValue = [...this.internalSelectList];
|
|
656
|
+
this._modelValueTracker.set(this._selectedValue);
|
|
657
|
+
}
|
|
658
|
+
else {
|
|
659
|
+
this._selectedValue = currentRealItems;
|
|
660
|
+
this._modelValueTracker.set(this._selectedValue);
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
areValuesEqual(val1, val2) {
|
|
664
|
+
if (Array.isArray(val1) && Array.isArray(val2)) {
|
|
665
|
+
if (val1.length !== val2.length)
|
|
666
|
+
return false;
|
|
667
|
+
return val1.every((item) => val2.some((other) => this.compareObjects(item, other)));
|
|
668
|
+
}
|
|
669
|
+
return this.compareObjects(val1, val2);
|
|
670
|
+
}
|
|
671
|
+
// Make sure to add this import at the top of the file if needed, or fully qualify it in typing
|
|
672
|
+
optionSelectionChange(event, option) {
|
|
673
|
+
if (!event.isUserInput || !this.multiple)
|
|
674
|
+
return;
|
|
675
|
+
const isChecking = event.source.selected;
|
|
676
|
+
const isAllObj = this.compareObjects(option, this._allOptionObj);
|
|
677
|
+
let currentVal = Array.isArray(this.selectedValue) ? [...this.selectedValue] : [];
|
|
678
|
+
let baseItems = currentVal.filter((item) => !this.compareObjects(item, this._allOptionObj));
|
|
679
|
+
if (isChecking) {
|
|
680
|
+
if (isAllObj) {
|
|
681
|
+
this.multiSelectInternalList = [...this.internalSelectList];
|
|
682
|
+
}
|
|
683
|
+
else {
|
|
684
|
+
if (!baseItems.some((item) => this.compareObjects(item, option))) {
|
|
685
|
+
baseItems.push(option);
|
|
686
|
+
}
|
|
687
|
+
const selectableCount = this.internalSelectList.filter((item) => !this.compareObjects(item, this._allOptionObj)).length;
|
|
688
|
+
if (baseItems.length === selectableCount) {
|
|
689
|
+
this.multiSelectInternalList = [...this.internalSelectList];
|
|
690
|
+
}
|
|
691
|
+
else {
|
|
692
|
+
this.multiSelectInternalList = baseItems;
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
else {
|
|
697
|
+
if (isAllObj) {
|
|
698
|
+
this.multiSelectInternalList = [];
|
|
699
|
+
}
|
|
700
|
+
else {
|
|
701
|
+
this.multiSelectInternalList = baseItems.filter((item) => !this.compareObjects(item, option));
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
/** Opens the dropdown panel programmatically */
|
|
706
|
+
open() {
|
|
707
|
+
this.matSelectRef()?.open();
|
|
708
|
+
}
|
|
709
|
+
clearSelect() {
|
|
710
|
+
if (this.disabled || this.readonly)
|
|
711
|
+
return;
|
|
712
|
+
this.selectedValue = null;
|
|
713
|
+
if (this.multiple) {
|
|
714
|
+
this.selectedValue = [];
|
|
715
|
+
}
|
|
716
|
+
this.commitValue();
|
|
717
|
+
this.selectionChange.emit({
|
|
718
|
+
...this.fieldInfo(),
|
|
719
|
+
selectionChange: null,
|
|
720
|
+
});
|
|
721
|
+
}
|
|
722
|
+
sortInternalSelectList() {
|
|
723
|
+
this.internalSelectList.sort((firstValue, secondValue) => {
|
|
724
|
+
const key = this.sortKeyValue || this.labelKey;
|
|
725
|
+
const first = key ? firstValue?.[key] : firstValue;
|
|
726
|
+
const second = key ? secondValue?.[key] : secondValue;
|
|
727
|
+
const sortResult = String(first ?? '').localeCompare(String(second ?? ''), undefined, {
|
|
728
|
+
numeric: true,
|
|
729
|
+
sensitivity: 'base',
|
|
730
|
+
});
|
|
731
|
+
return this.isAscendingOrder ? sortResult : -sortResult;
|
|
732
|
+
});
|
|
733
|
+
}
|
|
734
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.35", ngImport: i0, type: SearchableSelectComponent, deps: [{ token: i1.NgControl, optional: true, self: true }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
735
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.35", type: SearchableSelectComponent, isStandalone: true, selector: "ui-searchable-select", inputs: { itemSize: "itemSize", inputId: "inputId", label: "label", showSearch: "showSearch", errorMessage: "errorMessage", required: "required", fieldName: "fieldName", selectPlaceholder: "selectPlaceholder", searchPlaceholder: "searchPlaceholder", readonly: "readonly", showToggleAllCheckbox: "showToggleAllCheckbox", noEntriesFoundLabel: "noEntriesFoundLabel", toggleAllCheckboxTooltipMessage: "toggleAllCheckboxTooltipMessage", showSearchCheckbox: "showSearchCheckbox", multiple: "multiple", options: "options", labelKey: "labelKey", valueKey: "valueKey", hiddenKey: "hiddenKey", serverSideSearch: "serverSideSearch", searchStartsWith: "searchStartsWith", showClearIcon: "showClearIcon", enableAllOption: "enableAllOption", hideAllOption: "hideAllOption", enableSorting: "enableSorting", singleLineOption: "singleLineOption", sortAscending: "sortAscending", sortKey: "sortKey" }, outputs: { selectAllChange: "selectAllChange", selectionChange: "selectionChange", panelOpenChange: "panelOpenChange", panelOpened: "panelOpened", panelClosed: "panelClosed", blurred: "blurred", optionClicked: "optionClicked", searchTextChange: "searchTextChange" }, viewQueries: [{ propertyName: "virtualOptions", predicate: ["virtualOption"], descendants: true, isSignal: true }, { propertyName: "matSelectRef", first: true, predicate: MatSelect, descendants: true, isSignal: true }, { propertyName: "virtualScroll", first: true, predicate: CdkVirtualScrollViewport, descendants: true, isSignal: true }], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: "<div [ngClass]=\"{ 'required-text': required && !hasSelectedValue }\">\n <mat-form-field appearance=\"outline\">\n @if (label) {\n <mat-label [uiEllipsisTooltip]=\"label | translate\">{{ label | translate }}</mat-label>\n }\n @if (hasSelectedValue && showClearIcon) {\n <button\n type=\"button\"\n aria-label=\"Clear selection\"\n matTooltip=\"Clear\"\n matSuffix\n mat-icon-button\n (click)=\"$event.stopPropagation(); clearSelect()\"\n >\n <mat-icon svgIcon=\"ui:close\" class=\"Icon-xs text-danger me-1 text-danger d-flex\"></mat-icon>\n </button>\n }\n <mat-select\n [id]=\"effectiveId\"\n [(ngModel)]=\"selectedValue\"\n [ngModelOptions]=\"{ standalone: true }\"\n placeholder=\"{{ selectPlaceholder | translate }}\"\n (selectionChange)=\"handleSelectionChange($event)\"\n [multiple]=\"multiple\"\n (openedChange)=\"handleOpenedChange($event); openedChange($event)\"\n (opened)=\"opened()\"\n (closed)=\"closed()\"\n (blur)=\"blur()\"\n [disabled]=\"disabled || readonly\"\n [compareWith]=\"compareObjects\"\n >\n @if (hasSelectedValue) {\n <mat-select-trigger>\n {{ getTriggerText() }}\n </mat-select-trigger>\n }\n @if (showSearch && internalSelectList?.length) {\n <mat-option>\n <ngx-mat-select-search\n placeholderLabel=\"{{ searchPlaceholder | translate }}\"\n [noEntriesFoundLabel]=\"noEntriesFoundLabel\"\n [(ngModel)]=\"searchText\"\n [ngModelOptions]=\"{ standalone: true }\"\n [showToggleAllCheckbox]=\"showSearchCheckbox || showToggleAllCheckbox\"\n [toggleAllCheckboxTooltipMessage]=\"toggleAllCheckboxTooltipMessage\"\n (toggleAll)=\"toggleSelectAll($event)\"\n (ngModelChange)=\"searchTextModelChange($event)\"\n ></ngx-mat-select-search>\n </mat-option>\n }\n @let visibleOptions =\n internalSelectList\n | searchFilter\n : (serverSideSearch ? '' : searchText)\n : labelKey\n : filterConditionStartWith;\n <cdk-virtual-scroll-viewport\n [class.single-line-viewport]=\"singleLineOption\"\n [itemSize]=\"itemSize\"\n [style.--ui-option-row-height]=\"itemSize + 'px'\"\n minBufferPx=\"600\"\n maxBufferPx=\"1000\"\n [style.height.px]=\"visibleOptions.length * itemSize\"\n >\n @for (option of hiddenOptions(); track option) {\n <!-- IMPORTANT! Keep the content of 'mat-option' the same -->\n <mat-option [value]=\"option\" [style.display]=\"'none'\">\n {{ labelKey ? option?.[labelKey] : option }}\n </mat-option>\n }\n <mat-option\n #virtualOption\n class=\"ui-select-search-option ui-virtual-option\"\n [class.single-line-option]=\"singleLineOption\"\n *cdkVirtualFor=\"let option of visibleOptions; trackBy: trackByFn; templateCacheSize: 50\"\n [value]=\"valueKey && !multiple ? option[valueKey] : option\"\n (onSelectionChange)=\"optionSelectionChange($event, option)\"\n (click)=\"optionClick(option)\"\n [matTooltip]=\"labelKey ? option[labelKey] : option\"\n [disabled]=\"option?.['isDisabled']\"\n matTooltipPosition=\"above\"\n [matTooltipDisabled]=\"\n singleLineOption ||\n isTooltipDisabled(virtualOption, labelKey ? option[labelKey] : option)\n \"\n >\n @if (singleLineOption) {\n <span\n class=\"single-line-option-text\"\n [uiEllipsisTooltip]=\"labelKey ? option[labelKey] : option\"\n tooltipPosition=\"above\"\n >{{ labelKey ? option[labelKey] : option }}</span\n >\n } @else {\n {{ labelKey ? option[labelKey] : option }}\n }\n </mat-option>\n </cdk-virtual-scroll-viewport>\n </mat-select>\n @if (required && !hasSelectedValue && errorMessage) {\n <mat-error>\n {{ errorMessage | translate }}\n </mat-error>\n }\n </mat-form-field>\n</div>\n", styles: [".d-flex{display:flex}.text-danger{color:var(--mat-sys-error, var(--ui-danger-color, #dc3545))}.me-1{margin-inline-end:.25rem}:host{width:100%;display:inline-block}.single-line-option-text{display:block;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.single-line-viewport{overflow-x:hidden}mat-form-field{width:100%;min-width:0}cdk-virtual-scroll-viewport{max-height:200px}.ui-virtual-option{--mat-option-list-item-one-line-container-height: var(--ui-option-row-height);box-sizing:border-box;height:var(--ui-option-row-height);min-height:var(--ui-option-row-height);max-height:var(--ui-option-row-height);font-size:.875rem}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "ngmodule", type: MatFormFieldModule }, { 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: MatSelectModule }, { kind: "component", type: i4.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: "directive", type: i4.MatSelectTrigger, selector: "mat-select-trigger" }, { kind: "component", type: i4.MatOption, selector: "mat-option", inputs: ["value", "id", "disabled"], outputs: ["onSelectionChange"], exportAs: ["matOption"] }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i5.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i6.MatIconButton, selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]", exportAs: ["matButton", "matAnchor"] }, { kind: "ngmodule", type: MatTooltipModule }, { kind: "directive", type: i7.MatTooltip, selector: "[matTooltip]", inputs: ["matTooltipPosition", "matTooltipPositionAtOrigin", "matTooltipDisabled", "matTooltipShowDelay", "matTooltipHideDelay", "matTooltipTouchGestures", "matTooltip", "matTooltipClass"], exportAs: ["matTooltip"] }, { kind: "ngmodule", type: TranslateModule }, { kind: "ngmodule", type: NgxMatSelectSearchModule }, { kind: "component", type: i8.MatSelectSearchComponent, selector: "ngx-mat-select-search", inputs: ["placeholderLabel", "type", "closeIcon", "closeSvgIcon", "noEntriesFoundLabel", "clearSearchInput", "searching", "disableInitialFocus", "enableClearOnEscapePressed", "preventHomeEndKeyPropagation", "disableScrollToActiveOnOptionsChanged", "ariaLabel", "showToggleAllCheckbox", "toggleAllCheckboxChecked", "toggleAllCheckboxIndeterminate", "toggleAllCheckboxTooltipMessage", "toggleAllCheckboxTooltipPosition", "hideClearSearchButton", "alwaysRestoreSelectedOptionsMulti", "recreateValuesArray"], outputs: ["toggleAll"] }, { kind: "directive", type: EllipsisTooltipDirective, selector: "[uiEllipsisTooltip]", inputs: ["uiEllipsisTooltip", "tooltipPosition"] }, { kind: "ngmodule", type: ScrollingModule }, { kind: "directive", type: i9.CdkFixedSizeVirtualScroll, selector: "cdk-virtual-scroll-viewport[itemSize]", inputs: ["itemSize", "minBufferPx", "maxBufferPx"] }, { kind: "directive", type: i9.CdkVirtualForOf, selector: "[cdkVirtualFor][cdkVirtualForOf]", inputs: ["cdkVirtualForOf", "cdkVirtualForTrackBy", "cdkVirtualForTemplate", "cdkVirtualForTemplateCacheSize"] }, { kind: "component", type: i9.CdkVirtualScrollViewport, selector: "cdk-virtual-scroll-viewport", inputs: ["orientation", "appendOnly"], outputs: ["scrolledIndexChange"] }, { kind: "pipe", type: i10.TranslatePipe, name: "translate" }, { kind: "pipe", type: SearchFilterPipe, name: "searchFilter" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
736
|
+
}
|
|
737
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.35", ngImport: i0, type: SearchableSelectComponent, decorators: [{
|
|
738
|
+
type: Component,
|
|
739
|
+
args: [{ selector: 'ui-searchable-select', standalone: true, imports: [
|
|
740
|
+
CommonModule,
|
|
741
|
+
FormsModule,
|
|
742
|
+
MatFormFieldModule,
|
|
743
|
+
MatSelectModule,
|
|
744
|
+
MatIconModule,
|
|
745
|
+
MatButtonModule,
|
|
746
|
+
MatTooltipModule,
|
|
747
|
+
TranslateModule,
|
|
748
|
+
NgxMatSelectSearchModule,
|
|
749
|
+
EllipsisTooltipDirective,
|
|
750
|
+
SearchFilterPipe,
|
|
751
|
+
ScrollingModule,
|
|
752
|
+
], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div [ngClass]=\"{ 'required-text': required && !hasSelectedValue }\">\n <mat-form-field appearance=\"outline\">\n @if (label) {\n <mat-label [uiEllipsisTooltip]=\"label | translate\">{{ label | translate }}</mat-label>\n }\n @if (hasSelectedValue && showClearIcon) {\n <button\n type=\"button\"\n aria-label=\"Clear selection\"\n matTooltip=\"Clear\"\n matSuffix\n mat-icon-button\n (click)=\"$event.stopPropagation(); clearSelect()\"\n >\n <mat-icon svgIcon=\"ui:close\" class=\"Icon-xs text-danger me-1 text-danger d-flex\"></mat-icon>\n </button>\n }\n <mat-select\n [id]=\"effectiveId\"\n [(ngModel)]=\"selectedValue\"\n [ngModelOptions]=\"{ standalone: true }\"\n placeholder=\"{{ selectPlaceholder | translate }}\"\n (selectionChange)=\"handleSelectionChange($event)\"\n [multiple]=\"multiple\"\n (openedChange)=\"handleOpenedChange($event); openedChange($event)\"\n (opened)=\"opened()\"\n (closed)=\"closed()\"\n (blur)=\"blur()\"\n [disabled]=\"disabled || readonly\"\n [compareWith]=\"compareObjects\"\n >\n @if (hasSelectedValue) {\n <mat-select-trigger>\n {{ getTriggerText() }}\n </mat-select-trigger>\n }\n @if (showSearch && internalSelectList?.length) {\n <mat-option>\n <ngx-mat-select-search\n placeholderLabel=\"{{ searchPlaceholder | translate }}\"\n [noEntriesFoundLabel]=\"noEntriesFoundLabel\"\n [(ngModel)]=\"searchText\"\n [ngModelOptions]=\"{ standalone: true }\"\n [showToggleAllCheckbox]=\"showSearchCheckbox || showToggleAllCheckbox\"\n [toggleAllCheckboxTooltipMessage]=\"toggleAllCheckboxTooltipMessage\"\n (toggleAll)=\"toggleSelectAll($event)\"\n (ngModelChange)=\"searchTextModelChange($event)\"\n ></ngx-mat-select-search>\n </mat-option>\n }\n @let visibleOptions =\n internalSelectList\n | searchFilter\n : (serverSideSearch ? '' : searchText)\n : labelKey\n : filterConditionStartWith;\n <cdk-virtual-scroll-viewport\n [class.single-line-viewport]=\"singleLineOption\"\n [itemSize]=\"itemSize\"\n [style.--ui-option-row-height]=\"itemSize + 'px'\"\n minBufferPx=\"600\"\n maxBufferPx=\"1000\"\n [style.height.px]=\"visibleOptions.length * itemSize\"\n >\n @for (option of hiddenOptions(); track option) {\n <!-- IMPORTANT! Keep the content of 'mat-option' the same -->\n <mat-option [value]=\"option\" [style.display]=\"'none'\">\n {{ labelKey ? option?.[labelKey] : option }}\n </mat-option>\n }\n <mat-option\n #virtualOption\n class=\"ui-select-search-option ui-virtual-option\"\n [class.single-line-option]=\"singleLineOption\"\n *cdkVirtualFor=\"let option of visibleOptions; trackBy: trackByFn; templateCacheSize: 50\"\n [value]=\"valueKey && !multiple ? option[valueKey] : option\"\n (onSelectionChange)=\"optionSelectionChange($event, option)\"\n (click)=\"optionClick(option)\"\n [matTooltip]=\"labelKey ? option[labelKey] : option\"\n [disabled]=\"option?.['isDisabled']\"\n matTooltipPosition=\"above\"\n [matTooltipDisabled]=\"\n singleLineOption ||\n isTooltipDisabled(virtualOption, labelKey ? option[labelKey] : option)\n \"\n >\n @if (singleLineOption) {\n <span\n class=\"single-line-option-text\"\n [uiEllipsisTooltip]=\"labelKey ? option[labelKey] : option\"\n tooltipPosition=\"above\"\n >{{ labelKey ? option[labelKey] : option }}</span\n >\n } @else {\n {{ labelKey ? option[labelKey] : option }}\n }\n </mat-option>\n </cdk-virtual-scroll-viewport>\n </mat-select>\n @if (required && !hasSelectedValue && errorMessage) {\n <mat-error>\n {{ errorMessage | translate }}\n </mat-error>\n }\n </mat-form-field>\n</div>\n", styles: [".d-flex{display:flex}.text-danger{color:var(--mat-sys-error, var(--ui-danger-color, #dc3545))}.me-1{margin-inline-end:.25rem}:host{width:100%;display:inline-block}.single-line-option-text{display:block;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.single-line-viewport{overflow-x:hidden}mat-form-field{width:100%;min-width:0}cdk-virtual-scroll-viewport{max-height:200px}.ui-virtual-option{--mat-option-list-item-one-line-container-height: var(--ui-option-row-height);box-sizing:border-box;height:var(--ui-option-row-height);min-height:var(--ui-option-row-height);max-height:var(--ui-option-row-height);font-size:.875rem}\n"] }]
|
|
753
|
+
}], ctorParameters: () => [{ type: i1.NgControl, decorators: [{
|
|
754
|
+
type: Optional
|
|
755
|
+
}, {
|
|
756
|
+
type: Self
|
|
757
|
+
}] }, { type: i0.ChangeDetectorRef }], propDecorators: { itemSize: [{
|
|
758
|
+
type: Input
|
|
759
|
+
}], inputId: [{
|
|
760
|
+
type: Input,
|
|
761
|
+
args: [{ required: true }]
|
|
762
|
+
}], label: [{
|
|
763
|
+
type: Input
|
|
764
|
+
}], showSearch: [{
|
|
765
|
+
type: Input
|
|
766
|
+
}], errorMessage: [{
|
|
767
|
+
type: Input
|
|
768
|
+
}], required: [{
|
|
769
|
+
type: Input
|
|
770
|
+
}], fieldName: [{
|
|
771
|
+
type: Input
|
|
772
|
+
}], selectPlaceholder: [{
|
|
773
|
+
type: Input
|
|
774
|
+
}], searchPlaceholder: [{
|
|
775
|
+
type: Input
|
|
776
|
+
}], readonly: [{
|
|
777
|
+
type: Input
|
|
778
|
+
}], showToggleAllCheckbox: [{
|
|
779
|
+
type: Input
|
|
780
|
+
}], noEntriesFoundLabel: [{
|
|
781
|
+
type: Input
|
|
782
|
+
}], toggleAllCheckboxTooltipMessage: [{
|
|
783
|
+
type: Input
|
|
784
|
+
}], showSearchCheckbox: [{
|
|
785
|
+
type: Input
|
|
786
|
+
}], multiple: [{
|
|
787
|
+
type: Input
|
|
788
|
+
}], options: [{
|
|
789
|
+
type: Input
|
|
790
|
+
}], labelKey: [{
|
|
791
|
+
type: Input
|
|
792
|
+
}], valueKey: [{
|
|
793
|
+
type: Input
|
|
794
|
+
}], hiddenKey: [{
|
|
795
|
+
type: Input
|
|
796
|
+
}], serverSideSearch: [{
|
|
797
|
+
type: Input
|
|
798
|
+
}], searchStartsWith: [{
|
|
799
|
+
type: Input
|
|
800
|
+
}], showClearIcon: [{
|
|
801
|
+
type: Input
|
|
802
|
+
}], selectAllChange: [{
|
|
803
|
+
type: Output
|
|
804
|
+
}], selectionChange: [{
|
|
805
|
+
type: Output
|
|
806
|
+
}], panelOpenChange: [{
|
|
807
|
+
type: Output
|
|
808
|
+
}], panelOpened: [{
|
|
809
|
+
type: Output
|
|
810
|
+
}], panelClosed: [{
|
|
811
|
+
type: Output
|
|
812
|
+
}], blurred: [{
|
|
813
|
+
type: Output
|
|
814
|
+
}], optionClicked: [{
|
|
815
|
+
type: Output
|
|
816
|
+
}], searchTextChange: [{
|
|
817
|
+
type: Output
|
|
818
|
+
}], virtualOptions: [{ type: i0.ViewChildren, args: ['virtualOption', { isSignal: true }] }], matSelectRef: [{ type: i0.ViewChild, args: [i0.forwardRef(() => MatSelect), { isSignal: true }] }], virtualScroll: [{ type: i0.ViewChild, args: [i0.forwardRef(() => CdkVirtualScrollViewport), { isSignal: true }] }], enableAllOption: [{
|
|
819
|
+
type: Input
|
|
820
|
+
}], hideAllOption: [{
|
|
821
|
+
type: Input
|
|
822
|
+
}], enableSorting: [{
|
|
823
|
+
type: Input
|
|
824
|
+
}], singleLineOption: [{
|
|
825
|
+
type: Input
|
|
826
|
+
}], sortAscending: [{
|
|
827
|
+
type: Input
|
|
828
|
+
}], sortKey: [{
|
|
829
|
+
type: Input
|
|
830
|
+
}] } });
|
|
831
|
+
|
|
832
|
+
class IsEmptyPipe {
|
|
833
|
+
transform(value) {
|
|
834
|
+
if (value === null || value === undefined) {
|
|
835
|
+
return true;
|
|
836
|
+
}
|
|
837
|
+
if (typeof value === 'string') {
|
|
838
|
+
return !value.trim();
|
|
839
|
+
}
|
|
840
|
+
if (Array.isArray(value)) {
|
|
841
|
+
return !value.length;
|
|
842
|
+
}
|
|
843
|
+
if (typeof value === 'object') {
|
|
844
|
+
return !Object.keys(value)?.length;
|
|
845
|
+
}
|
|
846
|
+
return false;
|
|
847
|
+
}
|
|
848
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.35", ngImport: i0, type: IsEmptyPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
849
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.3.35", ngImport: i0, type: IsEmptyPipe, isStandalone: true, name: "isEmpty" });
|
|
850
|
+
}
|
|
851
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.35", ngImport: i0, type: IsEmptyPipe, decorators: [{
|
|
852
|
+
type: Pipe,
|
|
853
|
+
args: [{
|
|
854
|
+
name: 'isEmpty',
|
|
855
|
+
pure: true,
|
|
856
|
+
standalone: true,
|
|
857
|
+
}]
|
|
858
|
+
}] });
|
|
859
|
+
|
|
860
|
+
/**
|
|
861
|
+
* Generated bundle index. Do not edit.
|
|
862
|
+
*/
|
|
863
|
+
|
|
864
|
+
export { IsEmptyPipe, SearchableSelectComponent };
|
|
865
|
+
//# sourceMappingURL=angular-ui-controls-forms.mjs.map
|