@i-cell/ids-angular 0.0.0-watch

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.
Files changed (133) hide show
  1. package/README.md +24 -0
  2. package/accordion/index.d.ts +81 -0
  3. package/accordion/package.json +3 -0
  4. package/avatar/index.d.ts +66 -0
  5. package/avatar/package.json +3 -0
  6. package/badge/index.d.ts +61 -0
  7. package/badge/package.json +3 -0
  8. package/breadcrumb/index.d.ts +67 -0
  9. package/breadcrumb/package.json +3 -0
  10. package/button/index.d.ts +81 -0
  11. package/button/package.json +3 -0
  12. package/card/index.d.ts +91 -0
  13. package/card/package.json +3 -0
  14. package/checkbox/index.d.ts +137 -0
  15. package/checkbox/package.json +3 -0
  16. package/chip/index.d.ts +82 -0
  17. package/chip/package.json +3 -0
  18. package/core/index.d.ts +168 -0
  19. package/core/package.json +3 -0
  20. package/datepicker/index.d.ts +112 -0
  21. package/datepicker/package.json +3 -0
  22. package/dialog/index.d.ts +72 -0
  23. package/dialog/package.json +3 -0
  24. package/divider/index.d.ts +45 -0
  25. package/divider/package.json +3 -0
  26. package/fesm2022/i-cell-ids-angular-accordion.mjs +223 -0
  27. package/fesm2022/i-cell-ids-angular-accordion.mjs.map +1 -0
  28. package/fesm2022/i-cell-ids-angular-avatar.mjs +125 -0
  29. package/fesm2022/i-cell-ids-angular-avatar.mjs.map +1 -0
  30. package/fesm2022/i-cell-ids-angular-badge.mjs +172 -0
  31. package/fesm2022/i-cell-ids-angular-badge.mjs.map +1 -0
  32. package/fesm2022/i-cell-ids-angular-breadcrumb.mjs +313 -0
  33. package/fesm2022/i-cell-ids-angular-breadcrumb.mjs.map +1 -0
  34. package/fesm2022/i-cell-ids-angular-button.mjs +149 -0
  35. package/fesm2022/i-cell-ids-angular-button.mjs.map +1 -0
  36. package/fesm2022/i-cell-ids-angular-card.mjs +222 -0
  37. package/fesm2022/i-cell-ids-angular-card.mjs.map +1 -0
  38. package/fesm2022/i-cell-ids-angular-checkbox.mjs +350 -0
  39. package/fesm2022/i-cell-ids-angular-checkbox.mjs.map +1 -0
  40. package/fesm2022/i-cell-ids-angular-chip.mjs +166 -0
  41. package/fesm2022/i-cell-ids-angular-chip.mjs.map +1 -0
  42. package/fesm2022/i-cell-ids-angular-core.mjs +409 -0
  43. package/fesm2022/i-cell-ids-angular-core.mjs.map +1 -0
  44. package/fesm2022/i-cell-ids-angular-datepicker.mjs +860 -0
  45. package/fesm2022/i-cell-ids-angular-datepicker.mjs.map +1 -0
  46. package/fesm2022/i-cell-ids-angular-dialog.mjs +183 -0
  47. package/fesm2022/i-cell-ids-angular-dialog.mjs.map +1 -0
  48. package/fesm2022/i-cell-ids-angular-divider.mjs +76 -0
  49. package/fesm2022/i-cell-ids-angular-divider.mjs.map +1 -0
  50. package/fesm2022/i-cell-ids-angular-forms.mjs +972 -0
  51. package/fesm2022/i-cell-ids-angular-forms.mjs.map +1 -0
  52. package/fesm2022/i-cell-ids-angular-icon-button.mjs +120 -0
  53. package/fesm2022/i-cell-ids-angular-icon-button.mjs.map +1 -0
  54. package/fesm2022/i-cell-ids-angular-icon.mjs +158 -0
  55. package/fesm2022/i-cell-ids-angular-icon.mjs.map +1 -0
  56. package/fesm2022/i-cell-ids-angular-menu.mjs +154 -0
  57. package/fesm2022/i-cell-ids-angular-menu.mjs.map +1 -0
  58. package/fesm2022/i-cell-ids-angular-notification.mjs +167 -0
  59. package/fesm2022/i-cell-ids-angular-notification.mjs.map +1 -0
  60. package/fesm2022/i-cell-ids-angular-overlay-panel.mjs +72 -0
  61. package/fesm2022/i-cell-ids-angular-overlay-panel.mjs.map +1 -0
  62. package/fesm2022/i-cell-ids-angular-paginator.mjs +319 -0
  63. package/fesm2022/i-cell-ids-angular-paginator.mjs.map +1 -0
  64. package/fesm2022/i-cell-ids-angular-radio.mjs +312 -0
  65. package/fesm2022/i-cell-ids-angular-radio.mjs.map +1 -0
  66. package/fesm2022/i-cell-ids-angular-segmented-control-toggle.mjs +264 -0
  67. package/fesm2022/i-cell-ids-angular-segmented-control-toggle.mjs.map +1 -0
  68. package/fesm2022/i-cell-ids-angular-segmented-control.mjs +283 -0
  69. package/fesm2022/i-cell-ids-angular-segmented-control.mjs.map +1 -0
  70. package/fesm2022/i-cell-ids-angular-select.mjs +549 -0
  71. package/fesm2022/i-cell-ids-angular-select.mjs.map +1 -0
  72. package/fesm2022/i-cell-ids-angular-side-nav.mjs +375 -0
  73. package/fesm2022/i-cell-ids-angular-side-nav.mjs.map +1 -0
  74. package/fesm2022/i-cell-ids-angular-side-sheet.mjs +179 -0
  75. package/fesm2022/i-cell-ids-angular-side-sheet.mjs.map +1 -0
  76. package/fesm2022/i-cell-ids-angular-snackbar.mjs +440 -0
  77. package/fesm2022/i-cell-ids-angular-snackbar.mjs.map +1 -0
  78. package/fesm2022/i-cell-ids-angular-spinner.mjs +67 -0
  79. package/fesm2022/i-cell-ids-angular-spinner.mjs.map +1 -0
  80. package/fesm2022/i-cell-ids-angular-switch.mjs +181 -0
  81. package/fesm2022/i-cell-ids-angular-switch.mjs.map +1 -0
  82. package/fesm2022/i-cell-ids-angular-tab.mjs +142 -0
  83. package/fesm2022/i-cell-ids-angular-tab.mjs.map +1 -0
  84. package/fesm2022/i-cell-ids-angular-table.mjs +663 -0
  85. package/fesm2022/i-cell-ids-angular-table.mjs.map +1 -0
  86. package/fesm2022/i-cell-ids-angular-tag.mjs +116 -0
  87. package/fesm2022/i-cell-ids-angular-tag.mjs.map +1 -0
  88. package/fesm2022/i-cell-ids-angular-tooltip.mjs +586 -0
  89. package/fesm2022/i-cell-ids-angular-tooltip.mjs.map +1 -0
  90. package/fesm2022/i-cell-ids-angular.mjs +9 -0
  91. package/fesm2022/i-cell-ids-angular.mjs.map +1 -0
  92. package/forms/index.d.ts +470 -0
  93. package/forms/package.json +3 -0
  94. package/icon/index.d.ts +69 -0
  95. package/icon/package.json +3 -0
  96. package/icon-button/index.d.ts +68 -0
  97. package/icon-button/package.json +3 -0
  98. package/index.d.ts +2 -0
  99. package/menu/index.d.ts +68 -0
  100. package/menu/package.json +3 -0
  101. package/notification/index.d.ts +68 -0
  102. package/notification/package.json +3 -0
  103. package/overlay-panel/index.d.ts +41 -0
  104. package/overlay-panel/package.json +3 -0
  105. package/package.json +180 -0
  106. package/paginator/index.d.ts +122 -0
  107. package/paginator/package.json +3 -0
  108. package/radio/index.d.ts +95 -0
  109. package/radio/package.json +3 -0
  110. package/segmented-control/index.d.ts +98 -0
  111. package/segmented-control/package.json +3 -0
  112. package/segmented-control-toggle/index.d.ts +103 -0
  113. package/segmented-control-toggle/package.json +3 -0
  114. package/select/index.d.ts +103 -0
  115. package/select/package.json +3 -0
  116. package/side-nav/index.d.ts +107 -0
  117. package/side-nav/package.json +3 -0
  118. package/side-sheet/index.d.ts +84 -0
  119. package/side-sheet/package.json +3 -0
  120. package/snackbar/index.d.ts +149 -0
  121. package/snackbar/package.json +3 -0
  122. package/spinner/index.d.ts +41 -0
  123. package/spinner/package.json +3 -0
  124. package/switch/index.d.ts +89 -0
  125. package/switch/package.json +3 -0
  126. package/tab/index.d.ts +78 -0
  127. package/tab/package.json +3 -0
  128. package/table/index.d.ts +393 -0
  129. package/table/package.json +3 -0
  130. package/tag/index.d.ts +70 -0
  131. package/tag/package.json +3 -0
  132. package/tooltip/index.d.ts +96 -0
  133. package/tooltip/package.json +3 -0
@@ -0,0 +1,549 @@
1
+ import * as i0 from '@angular/core';
2
+ import { InjectionToken, Directive, inject, ElementRef, ChangeDetectorRef, input, signal, computed, viewChild, contentChildren, contentChild, effect, isDevMode, forwardRef, ChangeDetectionStrategy, ViewEncapsulation, Component } from '@angular/core';
3
+ import { SuccessStateMatcher, ErrorStateMatcher, IdsFormFieldControl, IdsFormFieldComponent, formFieldControlClass, IdsOptionComponent, IDS_OPTION_GROUP, _countGroupLabelsBeforeOption, _getOptionScrollPosition, IDS_FORM_FIELD_CONTROL, IDS_OPTION_PARENT_COMPONENT } from '@i-cell/ids-angular/forms';
4
+ import { LiveAnnouncer, ActiveDescendantKeyManager } from '@angular/cdk/a11y';
5
+ import { SelectionModel } from '@angular/cdk/collections';
6
+ import { hasModifierKey } from '@angular/cdk/keycodes';
7
+ import { CdkConnectedOverlay, CdkOverlayOrigin } from '@angular/cdk/overlay';
8
+ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
9
+ import { ValueChangeEvent, NG_VALUE_ACCESSOR } from '@angular/forms';
10
+ import { coerceNumberAttribute, createClassList } from '@i-cell/ids-angular/core';
11
+ import { IdsIconComponent } from '@i-cell/ids-angular/icon';
12
+ import { filter, first } from 'rxjs';
13
+
14
+ const IDS_SELECT_DEFAULT_CONFIG = new InjectionToken('IDS_SELECT_DEFAULT_CONFIG', {
15
+ providedIn: 'root',
16
+ factory: IDS_SELECT_DEFAULT_CONFIG_FACTORY,
17
+ });
18
+ function IDS_SELECT_DEFAULT_CONFIG_FACTORY() {
19
+ return {
20
+ errorStateMatcher: ErrorStateMatcher,
21
+ successStateMatcher: SuccessStateMatcher,
22
+ typeaheadDebounceInterval: 200,
23
+ };
24
+ }
25
+
26
+ class IdsSelectTriggerDirective {
27
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: IdsSelectTriggerDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
28
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.1.7", type: IdsSelectTriggerDirective, isStandalone: true, selector: "ids-select-trigger", ngImport: i0 }); }
29
+ }
30
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: IdsSelectTriggerDirective, decorators: [{
31
+ type: Directive,
32
+ args: [{
33
+ selector: 'ids-select-trigger',
34
+ standalone: true,
35
+ }]
36
+ }] });
37
+
38
+ const selectConnectedPositions = [
39
+ {
40
+ originX: 'start',
41
+ originY: 'bottom',
42
+ overlayX: 'start',
43
+ overlayY: 'top',
44
+ },
45
+ {
46
+ originX: 'end',
47
+ originY: 'bottom',
48
+ overlayX: 'end',
49
+ overlayY: 'top',
50
+ },
51
+ {
52
+ originX: 'start',
53
+ originY: 'top',
54
+ overlayX: 'start',
55
+ overlayY: 'bottom',
56
+ panelClass: 'ids-select-panel-above',
57
+ },
58
+ {
59
+ originX: 'end',
60
+ originY: 'top',
61
+ overlayX: 'end',
62
+ overlayY: 'bottom',
63
+ panelClass: 'ids-select-panel-above',
64
+ },
65
+ ];
66
+
67
+ const defaultConfig = IDS_SELECT_DEFAULT_CONFIG_FACTORY();
68
+ class IdsSelectComponent extends IdsFormFieldControl {
69
+ get _hostName() {
70
+ return 'select';
71
+ }
72
+ get _empty() {
73
+ return Boolean(this._selectionModel?.isEmpty());
74
+ }
75
+ get selected() {
76
+ return this.multiSelect() ? this._selectionModel?.selected : this._selectionModel?.selected?.[0];
77
+ }
78
+ get _triggerValue() {
79
+ if (this._empty) {
80
+ return '';
81
+ }
82
+ if (this.multiSelect()) {
83
+ const selectedOptions = this._selectionModel?.selected?.map((option) => option.viewValue());
84
+ return selectedOptions?.join(', ') || '';
85
+ }
86
+ return this._selectionModel?.selected?.[0].viewValue() || '';
87
+ }
88
+ constructor() {
89
+ super();
90
+ this._defaultConfig = this._getDefaultConfig(defaultConfig, IDS_SELECT_DEFAULT_CONFIG);
91
+ this._elementRef = inject(ElementRef);
92
+ this._changeDetectorRef = inject(ChangeDetectorRef);
93
+ this._liveAnnouncer = inject(LiveAnnouncer);
94
+ this._parentFormField = inject(IdsFormFieldComponent);
95
+ this._connectedPositions = selectConnectedPositions;
96
+ this._overlayWidth = 0;
97
+ this.multiSelect = input(false, ...(ngDevMode ? [{ debugName: "multiSelect" }] : []));
98
+ this.errorStateMatcher = input(inject(this._defaultConfig.errorStateMatcher), ...(ngDevMode ? [{ debugName: "errorStateMatcher" }] : []));
99
+ this.successStateMatcher = input(inject(this._defaultConfig.successStateMatcher), ...(ngDevMode ? [{ debugName: "successStateMatcher" }] : []));
100
+ this.ariaLabel = input('', ...(ngDevMode ? [{ debugName: "ariaLabel", alias: 'aria-label' }] : [{ alias: 'aria-label' }]));
101
+ this.ariaLabelledby = input('', ...(ngDevMode ? [{ debugName: "ariaLabelledby", alias: 'aria-labelledby' }] : [{ alias: 'aria-labelledby' }]));
102
+ this.valueCompareFn = input((o1, o2) => o1 === o2, ...(ngDevMode ? [{ debugName: "valueCompareFn" }] : []));
103
+ this.sortCompareFn = input(...(ngDevMode ? [undefined, { debugName: "sortCompareFn" }] : []));
104
+ this.tabIndex = input(0, ...(ngDevMode ? [{ debugName: "tabIndex", transform: coerceNumberAttribute }] : [{ transform: coerceNumberAttribute }]));
105
+ this.typeaheadDebounceInterval = input(this._defaultConfig.typeaheadDebounceInterval, ...(ngDevMode ? [{ debugName: "typeaheadDebounceInterval", transform: coerceNumberAttribute }] : [{ transform: coerceNumberAttribute }]));
106
+ this.isPanelOpen = signal(false, ...(ngDevMode ? [{ debugName: "isPanelOpen" }] : []));
107
+ this.parentSize = computed(() => this._parentFormField.parentOrSelfSize(), ...(ngDevMode ? [{ debugName: "parentSize" }] : []));
108
+ this.parentVariant = computed(() => this._parentFormField.parentOrSelfVariant(), ...(ngDevMode ? [{ debugName: "parentVariant" }] : []));
109
+ this._focused = signal(false, ...(ngDevMode ? [{ debugName: "_focused" }] : []));
110
+ this._canOpen = computed(() => !this.isPanelOpen() && !this.disabled() && !this.readonly() && this.options().length > 0, ...(ngDevMode ? [{ debugName: "_canOpen" }] : []));
111
+ this._hostClasses = computed(() => this._getHostClasses([
112
+ this.parentSize(),
113
+ this.parentVariant(),
114
+ this.disabled() ? 'disabled' : null,
115
+ this.readonly() ? 'readonly' : null,
116
+ ], [formFieldControlClass]), ...(ngDevMode ? [{ debugName: "_hostClasses" }] : []));
117
+ this._panelClasses = computed(() => createClassList(`${this._hostClassName}-panel`, [
118
+ this.parentSize(),
119
+ this.parentVariant(),
120
+ ]), ...(ngDevMode ? [{ debugName: "_panelClasses" }] : []));
121
+ this._panel = viewChild('panel', ...(ngDevMode ? [{ debugName: "_panel" }] : []));
122
+ this._overlayDir = viewChild(CdkConnectedOverlay, ...(ngDevMode ? [{ debugName: "_overlayDir" }] : []));
123
+ this.options = contentChildren(IdsOptionComponent, ...(ngDevMode ? [{ debugName: "options", descendants: true }] : [{ descendants: true }]));
124
+ this.optionGroups = contentChildren(IDS_OPTION_GROUP, ...(ngDevMode ? [{ debugName: "optionGroups", descendants: true }] : [{ descendants: true }]));
125
+ this._customTrigger = contentChild(IdsSelectTriggerDirective, ...(ngDevMode ? [{ debugName: "_customTrigger" }] : []));
126
+ this._onChange = () => { };
127
+ this._onTouched = () => { };
128
+ this._skipPredicate = (option) => {
129
+ if (this.isPanelOpen()) {
130
+ return false;
131
+ }
132
+ return option.disabledInput();
133
+ };
134
+ this.onContainerClick = () => {
135
+ if (!this._focused() && !this.readonly() && !this.disabled()) {
136
+ this.focus();
137
+ this.open();
138
+ }
139
+ };
140
+ effect(() => {
141
+ this._keyManager?.withTypeAhead(this.typeaheadDebounceInterval());
142
+ });
143
+ }
144
+ ngOnInit() {
145
+ if (!this._parentFormField) {
146
+ throw this._createHostError('Select must be in a form field');
147
+ }
148
+ this._selectionModel = new SelectionModel(this.multiSelect(), undefined, false, this.valueCompareFn());
149
+ queueMicrotask(() => {
150
+ const control = this.ngControl()?.control;
151
+ if (control) {
152
+ control.events
153
+ .pipe(filter((event) => event instanceof ValueChangeEvent), takeUntilDestroyed(this._destroyRef))
154
+ .subscribe(() => {
155
+ this._changeDetectorRef.markForCheck();
156
+ });
157
+ }
158
+ });
159
+ this._initErrorStateTracker();
160
+ }
161
+ ngAfterContentInit() {
162
+ this._initKeyManager();
163
+ this._selectionModel?.select(...this.options().filter((item) => item.selected()));
164
+ this._subscribeOptionChanges();
165
+ }
166
+ ngAfterViewInit() {
167
+ queueMicrotask(() => {
168
+ const controlDir = this.ngControl();
169
+ if (controlDir?.control) {
170
+ controlDir.control.events.pipe(takeUntilDestroyed(this._destroyRef)).subscribe(() => this.updateErrorAndSuccessState());
171
+ }
172
+ });
173
+ }
174
+ updateErrorAndSuccessState() {
175
+ this._errorStateTracker?.updateErrorState();
176
+ this._successStateTracker?.updateSuccessState();
177
+ }
178
+ ngOnDestroy() {
179
+ this._keyManager?.destroy();
180
+ }
181
+ _initKeyManager() {
182
+ this._keyManager = new ActiveDescendantKeyManager(this.options())
183
+ .withTypeAhead(this.typeaheadDebounceInterval())
184
+ .withVerticalOrientation()
185
+ .withHorizontalOrientation('ltr')
186
+ .withHomeAndEnd()
187
+ .withPageUpDown()
188
+ .withAllowedModifierKeys(['shiftKey'])
189
+ .skipPredicate(this._skipPredicate);
190
+ this._keyManager.tabOut.subscribe(() => {
191
+ if (this.isPanelOpen()) {
192
+ if (!this.multiSelect() && this._keyManager?.activeItem) {
193
+ this._keyManager.activeItem.selectViaInteraction();
194
+ }
195
+ this.focus();
196
+ this.close();
197
+ }
198
+ });
199
+ this._keyManager.change.subscribe(() => {
200
+ if (this.isPanelOpen() && this._panel()) {
201
+ this._scrollOptionIntoView(this._keyManager?.activeItemIndex || 0);
202
+ }
203
+ });
204
+ }
205
+ _subscribeOptionChanges() {
206
+ this.options().forEach((option) => {
207
+ option.onSelectionChange.subscribe((change) => {
208
+ this._handleOptionChange(change);
209
+ });
210
+ });
211
+ }
212
+ _handleOptionChange(change) {
213
+ const { source, selected, isUserInput } = change;
214
+ if (!this.multiSelect()) {
215
+ this._clearSelection();
216
+ }
217
+ source.selected.set(selected);
218
+ if (isUserInput) {
219
+ this._keyManager?.setActiveItem(source);
220
+ }
221
+ if (isUserInput && !this.multiSelect() && this.isPanelOpen()) {
222
+ this.close();
223
+ this.focus();
224
+ }
225
+ if (this.multiSelect()) {
226
+ this._sortValues();
227
+ if (isUserInput) {
228
+ this.focus();
229
+ }
230
+ }
231
+ if (selected) {
232
+ this._selectionModel?.select(source);
233
+ }
234
+ else {
235
+ this._selectionModel?.deselect(source);
236
+ }
237
+ this._handleChange();
238
+ this._onTouched();
239
+ }
240
+ _handleKeydown(event) {
241
+ if (!this.disabled() && !this.readonly()) {
242
+ this.isPanelOpen() ? this._handleOpenedPanelKeydown(event) : this._handleClosedPanelKeydown(event);
243
+ }
244
+ }
245
+ _handleClosedPanelKeydown(event) {
246
+ const manager = this._keyManager;
247
+ const key = event.key;
248
+ const isArrowKey = key === 'ArrowDown' ||
249
+ key === 'ArrowUp' ||
250
+ key === 'ArrowLeft' ||
251
+ key === 'ArrowRight';
252
+ const isOpenKey = key === 'Enter' || key === ' ';
253
+ if ((!manager?.isTyping() && isOpenKey && !hasModifierKey(event)) || isArrowKey) {
254
+ event.preventDefault();
255
+ this.open();
256
+ }
257
+ else if (!this.multiSelect()) {
258
+ const previouslySelectedOption = this.selected;
259
+ manager?.onKeydown(event);
260
+ const selectedOption = this.selected;
261
+ if (selectedOption?.viewValue() && previouslySelectedOption !== selectedOption) {
262
+ // eslint-disable-next-line no-magic-numbers
263
+ this._liveAnnouncer.announce(selectedOption.viewValue(), 10000);
264
+ }
265
+ }
266
+ }
267
+ _handleOpenedPanelKeydown(event) {
268
+ const manager = this._keyManager;
269
+ const key = event.key;
270
+ const isArrowKey = key === 'ArrowDown' || key === 'ArrowUp';
271
+ const isTyping = manager?.isTyping();
272
+ if (isArrowKey && event.altKey) {
273
+ event.preventDefault();
274
+ this.close();
275
+ }
276
+ else if (!isTyping &&
277
+ (key === 'Enter' || key === ' ') &&
278
+ manager?.activeItem &&
279
+ !hasModifierKey(event)) {
280
+ event.preventDefault();
281
+ manager.activeItem.selectViaInteraction();
282
+ }
283
+ else if (!isTyping && this.multiSelect() && key === 'a' && event.ctrlKey) {
284
+ event.preventDefault();
285
+ const hasDeselectedOptions = this.options().some((opt) => !opt.disabled && !opt.selected());
286
+ this.options().forEach((option) => {
287
+ if (!option.disabled) {
288
+ hasDeselectedOptions ? option.select() : option.deselect();
289
+ }
290
+ });
291
+ }
292
+ else {
293
+ const previouslyFocusedIndex = manager?.activeItemIndex;
294
+ manager?.onKeydown(event);
295
+ if (this.multiSelect() &&
296
+ isArrowKey &&
297
+ event.shiftKey &&
298
+ manager?.activeItem &&
299
+ manager?.activeItemIndex !== previouslyFocusedIndex) {
300
+ manager?.activeItem.selectViaInteraction();
301
+ }
302
+ }
303
+ }
304
+ _positioningSettled() {
305
+ this._scrollOptionIntoView(this._keyManager?.activeItemIndex || 0);
306
+ }
307
+ _scrollOptionIntoView(index) {
308
+ const option = this.options()[index];
309
+ if (option) {
310
+ const panel = this._panel().nativeElement;
311
+ const labelCount = _countGroupLabelsBeforeOption(index, this.options(), this.optionGroups());
312
+ const element = option.getHostElement();
313
+ if (index === 0 && labelCount === 1) {
314
+ panel.scrollTop = 0;
315
+ }
316
+ else {
317
+ panel.scrollTop = _getOptionScrollPosition(element.offsetTop, element.offsetHeight, panel.scrollTop, panel.offsetHeight);
318
+ }
319
+ }
320
+ }
321
+ _sortValues() {
322
+ if (this.multiSelect()) {
323
+ const options = this.options();
324
+ const sortComparator = this.sortCompareFn();
325
+ this._selectionModel?.sort((a, b) => (sortComparator
326
+ ? sortComparator(a, b, options)
327
+ : options.indexOf(a) - options.indexOf(b)));
328
+ }
329
+ }
330
+ _getOverlayWidth(preferredOrigin) {
331
+ const refToMeasure = preferredOrigin instanceof CdkOverlayOrigin
332
+ ? preferredOrigin.elementRef
333
+ : preferredOrigin || this._elementRef;
334
+ return refToMeasure.nativeElement.getBoundingClientRect().width;
335
+ }
336
+ _panelAttached() {
337
+ this._overlayDir()?.positionChange.pipe(first()).subscribe(() => {
338
+ this._changeDetectorRef.detectChanges();
339
+ this._positioningSettled();
340
+ });
341
+ }
342
+ toggle() {
343
+ this.isPanelOpen() ? this.close() : this.open();
344
+ }
345
+ open() {
346
+ if (!this._canOpen()) {
347
+ return;
348
+ }
349
+ if (this._parentFormField) {
350
+ this._preferredOverlayOrigin = this._parentFormField?.getConnectedOverlayOrigin();
351
+ }
352
+ this._overlayWidth = this._getOverlayWidth(this._preferredOverlayOrigin);
353
+ this.isPanelOpen.set(true);
354
+ this._keyManager?.withHorizontalOrientation(null);
355
+ this._highlightCorrectOption();
356
+ this._changeDetectorRef.markForCheck();
357
+ }
358
+ close() {
359
+ if (this.isPanelOpen()) {
360
+ this.isPanelOpen.set(false);
361
+ this._keyManager?.withHorizontalOrientation('ltr');
362
+ this._changeDetectorRef.markForCheck();
363
+ this._onTouched();
364
+ }
365
+ }
366
+ // #region ControlValueAccessor implementation
367
+ writeValue(value) {
368
+ this._setSelectionByValue(value);
369
+ }
370
+ registerOnChange(fn) {
371
+ this._onChange = fn;
372
+ }
373
+ registerOnTouched(fn) {
374
+ this._onTouched = fn;
375
+ }
376
+ setDisabledState(isDisabled) {
377
+ this._disabled.set(isDisabled);
378
+ this._changeDetectorRef.markForCheck();
379
+ }
380
+ // #endregion
381
+ _setSelectionByValue(value) {
382
+ this.options().forEach((option) => {
383
+ option.setInactiveStyles();
384
+ option.selected.set(false);
385
+ });
386
+ this._selectionModel?.clear();
387
+ this._rawValue = value;
388
+ if (this.options().length === 0) {
389
+ return;
390
+ }
391
+ if (this.multiSelect() && value) {
392
+ if (!Array.isArray(value)) {
393
+ throw this._createHostError('value must be an array in multiple-selection mode');
394
+ }
395
+ value.forEach((currentValue) => this._selectValue(currentValue));
396
+ this._sortValues();
397
+ }
398
+ else {
399
+ const correspondingOption = this._selectValue(value);
400
+ if (correspondingOption) {
401
+ this._keyManager?.updateActiveItem(correspondingOption);
402
+ }
403
+ else if (!this.isPanelOpen()) {
404
+ this._keyManager?.updateActiveItem(-1);
405
+ }
406
+ }
407
+ }
408
+ _selectValue(value) {
409
+ const valueCompareFn = this.valueCompareFn();
410
+ const correspondingOption = this.options().find((option) => {
411
+ if (this._selectionModel?.isSelected(option)) {
412
+ return false;
413
+ }
414
+ try {
415
+ return valueCompareFn?.(option.value(), value);
416
+ }
417
+ catch (error) {
418
+ if (isDevMode()) {
419
+ console.warn(error);
420
+ }
421
+ return false;
422
+ }
423
+ });
424
+ if (correspondingOption) {
425
+ correspondingOption.selected.set(true);
426
+ this._selectionModel?.select(correspondingOption);
427
+ }
428
+ return correspondingOption;
429
+ }
430
+ _clearSelection() {
431
+ this._selectionModel?.clear();
432
+ this.options().forEach((option) => {
433
+ option.selected.set(false);
434
+ });
435
+ }
436
+ _handleChange() {
437
+ const selectionModelValues = this._selectionModel?.selected?.map((item) => item.value());
438
+ if (this.multiSelect()) {
439
+ this._onChange(selectionModelValues);
440
+ }
441
+ else {
442
+ this._onChange(selectionModelValues?.[0]);
443
+ }
444
+ this._changeDetectorRef.markForCheck();
445
+ }
446
+ _highlightCorrectOption() {
447
+ if (this._keyManager) {
448
+ if (this._empty) {
449
+ let firstEnabledOptionIndex = -1;
450
+ for (let index = 0; index < this.options().length; index++) {
451
+ const option = this.options()[index];
452
+ if (!option.disabled) {
453
+ firstEnabledOptionIndex = index;
454
+ break;
455
+ }
456
+ }
457
+ this._keyManager.setActiveItem(firstEnabledOptionIndex);
458
+ }
459
+ else {
460
+ if (this._selectionModel) {
461
+ this._keyManager.setActiveItem(this._selectionModel.selected[0]);
462
+ }
463
+ }
464
+ }
465
+ }
466
+ isOptionPreSelectedByValue(optionValue) {
467
+ if (this._rawValue === undefined) {
468
+ return false;
469
+ }
470
+ if (this.multiSelect() && Array.isArray(this._rawValue)) {
471
+ return this._rawValue.some((value) => optionValue != null && value === optionValue);
472
+ }
473
+ return optionValue === this._rawValue;
474
+ }
475
+ _onFocus() {
476
+ if (!this.disabled()) {
477
+ this._focused.set(true);
478
+ }
479
+ }
480
+ _onBlur() {
481
+ this._focused.set(false);
482
+ this._keyManager?.cancelTypeahead();
483
+ if (!this.disabled() && !this.isPanelOpen()) {
484
+ this._onTouched();
485
+ this._changeDetectorRef.markForCheck();
486
+ }
487
+ }
488
+ _getAriaActiveDescendant() {
489
+ if (this.isPanelOpen() && this._keyManager?.activeItem) {
490
+ return this._keyManager.activeItem.id();
491
+ }
492
+ return null;
493
+ }
494
+ focus(options) {
495
+ this._elementRef.nativeElement.focus(options);
496
+ }
497
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: IdsSelectComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
498
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.7", type: IdsSelectComponent, isStandalone: true, selector: "ids-select[ngModel]:not([formControl]):not([formControlName]),\n ids-select[formControl]:not([ngModel]):not([formControlName]),\n ids-select[formControlName]:not([ngModel]):not([formControl])", inputs: { multiSelect: { classPropertyName: "multiSelect", publicName: "multiSelect", isSignal: true, isRequired: false, transformFunction: null }, errorStateMatcher: { classPropertyName: "errorStateMatcher", publicName: "errorStateMatcher", isSignal: true, isRequired: false, transformFunction: null }, successStateMatcher: { classPropertyName: "successStateMatcher", publicName: "successStateMatcher", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null }, ariaLabelledby: { classPropertyName: "ariaLabelledby", publicName: "aria-labelledby", isSignal: true, isRequired: false, transformFunction: null }, valueCompareFn: { classPropertyName: "valueCompareFn", publicName: "valueCompareFn", isSignal: true, isRequired: false, transformFunction: null }, sortCompareFn: { classPropertyName: "sortCompareFn", publicName: "sortCompareFn", isSignal: true, isRequired: false, transformFunction: null }, tabIndex: { classPropertyName: "tabIndex", publicName: "tabIndex", isSignal: true, isRequired: false, transformFunction: null }, typeaheadDebounceInterval: { classPropertyName: "typeaheadDebounceInterval", publicName: "typeaheadDebounceInterval", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "select", "aria-autocomplete": "none", "aria-haspopup": "listbox" }, listeners: { "keydown": "_handleKeydown($event)", "focus": "focus()", "blur": "_onBlur()" }, properties: { "attr.tabindex": "disabled() ? -1 : tabIndex()", "attr.aria-controls": "isPanelOpen() ? id() + \"-panel\" : null", "attr.aria-owns": "isPanelOpen() ? id() + \"-panel\" : null", "attr.aria-expanded": "isPanelOpen()", "attr.aria-label": "ariaLabel() || null", "attr.aria-labelledby": "ariaLabelledby() || null", "attr.aria-required": "required().toString()", "attr.aria-disabled": "disabled().toString()", "attr.aria-invalid": "hasErrorState()", "attr.aria-activedescendant": "_getAriaActiveDescendant()" } }, providers: [
499
+ { provide: IDS_FORM_FIELD_CONTROL, useExisting: IdsSelectComponent },
500
+ { provide: IDS_OPTION_PARENT_COMPONENT, useExisting: IdsSelectComponent },
501
+ {
502
+ provide: NG_VALUE_ACCESSOR,
503
+ useExisting: forwardRef(() => IdsSelectComponent),
504
+ multi: true,
505
+ },
506
+ ], queries: [{ propertyName: "options", predicate: IdsOptionComponent, descendants: true, isSignal: true }, { propertyName: "optionGroups", predicate: IDS_OPTION_GROUP, descendants: true, isSignal: true }, { propertyName: "_customTrigger", first: true, predicate: IdsSelectTriggerDirective, descendants: true, isSignal: true }], viewQueries: [{ propertyName: "_panel", first: true, predicate: ["panel"], descendants: true, isSignal: true }, { propertyName: "_overlayDir", first: true, predicate: CdkConnectedOverlay, descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0, template: "<div #trigger #fallbackOverlayOrigin=\"cdkOverlayOrigin\" cdk-overlay-origin class=\"ids-select__trigger\" (click)=\"open()\">\n <div class=\"ids-select__value\">\n @if (_empty) {\n <span class=\"ids-select__placeholder\">{{ placeholder() }}</span>\n } @else {\n <span class=\"ids-select__value-text\">\n @if (_customTrigger()) {\n <ng-content select=\"ids-select-trigger\" />\n } @else {\n {{ _triggerValue }}\n }\n </span>\n }\n </div>\n\n <div class=\"ids-select__arrow\">\n <ids-icon fontIcon=\"chevron-down\" />\n </div>\n</div>\n<ng-template\n cdk-connected-overlay\n cdkConnectedOverlayLockPosition\n [cdkConnectedOverlayOrigin]=\"_preferredOverlayOrigin || fallbackOverlayOrigin\"\n [cdkConnectedOverlayOpen]=\"isPanelOpen()\"\n [cdkConnectedOverlayPositions]=\"_connectedPositions\"\n [cdkConnectedOverlayWidth]=\"_overlayWidth\"\n (overlayOutsideClick)=\"close()\"\n (attach)=\"_panelAttached()\"\n (detach)=\"close()\"\n>\n <div\n #panel\n role=\"listbox\"\n tabindex=\"-1\"\n [attr.id]=\"id() + '-panel'\"\n [attr.aria-multiselectable]=\"multiSelect()\"\n [attr.aria-label]=\"ariaLabel() || null\"\n [attr.aria-labelledby]=\"ariaLabelledby()\"\n [class]=\"_panelClasses()\"\n (keydown)=\"_handleKeydown($event)\"\n >\n <ng-content />\n </div>\n</ng-template>\n", dependencies: [{ kind: "directive", type: CdkOverlayOrigin, selector: "[cdk-overlay-origin], [overlay-origin], [cdkOverlayOrigin]", exportAs: ["cdkOverlayOrigin"] }, { kind: "directive", type: CdkConnectedOverlay, selector: "[cdk-connected-overlay], [connected-overlay], [cdkConnectedOverlay]", inputs: ["cdkConnectedOverlayOrigin", "cdkConnectedOverlayPositions", "cdkConnectedOverlayPositionStrategy", "cdkConnectedOverlayOffsetX", "cdkConnectedOverlayOffsetY", "cdkConnectedOverlayWidth", "cdkConnectedOverlayHeight", "cdkConnectedOverlayMinWidth", "cdkConnectedOverlayMinHeight", "cdkConnectedOverlayBackdropClass", "cdkConnectedOverlayPanelClass", "cdkConnectedOverlayViewportMargin", "cdkConnectedOverlayScrollStrategy", "cdkConnectedOverlayOpen", "cdkConnectedOverlayDisableClose", "cdkConnectedOverlayTransformOriginOn", "cdkConnectedOverlayHasBackdrop", "cdkConnectedOverlayLockPosition", "cdkConnectedOverlayFlexibleDimensions", "cdkConnectedOverlayGrowAfterOpen", "cdkConnectedOverlayPush", "cdkConnectedOverlayDisposeOnNavigation"], outputs: ["backdropClick", "positionChange", "attach", "detach", "overlayKeydown", "overlayOutsideClick"], exportAs: ["cdkConnectedOverlay"] }, { kind: "component", type: IdsIconComponent, selector: "ids-icon", inputs: ["size", "sizeCollection", "variant", "fontIcon", "svgIcon", "aria-hidden"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
507
+ }
508
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: IdsSelectComponent, decorators: [{
509
+ type: Component,
510
+ args: [{ selector: `ids-select[ngModel]:not([formControl]):not([formControlName]),
511
+ ids-select[formControl]:not([ngModel]):not([formControlName]),
512
+ ids-select[formControlName]:not([ngModel]):not([formControl])`, imports: [
513
+ CdkOverlayOrigin,
514
+ CdkConnectedOverlay,
515
+ IdsIconComponent,
516
+ ], encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, providers: [
517
+ { provide: IDS_FORM_FIELD_CONTROL, useExisting: IdsSelectComponent },
518
+ { provide: IDS_OPTION_PARENT_COMPONENT, useExisting: IdsSelectComponent },
519
+ {
520
+ provide: NG_VALUE_ACCESSOR,
521
+ useExisting: forwardRef(() => IdsSelectComponent),
522
+ multi: true,
523
+ },
524
+ ], host: {
525
+ 'role': 'select',
526
+ 'aria-autocomplete': 'none',
527
+ 'aria-haspopup': 'listbox',
528
+ '[attr.tabindex]': 'disabled() ? -1 : tabIndex()',
529
+ '[attr.aria-controls]': 'isPanelOpen() ? id() + "-panel" : null',
530
+ '[attr.aria-owns]': 'isPanelOpen() ? id() + "-panel" : null',
531
+ '[attr.aria-expanded]': 'isPanelOpen()',
532
+ '[attr.aria-label]': 'ariaLabel() || null',
533
+ '[attr.aria-labelledby]': 'ariaLabelledby() || null',
534
+ '[attr.aria-required]': 'required().toString()',
535
+ '[attr.aria-disabled]': 'disabled().toString()',
536
+ '[attr.aria-invalid]': 'hasErrorState()',
537
+ '[attr.aria-activedescendant]': '_getAriaActiveDescendant()',
538
+ '(keydown)': '_handleKeydown($event)',
539
+ '(focus)': 'focus()',
540
+ '(blur)': '_onBlur()',
541
+ }, template: "<div #trigger #fallbackOverlayOrigin=\"cdkOverlayOrigin\" cdk-overlay-origin class=\"ids-select__trigger\" (click)=\"open()\">\n <div class=\"ids-select__value\">\n @if (_empty) {\n <span class=\"ids-select__placeholder\">{{ placeholder() }}</span>\n } @else {\n <span class=\"ids-select__value-text\">\n @if (_customTrigger()) {\n <ng-content select=\"ids-select-trigger\" />\n } @else {\n {{ _triggerValue }}\n }\n </span>\n }\n </div>\n\n <div class=\"ids-select__arrow\">\n <ids-icon fontIcon=\"chevron-down\" />\n </div>\n</div>\n<ng-template\n cdk-connected-overlay\n cdkConnectedOverlayLockPosition\n [cdkConnectedOverlayOrigin]=\"_preferredOverlayOrigin || fallbackOverlayOrigin\"\n [cdkConnectedOverlayOpen]=\"isPanelOpen()\"\n [cdkConnectedOverlayPositions]=\"_connectedPositions\"\n [cdkConnectedOverlayWidth]=\"_overlayWidth\"\n (overlayOutsideClick)=\"close()\"\n (attach)=\"_panelAttached()\"\n (detach)=\"close()\"\n>\n <div\n #panel\n role=\"listbox\"\n tabindex=\"-1\"\n [attr.id]=\"id() + '-panel'\"\n [attr.aria-multiselectable]=\"multiSelect()\"\n [attr.aria-label]=\"ariaLabel() || null\"\n [attr.aria-labelledby]=\"ariaLabelledby()\"\n [class]=\"_panelClasses()\"\n (keydown)=\"_handleKeydown($event)\"\n >\n <ng-content />\n </div>\n</ng-template>\n" }]
542
+ }], ctorParameters: () => [] });
543
+
544
+ /**
545
+ * Generated bundle index. Do not edit.
546
+ */
547
+
548
+ export { IDS_SELECT_DEFAULT_CONFIG, IDS_SELECT_DEFAULT_CONFIG_FACTORY, IdsSelectComponent, IdsSelectTriggerDirective };
549
+ //# sourceMappingURL=i-cell-ids-angular-select.mjs.map