@cute-widgets/base 20.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.
Files changed (183) hide show
  1. package/CHANGELOG.md +1 -0
  2. package/LICENSE.md +191 -0
  3. package/README.md +190 -0
  4. package/abstract/index.d.ts +327 -0
  5. package/alert/index.d.ts +68 -0
  6. package/autocomplete/index.d.ts +442 -0
  7. package/badge/index.d.ts +26 -0
  8. package/bottom-sheet/index.d.ts +231 -0
  9. package/button/index.d.ts +182 -0
  10. package/button-toggle/index.d.ts +225 -0
  11. package/card/index.d.ts +163 -0
  12. package/checkbox/index.d.ts +174 -0
  13. package/chips/index.d.ts +963 -0
  14. package/collapse/index.d.ts +97 -0
  15. package/core/animation/index.d.ts +43 -0
  16. package/core/datetime/index.d.ts +404 -0
  17. package/core/directives/index.d.ts +168 -0
  18. package/core/error/index.d.ts +74 -0
  19. package/core/index.d.ts +1039 -0
  20. package/core/interfaces/index.d.ts +114 -0
  21. package/core/layout/index.d.ts +53 -0
  22. package/core/line/index.d.ts +37 -0
  23. package/core/nav/index.d.ts +321 -0
  24. package/core/observers/index.d.ts +124 -0
  25. package/core/option/index.d.ts +185 -0
  26. package/core/pipes/index.d.ts +53 -0
  27. package/core/ripple/index.d.ts +66 -0
  28. package/core/testing/index.d.ts +154 -0
  29. package/core/theming/index.d.ts +118 -0
  30. package/core/types/index.d.ts +53 -0
  31. package/core/utils/index.d.ts +129 -0
  32. package/cute-widgets-base-20.0.1.tgz +0 -0
  33. package/datepicker/index.d.ts +1817 -0
  34. package/dialog/index.d.ts +484 -0
  35. package/divider/index.d.ts +24 -0
  36. package/expansion/README.md +8 -0
  37. package/expansion/index.d.ts +308 -0
  38. package/fesm2022/cute-widgets-base-abstract.mjs +547 -0
  39. package/fesm2022/cute-widgets-base-abstract.mjs.map +1 -0
  40. package/fesm2022/cute-widgets-base-alert.mjs +198 -0
  41. package/fesm2022/cute-widgets-base-alert.mjs.map +1 -0
  42. package/fesm2022/cute-widgets-base-autocomplete.mjs +1217 -0
  43. package/fesm2022/cute-widgets-base-autocomplete.mjs.map +1 -0
  44. package/fesm2022/cute-widgets-base-badge.mjs +75 -0
  45. package/fesm2022/cute-widgets-base-badge.mjs.map +1 -0
  46. package/fesm2022/cute-widgets-base-bottom-sheet.mjs +416 -0
  47. package/fesm2022/cute-widgets-base-bottom-sheet.mjs.map +1 -0
  48. package/fesm2022/cute-widgets-base-button-toggle.mjs +640 -0
  49. package/fesm2022/cute-widgets-base-button-toggle.mjs.map +1 -0
  50. package/fesm2022/cute-widgets-base-button.mjs +546 -0
  51. package/fesm2022/cute-widgets-base-button.mjs.map +1 -0
  52. package/fesm2022/cute-widgets-base-card.mjs +471 -0
  53. package/fesm2022/cute-widgets-base-card.mjs.map +1 -0
  54. package/fesm2022/cute-widgets-base-checkbox.mjs +390 -0
  55. package/fesm2022/cute-widgets-base-checkbox.mjs.map +1 -0
  56. package/fesm2022/cute-widgets-base-chips.mjs +2360 -0
  57. package/fesm2022/cute-widgets-base-chips.mjs.map +1 -0
  58. package/fesm2022/cute-widgets-base-collapse.mjs +259 -0
  59. package/fesm2022/cute-widgets-base-collapse.mjs.map +1 -0
  60. package/fesm2022/cute-widgets-base-core-animation.mjs +53 -0
  61. package/fesm2022/cute-widgets-base-core-animation.mjs.map +1 -0
  62. package/fesm2022/cute-widgets-base-core-datetime.mjs +568 -0
  63. package/fesm2022/cute-widgets-base-core-datetime.mjs.map +1 -0
  64. package/fesm2022/cute-widgets-base-core-directives.mjs +404 -0
  65. package/fesm2022/cute-widgets-base-core-directives.mjs.map +1 -0
  66. package/fesm2022/cute-widgets-base-core-error.mjs +105 -0
  67. package/fesm2022/cute-widgets-base-core-error.mjs.map +1 -0
  68. package/fesm2022/cute-widgets-base-core-interfaces.mjs +22 -0
  69. package/fesm2022/cute-widgets-base-core-interfaces.mjs.map +1 -0
  70. package/fesm2022/cute-widgets-base-core-layout.mjs +74 -0
  71. package/fesm2022/cute-widgets-base-core-layout.mjs.map +1 -0
  72. package/fesm2022/cute-widgets-base-core-line.mjs +87 -0
  73. package/fesm2022/cute-widgets-base-core-line.mjs.map +1 -0
  74. package/fesm2022/cute-widgets-base-core-nav.mjs +863 -0
  75. package/fesm2022/cute-widgets-base-core-nav.mjs.map +1 -0
  76. package/fesm2022/cute-widgets-base-core-observers.mjs +304 -0
  77. package/fesm2022/cute-widgets-base-core-observers.mjs.map +1 -0
  78. package/fesm2022/cute-widgets-base-core-option.mjs +373 -0
  79. package/fesm2022/cute-widgets-base-core-option.mjs.map +1 -0
  80. package/fesm2022/cute-widgets-base-core-pipes.mjs +97 -0
  81. package/fesm2022/cute-widgets-base-core-pipes.mjs.map +1 -0
  82. package/fesm2022/cute-widgets-base-core-ripple.mjs +172 -0
  83. package/fesm2022/cute-widgets-base-core-ripple.mjs.map +1 -0
  84. package/fesm2022/cute-widgets-base-core-testing.mjs +210 -0
  85. package/fesm2022/cute-widgets-base-core-testing.mjs.map +1 -0
  86. package/fesm2022/cute-widgets-base-core-theming.mjs +314 -0
  87. package/fesm2022/cute-widgets-base-core-theming.mjs.map +1 -0
  88. package/fesm2022/cute-widgets-base-core-types.mjs +22 -0
  89. package/fesm2022/cute-widgets-base-core-types.mjs.map +1 -0
  90. package/fesm2022/cute-widgets-base-core-utils.mjs +257 -0
  91. package/fesm2022/cute-widgets-base-core-utils.mjs.map +1 -0
  92. package/fesm2022/cute-widgets-base-core.mjs +1600 -0
  93. package/fesm2022/cute-widgets-base-core.mjs.map +1 -0
  94. package/fesm2022/cute-widgets-base-datepicker.mjs +4827 -0
  95. package/fesm2022/cute-widgets-base-datepicker.mjs.map +1 -0
  96. package/fesm2022/cute-widgets-base-dialog.mjs +1046 -0
  97. package/fesm2022/cute-widgets-base-dialog.mjs.map +1 -0
  98. package/fesm2022/cute-widgets-base-divider.mjs +86 -0
  99. package/fesm2022/cute-widgets-base-divider.mjs.map +1 -0
  100. package/fesm2022/cute-widgets-base-expansion.mjs +623 -0
  101. package/fesm2022/cute-widgets-base-expansion.mjs.map +1 -0
  102. package/fesm2022/cute-widgets-base-form-field.mjs +969 -0
  103. package/fesm2022/cute-widgets-base-form-field.mjs.map +1 -0
  104. package/fesm2022/cute-widgets-base-grid-list.mjs +715 -0
  105. package/fesm2022/cute-widgets-base-grid-list.mjs.map +1 -0
  106. package/fesm2022/cute-widgets-base-icon.mjs +1105 -0
  107. package/fesm2022/cute-widgets-base-icon.mjs.map +1 -0
  108. package/fesm2022/cute-widgets-base-input.mjs +726 -0
  109. package/fesm2022/cute-widgets-base-input.mjs.map +1 -0
  110. package/fesm2022/cute-widgets-base-layout-container.mjs +95 -0
  111. package/fesm2022/cute-widgets-base-layout-container.mjs.map +1 -0
  112. package/fesm2022/cute-widgets-base-layout-stack.mjs +166 -0
  113. package/fesm2022/cute-widgets-base-layout-stack.mjs.map +1 -0
  114. package/fesm2022/cute-widgets-base-layout.mjs +250 -0
  115. package/fesm2022/cute-widgets-base-layout.mjs.map +1 -0
  116. package/fesm2022/cute-widgets-base-list.mjs +1557 -0
  117. package/fesm2022/cute-widgets-base-list.mjs.map +1 -0
  118. package/fesm2022/cute-widgets-base-menu.mjs +1283 -0
  119. package/fesm2022/cute-widgets-base-menu.mjs.map +1 -0
  120. package/fesm2022/cute-widgets-base-navbar.mjs +359 -0
  121. package/fesm2022/cute-widgets-base-navbar.mjs.map +1 -0
  122. package/fesm2022/cute-widgets-base-paginator.mjs +485 -0
  123. package/fesm2022/cute-widgets-base-paginator.mjs.map +1 -0
  124. package/fesm2022/cute-widgets-base-progress.mjs +321 -0
  125. package/fesm2022/cute-widgets-base-progress.mjs.map +1 -0
  126. package/fesm2022/cute-widgets-base-radio.mjs +637 -0
  127. package/fesm2022/cute-widgets-base-radio.mjs.map +1 -0
  128. package/fesm2022/cute-widgets-base-select.mjs +1208 -0
  129. package/fesm2022/cute-widgets-base-select.mjs.map +1 -0
  130. package/fesm2022/cute-widgets-base-sidenav.mjs +1095 -0
  131. package/fesm2022/cute-widgets-base-sidenav.mjs.map +1 -0
  132. package/fesm2022/cute-widgets-base-slider.mjs +99 -0
  133. package/fesm2022/cute-widgets-base-slider.mjs.map +1 -0
  134. package/fesm2022/cute-widgets-base-snack-bar.mjs +897 -0
  135. package/fesm2022/cute-widgets-base-snack-bar.mjs.map +1 -0
  136. package/fesm2022/cute-widgets-base-sort.mjs +639 -0
  137. package/fesm2022/cute-widgets-base-sort.mjs.map +1 -0
  138. package/fesm2022/cute-widgets-base-spinner.mjs +154 -0
  139. package/fesm2022/cute-widgets-base-spinner.mjs.map +1 -0
  140. package/fesm2022/cute-widgets-base-stepper.mjs +673 -0
  141. package/fesm2022/cute-widgets-base-stepper.mjs.map +1 -0
  142. package/fesm2022/cute-widgets-base-table.mjs +1023 -0
  143. package/fesm2022/cute-widgets-base-table.mjs.map +1 -0
  144. package/fesm2022/cute-widgets-base-tabs.mjs +729 -0
  145. package/fesm2022/cute-widgets-base-tabs.mjs.map +1 -0
  146. package/fesm2022/cute-widgets-base-timepicker.mjs +965 -0
  147. package/fesm2022/cute-widgets-base-timepicker.mjs.map +1 -0
  148. package/fesm2022/cute-widgets-base-toolbar.mjs +120 -0
  149. package/fesm2022/cute-widgets-base-toolbar.mjs.map +1 -0
  150. package/fesm2022/cute-widgets-base-tooltip.mjs +947 -0
  151. package/fesm2022/cute-widgets-base-tooltip.mjs.map +1 -0
  152. package/fesm2022/cute-widgets-base-tree.mjs +598 -0
  153. package/fesm2022/cute-widgets-base-tree.mjs.map +1 -0
  154. package/fesm2022/cute-widgets-base.mjs +68 -0
  155. package/fesm2022/cute-widgets-base.mjs.map +1 -0
  156. package/form-field/index.d.ts +401 -0
  157. package/grid-list/index.d.ts +361 -0
  158. package/icon/index.d.ts +477 -0
  159. package/index.d.ts +3 -0
  160. package/input/index.d.ts +256 -0
  161. package/layout/container/index.d.ts +31 -0
  162. package/layout/index.d.ts +78 -0
  163. package/layout/stack/index.d.ts +52 -0
  164. package/list/index.d.ts +659 -0
  165. package/menu/index.d.ts +497 -0
  166. package/navbar/index.d.ts +91 -0
  167. package/package.json +279 -0
  168. package/paginator/index.d.ts +216 -0
  169. package/progress/index.d.ts +130 -0
  170. package/radio/index.d.ts +259 -0
  171. package/select/index.d.ts +426 -0
  172. package/sidenav/index.d.ts +369 -0
  173. package/slider/index.d.ts +48 -0
  174. package/snack-bar/index.d.ts +374 -0
  175. package/sort/index.d.ts +334 -0
  176. package/spinner/index.d.ts +70 -0
  177. package/stepper/index.d.ts +295 -0
  178. package/table/index.d.ts +395 -0
  179. package/tabs/index.d.ts +307 -0
  180. package/timepicker/index.d.ts +350 -0
  181. package/toolbar/index.d.ts +36 -0
  182. package/tooltip/index.d.ts +299 -0
  183. package/tree/index.d.ts +314 -0
@@ -0,0 +1,1208 @@
1
+ import { LiveAnnouncer, removeAriaReferencedId, addAriaReferencedId, ActiveDescendantKeyManager } from '@angular/cdk/a11y';
2
+ import { Directionality } from '@angular/cdk/bidi';
3
+ import { SelectionModel } from '@angular/cdk/collections';
4
+ import { DOWN_ARROW, UP_ARROW, LEFT_ARROW, RIGHT_ARROW, ENTER, SPACE, hasModifierKey, A } from '@angular/cdk/keycodes';
5
+ import { Overlay, CdkOverlayOrigin, CdkConnectedOverlay } from '@angular/cdk/overlay';
6
+ import { ViewportRuler } from '@angular/cdk/scrolling';
7
+ import * as i0 from '@angular/core';
8
+ import { InjectionToken, inject, isDevMode, NgZone, EventEmitter, HostAttributeToken, booleanAttribute, numberAttribute, Output, Input, ViewChild, ContentChild, ContentChildren, ChangeDetectionStrategy, ViewEncapsulation, Component, Directive, NgModule } from '@angular/core';
9
+ import { Validators, NgControl, NgForm, FormGroupDirective } from '@angular/forms';
10
+ import { NgClass, CommonModule } from '@angular/common';
11
+ import { Subject, defer, merge } from 'rxjs';
12
+ import { startWith, switchMap, take, filter, map, distinctUntilChanged, takeUntil } from 'rxjs/operators';
13
+ import { trigger, state, transition, style, animate, query, animateChild } from '@angular/animations';
14
+ import { _countGroupLabelsBeforeOption, _getOptionScrollPosition, CuteOption, CUTE_OPTGROUP, CUTE_OPTION_PARENT_COMPONENT, CuteOptgroup } from '@cute-widgets/base/core/option';
15
+ import { CUTE_FORM_FIELD, CuteFormFieldControl } from '@cute-widgets/base/form-field';
16
+ import { ErrorStateMatcher, _ErrorStateTracker } from '@cute-widgets/base/core/error';
17
+ import { CuteInputDropdownControl } from '@cute-widgets/base/abstract';
18
+
19
+ /**
20
+ * @license Apache-2.0
21
+ *
22
+ * Copyright (c) 2025 CuteWidgets Team. All Rights Reserved.
23
+ *
24
+ * You may not use this file except in compliance with the License
25
+ * that can be found at http://www.apache.org/licenses/LICENSE-2.0
26
+ */
27
+ /**
28
+ * The following are all the animations for the mat-select component, with each
29
+ * const containing the metadata for one animation.
30
+ *
31
+ * The values below match the implementation of the AngularJS Material mat-select animation.
32
+ * @docs-private
33
+ */
34
+ const cuteSelectAnimations = {
35
+ /**
36
+ * This animation ensures the select's overlay panel animation (transformPanel) is called when
37
+ * closing the select.
38
+ * This is needed due to https://github.com/angular/angular/issues/23302
39
+ */
40
+ transformPanelWrap: trigger('transformPanelWrap', [
41
+ transition('* => void', query('@transformPanel', [animateChild()], { optional: true })),
42
+ ]),
43
+ /** This animation transforms the select's overlay panel on and off the page. */
44
+ transformPanel: trigger('transformPanel', [
45
+ state('void', style({
46
+ opacity: 0,
47
+ transform: 'scale(1, 0.8)',
48
+ })),
49
+ transition('void => showing', animate('120ms cubic-bezier(0, 0, 0.2, 1)', style({
50
+ opacity: 1,
51
+ transform: 'scale(1, 1)',
52
+ }))),
53
+ transition('* => void', animate('100ms linear', style({ opacity: 0 }))),
54
+ ]),
55
+ };
56
+
57
+ /**
58
+ * @license Apache-2.0
59
+ *
60
+ * Copyright (c) 2025 CuteWidgets Team. All Rights Reserved.
61
+ *
62
+ * You may not use this file except in compliance with the License
63
+ * that can be found at http://www.apache.org/licenses/LICENSE-2.0
64
+ *
65
+ * This code is a modification of the `@angular/material` original
66
+ * code licensed under MIT-style License (https://angular.dev/license).
67
+ */
68
+ /**
69
+ * Returns an exception to be thrown when attempting to change a select's `multiple` option
70
+ * after initialization.
71
+ */
72
+ function getCuteSelectDynamicMultipleError() {
73
+ return Error('Cannot change `multiple` mode of select after initialization.');
74
+ }
75
+ /**
76
+ * Returns an exception to be thrown when attempting to assign a non-array value to a select
77
+ * in `multiple` mode. Note that `undefined` and `null` are still valid values to allow for
78
+ * resetting the value.
79
+ */
80
+ function getCuteSelectNonArrayValueError() {
81
+ return Error('Value must be an array in multiple-selection mode.');
82
+ }
83
+ /**
84
+ * Returns an exception to be thrown when assigning a non-function value to the comparator
85
+ * used to determine if a value corresponds to an option. Note that whether the function
86
+ * actually takes two values and returns a boolean is not checked.
87
+ */
88
+ function getCuteSelectNonFunctionValueError() {
89
+ return Error('`compareWith` must be a function.');
90
+ }
91
+
92
+ /**
93
+ * @license Apache-2.0
94
+ *
95
+ * Copyright (c) 2025 CuteWidgets Team. All Rights Reserved.
96
+ *
97
+ * You may not use this file except in compliance with the License
98
+ * that can be found at http://www.apache.org/licenses/LICENSE-2.0
99
+ *
100
+ * This code is a modification of the `@angular/material` original
101
+ * code licensed under MIT-style License (https://angular.dev/license).
102
+ */
103
+ let nextUniqueId = 0;
104
+ /** Injection token that determines the scroll handling while a select is open. */
105
+ const CUTE_SELECT_SCROLL_STRATEGY = new InjectionToken('cute-select-scroll-strategy', {
106
+ providedIn: 'root',
107
+ factory: () => {
108
+ const overlay = inject(Overlay);
109
+ return () => overlay.scrollStrategies.reposition();
110
+ },
111
+ });
112
+ /** @docs-private */
113
+ function CUTE_SELECT_SCROLL_STRATEGY_PROVIDER_FACTORY(overlay) {
114
+ return () => overlay.scrollStrategies.reposition();
115
+ }
116
+ /** Injection token that can be used to provide the default options the select module. */
117
+ const CUTE_SELECT_CONFIG = new InjectionToken('CUTE_SELECT_CONFIG');
118
+ /** @docs-private */
119
+ const CUTE_SELECT_SCROLL_STRATEGY_PROVIDER = {
120
+ provide: CUTE_SELECT_SCROLL_STRATEGY,
121
+ deps: [Overlay],
122
+ useFactory: CUTE_SELECT_SCROLL_STRATEGY_PROVIDER_FACTORY,
123
+ };
124
+ /**
125
+ * Injection token that can be used to reference instances of `CuteSelectTrigger`. It serves as
126
+ * an alternative token to the actual `CuteSelectTrigger` class which could cause unnecessary
127
+ * retention of the class and its directive metadata.
128
+ */
129
+ const CUTE_SELECT_TRIGGER = new InjectionToken('CuteSelectTrigger');
130
+ /** Change event object that is emitted when the select value has changed. */
131
+ class CuteSelectChange {
132
+ constructor(
133
+ /** Reference to the select that emitted the change event. */
134
+ source,
135
+ /** Current value of the select that emitted the event. */
136
+ value) {
137
+ this.source = source;
138
+ this.value = value;
139
+ }
140
+ }
141
+ class CuteSelect extends CuteInputDropdownControl {
142
+ /** Scrolls a particular option into the view. */
143
+ _scrollOptionIntoView(index) {
144
+ const option = this.options?.toArray()[index];
145
+ if (option && this.panel) {
146
+ const panel = this.panel.nativeElement;
147
+ const content = panel.children[0]; // we place options on one level down in the DOM
148
+ const labelCount = _countGroupLabelsBeforeOption(index, this.options, this.optionGroups);
149
+ const element = option._getHostElement();
150
+ if (index === 0 && labelCount === 1) {
151
+ // If we've got one group label before the option, and we're at the top option,
152
+ // scroll the list to the top. This is better UX than scrolling the list to the
153
+ // top of the option, because it allows the user to read the top group's label.
154
+ //panel.scrollTop = 0;
155
+ content.scrollTop = 0;
156
+ }
157
+ else {
158
+ /*
159
+ panel.scrollTop = _getOptionScrollPosition(
160
+ element.offsetTop,
161
+ element.offsetHeight,
162
+ panel.scrollTop,
163
+ panel.offsetHeight,
164
+ );
165
+ */
166
+ content.scrollTop = _getOptionScrollPosition(element.offsetTop, element.offsetHeight, content.scrollTop, content.offsetHeight);
167
+ }
168
+ }
169
+ }
170
+ /** Generates unique identifier */
171
+ generateId() {
172
+ return `cute-select-${nextUniqueId++}`;
173
+ }
174
+ /** Called when the panel has been opened and the overlay has settled on its final position. */
175
+ _positioningSettled() {
176
+ this._scrollOptionIntoView(this._keyManager?.activeItemIndex || 0);
177
+ }
178
+ /** Creates a change event object that should be emitted by the select. */
179
+ _getChangeEvent(value) {
180
+ return new CuteSelectChange(this, value);
181
+ }
182
+ get expanded() { return this.panelOpen; }
183
+ /** Whether the select is focused. */
184
+ get focused() {
185
+ return this._focused || this._panelOpen;
186
+ }
187
+ /** Implemented as part of CuteFormFieldControl. */
188
+ get controlElementRef() { return this._elementRef; }
189
+ /** Whether the checkmark indicator for single-selection options is hidden. */
190
+ get hideSingleSelectionIndicator() {
191
+ return this._hideSingleSelectionIndicator;
192
+ }
193
+ set hideSingleSelectionIndicator(value) {
194
+ this._hideSingleSelectionIndicator = value;
195
+ this._syncParentProperties();
196
+ }
197
+ /** Placeholder to be shown if no value has been selected. */
198
+ get placeholder() { return this._placeholder; }
199
+ set placeholder(value) {
200
+ this._placeholder = value;
201
+ this.stateChanges.next();
202
+ }
203
+ /** Whether the component is required. */
204
+ get required() {
205
+ return super.required ?? this.ngControl?.control?.hasValidator(Validators.required) ?? false;
206
+ }
207
+ set required(value) {
208
+ super.required = value;
209
+ this.stateChanges.next();
210
+ }
211
+ /** Whether the user should be allowed to select multiple options. */
212
+ get multiple() { return this._multiple; }
213
+ set multiple(value) {
214
+ if (this._selectionModel && isDevMode()) {
215
+ throw getCuteSelectDynamicMultipleError();
216
+ }
217
+ this._multiple = value;
218
+ }
219
+ /**
220
+ * Function to compare the option values with the selected values. The first argument
221
+ * is a value from an option. The second is a value from the selection. A boolean
222
+ * should be returned.
223
+ */
224
+ get compareWith() { return this._compareWith; }
225
+ set compareWith(fn) {
226
+ if (typeof fn !== 'function' && isDevMode()) {
227
+ throw getCuteSelectNonFunctionValueError();
228
+ }
229
+ this._compareWith = fn;
230
+ if (this._selectionModel) {
231
+ // A different comparator means the selection could change.
232
+ this._initializeSelection();
233
+ }
234
+ }
235
+ /** Value of the select control. */
236
+ get value() { return this._value; }
237
+ set value(newValue) {
238
+ const hasAssigned = this._assignValue(newValue);
239
+ if (hasAssigned) {
240
+ this._onChange(newValue);
241
+ }
242
+ }
243
+ /** Object used to control when error messages are shown. */
244
+ get errorStateMatcher() { return this._errorStateTracker.matcher; }
245
+ set errorStateMatcher(value) {
246
+ this._errorStateTracker.matcher = value;
247
+ }
248
+ /** Whether the select is in an error state. */
249
+ get errorState() { return this._errorStateTracker.errorState; }
250
+ set errorState(value) {
251
+ this._errorStateTracker.errorState = value;
252
+ }
253
+ constructor() {
254
+ super();
255
+ this._viewportRuler = inject(ViewportRuler);
256
+ this._ngZone = inject(NgZone);
257
+ this._dir = inject(Directionality, { optional: true });
258
+ this._parentFormField = inject(CUTE_FORM_FIELD, { optional: true });
259
+ this.ngControl = inject(NgControl, { self: true, optional: true });
260
+ this._liveAnnouncer = inject(LiveAnnouncer);
261
+ this._defaultOptions = inject(CUTE_SELECT_CONFIG, { optional: true });
262
+ /**
263
+ * This position config ensures that the top "start" corner of the overlay
264
+ * is aligned with the top "start" of the origin by default (overlapping
265
+ * the trigger completely). If the panel cannot fit below the trigger, it
266
+ * will fall back to a position above the trigger.
267
+ */
268
+ this._positions = [
269
+ {
270
+ originX: 'start',
271
+ originY: 'bottom',
272
+ overlayX: 'start',
273
+ overlayY: 'top',
274
+ offsetY: 4,
275
+ },
276
+ {
277
+ originX: 'end',
278
+ originY: 'bottom',
279
+ overlayX: 'end',
280
+ overlayY: 'top',
281
+ offsetY: 4,
282
+ },
283
+ {
284
+ originX: 'start',
285
+ originY: 'top',
286
+ overlayX: 'start',
287
+ overlayY: 'bottom',
288
+ offsetY: -4,
289
+ //panelClass: 'cute-select-panel-above',
290
+ },
291
+ {
292
+ originX: 'end',
293
+ originY: 'top',
294
+ overlayX: 'end',
295
+ overlayY: 'bottom',
296
+ offsetY: -4,
297
+ //panelClass: 'cute-select-panel-above',
298
+ },
299
+ ];
300
+ /** Factory function used to create a scroll strategy for this select. */
301
+ this._scrollStrategyFactory = inject(CUTE_SELECT_SCROLL_STRATEGY);
302
+ /** Whether the overlay panel is open. */
303
+ this._panelOpen = false;
304
+ /** Comparison function to specify which option is displayed. Defaults to object equality. */
305
+ this._compareWith = (o1, o2) => o1 === o2;
306
+ /** Current `aria-labelledby` value for the select trigger. */
307
+ this._triggerAriaLabelledBy = null;
308
+ /** Emits whenever the component is destroyed. */
309
+ this._destroy = new Subject();
310
+ /** Emits when the panel element is finished transforming in. */
311
+ this._panelDoneAnimatingStream = new Subject();
312
+ /** Disable the automatic labeling to avoid issues like #27241. */
313
+ this.disableAutomaticLabeling = true;
314
+ this._overlayPanelClass = this._defaultOptions?.overlayPanelClass || '';
315
+ this._focused = false;
316
+ /** A name for this control that can be used by `cute-form-field`. */
317
+ this.controlType = 'cute-select';
318
+ /** Classes to be passed to the select panel. Supports the same syntax as `ngClass`. */
319
+ this.panelClass = "";
320
+ /** Whether ripples in the select are disabled. */
321
+ this.disableRipple = false;
322
+ this._hideSingleSelectionIndicator = this._defaultOptions?.hideSingleSelectionIndicator ?? false;
323
+ this._placeholder = "";
324
+ this._multiple = false;
325
+ /** Whether to center the active option over the trigger. */
326
+ this.disableOptionCentering = this._defaultOptions?.disableOptionCentering ?? false;
327
+ /** Time to wait in milliseconds after the last keystroke before moving focus to an item. */
328
+ this.typeaheadDebounceInterval = 0;
329
+ /**
330
+ * Width of the panel. If set to `auto`, the panel will match the trigger width.
331
+ * If set to null or an empty string, the panel will grow to match the longest option's text.
332
+ */
333
+ this.panelWidth = this._defaultOptions && typeof this._defaultOptions.panelWidth !== 'undefined'
334
+ ? this._defaultOptions.panelWidth
335
+ : 'auto';
336
+ /**
337
+ * Height of the panel. If set to `auto`, _null_ or an empty string, the panel will display all options.
338
+ * If height is not empty, its value is set as a maximum height of the panel with vertical scrolling set to `auto`.
339
+ */
340
+ this.panelHeight = this._defaultOptions && typeof this._defaultOptions.panelHeight !== 'undefined'
341
+ ? this._defaultOptions.panelHeight
342
+ : null;
343
+ /**
344
+ * By default, selecting an option with a `null` or `undefined` value will reset the select's
345
+ * value. Enable this option if the reset behavior doesn't match your requirements and instead,
346
+ * the nullable options should become selected. The value of this input can be controlled app-wide
347
+ * using the `MAT_SELECT_CONFIG` injection token.
348
+ */
349
+ this.canSelectNullableOptions = this._defaultOptions?.canSelectNullableOptions ?? false;
350
+ /** Combined stream of all of the child options' change events. */
351
+ this.optionSelectionChanges = defer(() => {
352
+ const options = this.options;
353
+ if (options) {
354
+ return options.changes.pipe(startWith(options), switchMap(() => merge(...options.map(option => option.onSelectionChange))));
355
+ }
356
+ return this._ngZone.onStable.pipe(take(1), switchMap(() => this.optionSelectionChanges));
357
+ });
358
+ /** Event emitted when the select panel has been toggled. */
359
+ this.openedChange = new EventEmitter();
360
+ /** Event emitted when the select has been opened. */
361
+ this._openedStream = this.openedChange.pipe(filter(o => o), map(() => { }));
362
+ /** Event emitted when the select has been closed. */
363
+ this._closedStream = this.openedChange.pipe(filter(o => !o), map(() => { }));
364
+ /** Event emitted when the selected value has been changed by the user. */
365
+ this.selectionChange = new EventEmitter();
366
+ /**
367
+ * Event that emits whenever the raw value of the select changes. This is here primarily
368
+ * to facilitate the two-way binding for the `value` input.
369
+ */
370
+ this.valueChange = new EventEmitter();
371
+ /**
372
+ * Track which modal we have modified the `aria-owns` attribute of. When the combobox trigger is
373
+ * inside an aria-modal, we apply aria-owns to the parent modal with the `id` of the options
374
+ * panel. Track the modal we have changed so we can undo the changes on destroy.
375
+ */
376
+ this._trackedModal = null;
377
+ // `skipPredicate` determines if key manager should avoid putting a given option in the tab
378
+ // order. Allow disabled list items to receive focus via keyboard to align with WAI ARIA
379
+ // recommendation.
380
+ //
381
+ // Normally WAI ARIA's instructions are to exclude disabled items from the tab order, but it
382
+ // makes a few exceptions for compound widgets.
383
+ //
384
+ // From [Developing a Keyboard Interface](
385
+ // https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/):
386
+ // "For the following composite widget elements, keep them focusable when disabled: Options in a
387
+ // Listbox..."
388
+ //
389
+ // The user can focus on disabled options using the keyboard, but the user cannot click disabled
390
+ // options.
391
+ this._skipPredicate = (option) => {
392
+ if (this.panelOpen) {
393
+ // Support keyboard focusing disabled options in an ARIA listbox.
394
+ return false;
395
+ }
396
+ // When the panel is closed, skip over disabled options. Support options via the UP/DOWN arrow
397
+ // keys on closed select. ARIA listbox interaction pattern is less relevant when the panel is
398
+ // closed.
399
+ return option.disabled;
400
+ };
401
+ const defaultErrorStateMatcher = inject(ErrorStateMatcher);
402
+ const parentForm = inject(NgForm, { optional: true });
403
+ const parentFormGroup = inject(FormGroupDirective, { optional: true });
404
+ const tabIndex = inject(new HostAttributeToken('tabindex'), { optional: true });
405
+ if (this.ngControl) {
406
+ // Note: we provide the value accessor through here, instead of
407
+ // the `providers` to avoid running into a circular import.
408
+ this.ngControl.valueAccessor = this;
409
+ }
410
+ // Note that we only want to set this when the defaults pass it in; otherwise it should
411
+ // stay as `undefined` so that it falls back to the default in the key manager.
412
+ if (this._defaultOptions?.typeaheadDebounceInterval != null) {
413
+ this.typeaheadDebounceInterval = this._defaultOptions.typeaheadDebounceInterval;
414
+ }
415
+ this._errorStateTracker = new _ErrorStateTracker(defaultErrorStateMatcher, this.ngControl, parentFormGroup, parentForm, this.stateChanges);
416
+ this._scrollStrategy = this._scrollStrategyFactory();
417
+ this.tabIndex = tabIndex == null ? 0 : parseInt(tabIndex) || 0;
418
+ // Force setter to be called in case id was not specified.
419
+ this.id = this.id;
420
+ }
421
+ ngOnInit() {
422
+ super.ngOnInit();
423
+ this._selectionModel = new SelectionModel(this.multiple);
424
+ this.stateChanges.next();
425
+ // We need `distinctUntilChanged` here, because some browsers will
426
+ // fire the animation end event twice for the same animation. See:
427
+ // https://github.com/angular/angular/issues/24084
428
+ this._panelDoneAnimatingStream
429
+ .pipe(distinctUntilChanged(), takeUntil(this._destroy))
430
+ .subscribe(() => this._panelDoneAnimating(this.panelOpen));
431
+ this._viewportRuler
432
+ .change()
433
+ .pipe(takeUntil(this._destroy))
434
+ .subscribe(() => {
435
+ if (this.panelOpen) {
436
+ this._overlayWidth = this._getOverlayWidth(this._preferredOverlayOrigin);
437
+ this._changeDetectorRef.detectChanges();
438
+ }
439
+ });
440
+ }
441
+ ngAfterContentInit() {
442
+ super.ngAfterContentInit();
443
+ this._initKeyManager();
444
+ this._selectionModel?.changed.pipe(takeUntil(this._destroy)).subscribe(event => {
445
+ event.added.forEach(option => option.select());
446
+ event.removed.forEach(option => option.deselect());
447
+ });
448
+ this.options?.changes.pipe(startWith(null), takeUntil(this._destroy)).subscribe(() => {
449
+ this._resetOptions();
450
+ this._initializeSelection();
451
+ });
452
+ }
453
+ ngDoCheck() {
454
+ const newAriaLabelledby = this._getTriggerAriaLabelledby();
455
+ const ngControl = this.ngControl;
456
+ // We have to manage setting the `aria-labelledby` ourselves, because part of its value
457
+ // is computed as a result of a content query which can cause this binding to trigger a
458
+ // "changed after checked" error.
459
+ if (newAriaLabelledby !== this._triggerAriaLabelledBy) {
460
+ const element = this._elementRef.nativeElement;
461
+ this._triggerAriaLabelledBy = newAriaLabelledby;
462
+ if (newAriaLabelledby) {
463
+ element.setAttribute('aria-labelledby', newAriaLabelledby);
464
+ }
465
+ else {
466
+ element.removeAttribute('aria-labelledby');
467
+ }
468
+ }
469
+ if (ngControl) {
470
+ // The disabled state might go out of sync if the form group is swapped out. See #17860.
471
+ if (this._previousControl !== ngControl.control) {
472
+ if (this._previousControl !== undefined &&
473
+ ngControl.disabled !== null &&
474
+ ngControl.disabled !== this.disabled) {
475
+ this.disabled = ngControl.disabled;
476
+ }
477
+ this._previousControl = ngControl.control;
478
+ }
479
+ this.updateErrorState();
480
+ }
481
+ }
482
+ ngOnChanges(changes) {
483
+ super.ngOnChanges(changes);
484
+ // Updating the disabled state is handled by the input, but we need to additionally let
485
+ // the parent form field know to run change detection when the disabled state changes.
486
+ if (changes['disabled'] || changes['userAriaDescribedBy']) {
487
+ this.stateChanges.next();
488
+ }
489
+ if (changes['typeaheadDebounceInterval'] && this._keyManager) {
490
+ this._keyManager.withTypeAhead(this.typeaheadDebounceInterval);
491
+ }
492
+ }
493
+ ngOnDestroy() {
494
+ super.ngOnDestroy();
495
+ this._keyManager?.destroy();
496
+ this._destroy.next();
497
+ this._destroy.complete();
498
+ this.stateChanges.complete();
499
+ this._clearFromModal();
500
+ }
501
+ /** Toggles the overlay panel open or closed. */
502
+ toggle() {
503
+ this.panelOpen ? this.close() : this.open();
504
+ }
505
+ /** Opens the overlay panel. */
506
+ open() {
507
+ // It's important that we read this as late as possible, because doing so earlier will
508
+ // return a different element since it's based on queries in the form field which may
509
+ // not have run yet. Also, this needs to be assigned before we measure the overlay width.
510
+ if (this._parentFormField) {
511
+ this._preferredOverlayOrigin = this._parentFormField.getConnectedOverlayOrigin();
512
+ }
513
+ this._overlayWidth = this._getOverlayWidth(this._preferredOverlayOrigin);
514
+ if (this._canOpen()) {
515
+ this._applyModalPanelOwnership();
516
+ this._panelOpen = true;
517
+ this._keyManager?.withHorizontalOrientation(null);
518
+ this._highlightCorrectOption();
519
+ this.markForCheck();
520
+ }
521
+ // Required for the MDC form field to pick up when the overlay has been opened.
522
+ this.stateChanges.next();
523
+ }
524
+ /**
525
+ * If the autocomplete trigger is inside of an `aria-modal` element, connect
526
+ * that modal to the options panel with `aria-owns`.
527
+ *
528
+ * For some browser + screen reader combinations, when navigation is inside
529
+ * of an `aria-modal` element, the screen reader treats everything outside
530
+ * of that modal as hidden or invisible.
531
+ *
532
+ * This causes a problem when the combobox trigger is _inside_ of a modal, because the
533
+ * options panel is rendered _outside_ of that modal, preventing screen reader navigation
534
+ * from reaching the panel.
535
+ *
536
+ * We can work around this issue by applying `aria-owns` to the modal with the `id` of
537
+ * the options panel. This effectively communicates to assistive technology that the
538
+ * options panel is part of the same interaction as the modal.
539
+ *
540
+ * At the time of this writing, this issue is present in VoiceOver.
541
+ * See https://github.com/angular/components/issues/20694
542
+ */
543
+ _applyModalPanelOwnership() {
544
+ // TODO(http://github.com/angular/components/issues/26853): consider de-duplicating this with
545
+ // the `LiveAnnouncer` and any other usages.
546
+ //
547
+ // Note that the selector here is limited to CDK overlays at the moment in order to reduce the
548
+ // section of the DOM we need to look through. This should cover all the cases we support, but
549
+ // the selector can be expanded if it turns out to be too narrow.
550
+ const modal = this._elementRef.nativeElement.closest('body > .cdk-overlay-container [aria-modal="true"]');
551
+ if (!modal) {
552
+ // Most commonly, the autocomplete trigger is not inside a modal.
553
+ return;
554
+ }
555
+ const panelId = `${this.id}-panel`;
556
+ if (this._trackedModal) {
557
+ removeAriaReferencedId(this._trackedModal, 'aria-owns', panelId);
558
+ }
559
+ addAriaReferencedId(modal, 'aria-owns', panelId);
560
+ this._trackedModal = modal;
561
+ }
562
+ /** Clears the reference to the listbox overlay element from the modal it was added to. */
563
+ _clearFromModal() {
564
+ if (!this._trackedModal) {
565
+ // Most commonly, the autocomplete trigger is not used inside a modal.
566
+ return;
567
+ }
568
+ const panelId = `${this.id}-panel`;
569
+ removeAriaReferencedId(this._trackedModal, 'aria-owns', panelId);
570
+ this._trackedModal = null;
571
+ }
572
+ /** Closes the overlay panel and focuses the host element. */
573
+ close() {
574
+ if (this._panelOpen) {
575
+ this._panelOpen = false;
576
+ this._keyManager?.withHorizontalOrientation(this._isRtl() ? 'rtl' : 'ltr');
577
+ this.markForCheck();
578
+ this._onTouched();
579
+ }
580
+ this.focus();
581
+ // Required for the MDC form field to pick up when the overlay has been closed.
582
+ this.stateChanges.next();
583
+ }
584
+ /**
585
+ * Sets the select' value. Part of the ControlValueAccessor interface
586
+ * required to integrate with Angular core forms API.
587
+ *
588
+ * @param value New value to be written to the model.
589
+ */
590
+ writeValue(value) {
591
+ this._assignValue(value);
592
+ }
593
+ /** Whether the overlay panel is open. */
594
+ get panelOpen() {
595
+ return this._panelOpen;
596
+ }
597
+ /** The currently selected option. */
598
+ get selected() {
599
+ return this.multiple ? this._selectionModel?.selected || [] : this._selectionModel?.selected[0];
600
+ }
601
+ /** The value displayed in the trigger. */
602
+ get triggerValue() {
603
+ if (this.empty) {
604
+ return '';
605
+ }
606
+ if (this._multiple) {
607
+ const selectedOptions = this._selectionModel.selected.map(option => option.viewValue);
608
+ if (this._isRtl()) {
609
+ selectedOptions.reverse();
610
+ }
611
+ // TODO(crisbeto): delimiter should be configurable for proper localization.
612
+ return selectedOptions.join(', ');
613
+ }
614
+ return this._selectionModel.selected[0].viewValue;
615
+ }
616
+ /** Refreshes the error state of the select. */
617
+ updateErrorState() {
618
+ this._errorStateTracker.updateErrorState();
619
+ }
620
+ /** Whether the element is in RTL mode. */
621
+ _isRtl() {
622
+ return this._dir ? this._dir.value === 'rtl' : false;
623
+ }
624
+ /** Handles all keydown events on the select. */
625
+ _handleKeydown(event) {
626
+ if (!this.disabled) {
627
+ this.panelOpen ? this._handleOpenKeydown(event) : this._handleClosedKeydown(event);
628
+ }
629
+ }
630
+ /** Handles keyboard events while the select is closed. */
631
+ _handleClosedKeydown(event) {
632
+ const keyCode = event.keyCode;
633
+ const isArrowKey = keyCode === DOWN_ARROW ||
634
+ keyCode === UP_ARROW ||
635
+ keyCode === LEFT_ARROW ||
636
+ keyCode === RIGHT_ARROW;
637
+ const isOpenKey = keyCode === ENTER || keyCode === SPACE;
638
+ const manager = this._keyManager;
639
+ // Open the select on ALT + arrow key to match the native <select>
640
+ if ((manager && !manager.isTyping() && isOpenKey && !hasModifierKey(event)) ||
641
+ ((this.multiple || event.altKey) && isArrowKey)) {
642
+ event.preventDefault(); // prevents the page from scrolling down when pressing space
643
+ this.open();
644
+ }
645
+ else if (!this.multiple) {
646
+ const previouslySelectedOption = this.selected;
647
+ manager.onKeydown(event);
648
+ const selectedOption = this.selected;
649
+ // Since the value has changed, we need to announce it ourselves.
650
+ if (selectedOption && previouslySelectedOption !== selectedOption) {
651
+ // We set a duration on the live announcement, because we want the live element to be
652
+ // cleared after a while so that users can't navigate to it using the arrow keys.
653
+ this._liveAnnouncer.announce(selectedOption.viewValue, 10000);
654
+ }
655
+ }
656
+ }
657
+ /** Handles keyboard events when the selected is open. */
658
+ _handleOpenKeydown(event) {
659
+ const manager = this._keyManager;
660
+ const keyCode = event.keyCode;
661
+ const isArrowKey = keyCode === DOWN_ARROW || keyCode === UP_ARROW;
662
+ const isTyping = manager.isTyping();
663
+ if (isArrowKey && event.altKey) {
664
+ // Close the select on ALT + arrow key to match the native <select>
665
+ event.preventDefault();
666
+ this.close();
667
+ // Don't do anything in this case if the user is typing,
668
+ // because the typing sequence can include the space key.
669
+ }
670
+ else if (!isTyping &&
671
+ (keyCode === ENTER || keyCode === SPACE) &&
672
+ manager.activeItem &&
673
+ !hasModifierKey(event)) {
674
+ event.preventDefault();
675
+ manager.activeItem._selectViaInteraction();
676
+ }
677
+ else if (!isTyping && this._multiple && keyCode === A && event.ctrlKey) {
678
+ event.preventDefault();
679
+ const hasDeselectedOptions = this.options?.some(opt => !opt.disabled && !opt.selected);
680
+ this.options?.forEach(option => {
681
+ if (!option.disabled) {
682
+ hasDeselectedOptions ? option.select() : option.deselect();
683
+ }
684
+ });
685
+ }
686
+ else {
687
+ const previouslyFocusedIndex = manager.activeItemIndex;
688
+ manager.onKeydown(event);
689
+ if (this._multiple &&
690
+ isArrowKey &&
691
+ event.shiftKey &&
692
+ manager.activeItem &&
693
+ manager.activeItemIndex !== previouslyFocusedIndex) {
694
+ manager.activeItem._selectViaInteraction();
695
+ }
696
+ }
697
+ }
698
+ _onFocus() {
699
+ if (!this.disabled) {
700
+ this._focused = true;
701
+ this.stateChanges.next();
702
+ }
703
+ }
704
+ /**
705
+ * Calls the touched callback only if the panel is closed. Otherwise, the trigger will
706
+ * "blur" to the panel when it opens, causing a false positive.
707
+ */
708
+ _onBlur() {
709
+ this._focused = false;
710
+ this._keyManager?.cancelTypeahead();
711
+ if (!this.disabled && !this.panelOpen) {
712
+ this._onTouched();
713
+ this.markForCheck();
714
+ this.stateChanges.next();
715
+ }
716
+ }
717
+ /**
718
+ * Callback that is invoked when the overlay panel has been attached.
719
+ */
720
+ _onAttached() {
721
+ this._overlayDir?.positionChange.pipe(take(1)).subscribe(() => {
722
+ this._changeDetectorRef.detectChanges();
723
+ this._positioningSettled();
724
+ });
725
+ }
726
+ /** Returns the theme to be used on the panel. */
727
+ _getPanelTheme() {
728
+ return this._parentFormField ? `cute-${this._parentFormField.color}` : '';
729
+ }
730
+ /** Whether the select has a value. */
731
+ get empty() {
732
+ return !this._selectionModel || this._selectionModel.isEmpty();
733
+ }
734
+ _initializeSelection() {
735
+ // Defers setting the value to avoid the "Expression
736
+ // has changed after it was checked" errors from Angular.
737
+ Promise.resolve().then(() => {
738
+ if (this.ngControl) {
739
+ this._value = this.ngControl.value;
740
+ }
741
+ this._setSelectionByValue(this._value);
742
+ this.stateChanges.next();
743
+ });
744
+ }
745
+ /**
746
+ * Sets the selected option based on a value. If no option can be
747
+ * found with the designated value, the select trigger is cleared.
748
+ */
749
+ _setSelectionByValue(value) {
750
+ this.options?.forEach(option => option.setInactiveStyles());
751
+ this._selectionModel?.clear();
752
+ if (this.multiple && value) {
753
+ if (!Array.isArray(value) && isDevMode()) {
754
+ throw getCuteSelectNonArrayValueError();
755
+ }
756
+ value.forEach((currentValue) => this._selectOptionByValue(currentValue));
757
+ this._sortValues();
758
+ }
759
+ else {
760
+ const correspondingOption = this._selectOptionByValue(value);
761
+ // Shift focus to the active item. Note that we shouldn't do this in multiple
762
+ // mode, because we don't know what option the user interacted with last.
763
+ if (correspondingOption) {
764
+ this._keyManager?.updateActiveItem(correspondingOption);
765
+ }
766
+ else if (!this.panelOpen) {
767
+ // Otherwise, reset the highlighted option. Note that we only want to do this while
768
+ // closed, because doing it while open can shift the user's focus unnecessarily.
769
+ this._keyManager?.updateActiveItem(-1);
770
+ }
771
+ }
772
+ this.markForCheck();
773
+ }
774
+ /**
775
+ * Finds and selects and option based on its value.
776
+ * @returns Option that has the corresponding value.
777
+ */
778
+ _selectOptionByValue(value) {
779
+ const correspondingOption = this.options?.find((option) => {
780
+ // Skip options that are already in the model. This allows us to handle cases
781
+ // where the same primitive value is selected multiple times.
782
+ if (this._selectionModel?.isSelected(option)) {
783
+ return false;
784
+ }
785
+ try {
786
+ // Treat null as a special reset value.
787
+ return (option.value != null || this.canSelectNullableOptions) &&
788
+ this._compareWith(option.value, value);
789
+ }
790
+ catch (error) {
791
+ if (isDevMode()) {
792
+ // Notify developers of errors in their comparator.
793
+ console.warn(error);
794
+ }
795
+ return false;
796
+ }
797
+ });
798
+ if (correspondingOption) {
799
+ this._selectionModel?.select(correspondingOption);
800
+ }
801
+ return correspondingOption;
802
+ }
803
+ /** Assigns a specific value to the select. Returns whether the value has changed. */
804
+ _assignValue(newValue) {
805
+ // Always re-assign an array, because it might have been mutated.
806
+ if (newValue !== this._value || (this._multiple && Array.isArray(newValue))) {
807
+ if (this.options) {
808
+ this._setSelectionByValue(newValue);
809
+ }
810
+ this._value = newValue;
811
+ return true;
812
+ }
813
+ return false;
814
+ }
815
+ /** Gets how wide the overlay panel should be. */
816
+ _getOverlayWidth(preferredOrigin) {
817
+ if (this.panelWidth === 'auto') {
818
+ const refToMeasure = preferredOrigin instanceof CdkOverlayOrigin
819
+ ? preferredOrigin.elementRef
820
+ : preferredOrigin || this._elementRef;
821
+ return refToMeasure.nativeElement.getBoundingClientRect().width;
822
+ }
823
+ return this.panelWidth === null ? '' : this.panelWidth;
824
+ }
825
+ /** Syncs the parent state with the individual options. */
826
+ _syncParentProperties() {
827
+ if (this.options) {
828
+ for (const option of this.options) {
829
+ option.markForCheck();
830
+ }
831
+ }
832
+ }
833
+ /** Sets up a key manager to listen to keyboard events on the overlay panel. */
834
+ _initKeyManager() {
835
+ this._keyManager = new ActiveDescendantKeyManager(this.options)
836
+ .withTypeAhead(this.typeaheadDebounceInterval)
837
+ .withVerticalOrientation()
838
+ .withHorizontalOrientation(this._isRtl() ? 'rtl' : 'ltr')
839
+ .withHomeAndEnd()
840
+ .withPageUpDown()
841
+ .withAllowedModifierKeys(['shiftKey'])
842
+ .skipPredicate(this._skipPredicate);
843
+ this._keyManager.tabOut.subscribe(() => {
844
+ if (this.panelOpen) {
845
+ // Select the active item when tabbing away. This is consistent with how the native
846
+ // select behaves. Note that we only want to do this in single selection mode.
847
+ if (!this.multiple && this._keyManager?.activeItem) {
848
+ this._keyManager.activeItem._selectViaInteraction();
849
+ }
850
+ // Restore focus to the trigger before closing. Ensures that the focus
851
+ // position won't be lost if the user got focus into the overlay.
852
+ this.focus();
853
+ this.close();
854
+ }
855
+ });
856
+ this._keyManager.change.subscribe(() => {
857
+ if (this._panelOpen && this.panel) {
858
+ this._scrollOptionIntoView(this._keyManager?.activeItemIndex || 0);
859
+ }
860
+ else if (!this._panelOpen && !this.multiple && this._keyManager?.activeItem) {
861
+ this._keyManager.activeItem._selectViaInteraction();
862
+ }
863
+ });
864
+ }
865
+ /** Drops current option subscriptions and IDs and resets from scratch. */
866
+ _resetOptions() {
867
+ const changedOrDestroyed = merge(this.options.changes, this._destroy);
868
+ this.optionSelectionChanges.pipe(takeUntil(changedOrDestroyed)).subscribe(event => {
869
+ this._onSelect(event.source, event.isUserInput);
870
+ if (event.isUserInput && !this.multiple && this._panelOpen) {
871
+ this.close();
872
+ this.focus();
873
+ }
874
+ });
875
+ // Listen to changes in the internal state of the options and react accordingly.
876
+ // Handles cases like the labels of the selected options changing.
877
+ merge(...this.options.map(option => option._stateChanges))
878
+ .pipe(takeUntil(changedOrDestroyed))
879
+ .subscribe(() => {
880
+ // `_stateChanges` can fire as a result of a change in the label's DOM value which may
881
+ // be the result of an expression changing. We have to use `detectChanges` in order
882
+ // to avoid "changed after checked" errors (see #14793).
883
+ this._changeDetectorRef.detectChanges();
884
+ this.stateChanges.next();
885
+ });
886
+ }
887
+ /** Invoked when an option is clicked. */
888
+ _onSelect(option, isUserInput) {
889
+ const wasSelected = this._selectionModel?.isSelected(option);
890
+ if (!this.canSelectNullableOptions && option.value == null && !this._multiple) {
891
+ option.deselect();
892
+ this._selectionModel?.clear();
893
+ if (this.value != null) {
894
+ this._propagateChanges(option.value);
895
+ }
896
+ }
897
+ else {
898
+ if (wasSelected !== option.selected) {
899
+ option.selected
900
+ ? this._selectionModel?.select(option)
901
+ : this._selectionModel?.deselect(option);
902
+ }
903
+ if (isUserInput) {
904
+ this._keyManager?.setActiveItem(option);
905
+ }
906
+ if (this.multiple) {
907
+ this._sortValues();
908
+ if (isUserInput) {
909
+ // In case the user selected the option with their mouse, we
910
+ // want to restore focus back to the trigger, in order to
911
+ // prevent the select keyboard controls from clashing with
912
+ // the ones from `cute-option`.
913
+ this.focus();
914
+ }
915
+ }
916
+ }
917
+ if (wasSelected !== this._selectionModel?.isSelected(option)) {
918
+ this._propagateChanges();
919
+ }
920
+ this.stateChanges.next();
921
+ }
922
+ /** Sorts the selected values in the selected based on their order in the panel. */
923
+ _sortValues() {
924
+ if (this.multiple) {
925
+ const options = this.options.toArray();
926
+ this._selectionModel?.sort((a, b) => {
927
+ return this.sortComparator
928
+ ? this.sortComparator(a, b, options)
929
+ : options.indexOf(a) - options.indexOf(b);
930
+ });
931
+ this.stateChanges.next();
932
+ }
933
+ }
934
+ /** Emits change event to set the model value. */
935
+ _propagateChanges(fallbackValue) {
936
+ let valueToEmit;
937
+ if (this.multiple) {
938
+ valueToEmit = this.selected.map(option => option.value);
939
+ }
940
+ else {
941
+ valueToEmit = this.selected ? this.selected.value : fallbackValue;
942
+ }
943
+ this._value = valueToEmit;
944
+ this.valueChange.emit(valueToEmit);
945
+ this._onChange(valueToEmit);
946
+ this.selectionChange.emit(this._getChangeEvent(valueToEmit));
947
+ this.markForCheck();
948
+ }
949
+ /**
950
+ * Highlights the selected item. If no option is selected, it will highlight
951
+ * the first *enabled* option.
952
+ */
953
+ _highlightCorrectOption() {
954
+ if (this._keyManager) {
955
+ if (this.empty) {
956
+ // Find the index of the first *enabled* option. Avoid calling `_keyManager.setActiveItem`
957
+ // because it activates the first option that passes the skip predicate, rather than the
958
+ // first *enabled* option.
959
+ let firstEnabledOptionIndex = -1;
960
+ for (let index = 0; index < this.options.length; index++) {
961
+ const option = this.options.get(index);
962
+ if (!option.disabled) {
963
+ firstEnabledOptionIndex = index;
964
+ break;
965
+ }
966
+ }
967
+ this._keyManager.setActiveItem(firstEnabledOptionIndex);
968
+ }
969
+ else {
970
+ this._keyManager.setActiveItem(this._selectionModel.selected[0]);
971
+ }
972
+ }
973
+ }
974
+ /** Whether the panel is allowed to open. */
975
+ _canOpen() {
976
+ return !this._panelOpen && !this.disabled && this.options.length > 0;
977
+ }
978
+ /** Focuses the select element. */
979
+ focus(origin, options) {
980
+ //this._elementRef.nativeElement.focus(options);
981
+ this.trigger?.nativeElement.focus(options);
982
+ }
983
+ /** Gets the aria-labelledby for the select panel. */
984
+ _getPanelAriaLabelledby() {
985
+ if (this.ariaLabel) {
986
+ return null;
987
+ }
988
+ const labelId = this._parentFormField?.getLabelId() || null;
989
+ const labelExpression = labelId ? labelId + ' ' : '';
990
+ return this.ariaLabelledby ? labelExpression + this.ariaLabelledby : labelId;
991
+ }
992
+ /** Determines the `aria-activedescendant` to be set on the host. */
993
+ _getAriaActiveDescendant() {
994
+ if (this.panelOpen && this._keyManager && this._keyManager.activeItem) {
995
+ return this._keyManager.activeItem.id || null;
996
+ }
997
+ return null;
998
+ }
999
+ /** Gets the aria-labelledby of the select component trigger. */
1000
+ _getTriggerAriaLabelledby() {
1001
+ if (this.ariaLabel) {
1002
+ return null;
1003
+ }
1004
+ const labelId = this._parentFormField?.getLabelId();
1005
+ let value = (labelId ? labelId + ' ' : '') + this.inputId;
1006
+ if (this.ariaLabelledby) {
1007
+ value += ' ' + this.ariaLabelledby;
1008
+ }
1009
+ return value;
1010
+ }
1011
+ /** Called when the overlay panel is done animating. */
1012
+ _panelDoneAnimating(isOpen) {
1013
+ this.openedChange.emit(isOpen);
1014
+ }
1015
+ /**
1016
+ * Implemented as part of CuteFormFieldControl.
1017
+ */
1018
+ setDescribedByIds(ids) {
1019
+ if (ids.length) {
1020
+ this._elementRef.nativeElement.setAttribute('aria-describedby', ids.join(' '));
1021
+ }
1022
+ else {
1023
+ this._elementRef.nativeElement.removeAttribute('aria-describedby');
1024
+ }
1025
+ }
1026
+ /**
1027
+ * Implemented as part of CuteFormFieldControl.
1028
+ */
1029
+ onContainerClick() {
1030
+ this.focus();
1031
+ this.open();
1032
+ }
1033
+ /**
1034
+ * Implemented as part of CuteFormFieldControl.
1035
+ */
1036
+ get shouldLabelFloat() {
1037
+ // Since the panel doesn't overlap the trigger, we
1038
+ // want the label to only float when there's a value.
1039
+ return this.panelOpen || !this.empty || (this.focused && !!this.placeholder);
1040
+ }
1041
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteSelect, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1042
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.15", type: CuteSelect, isStandalone: true, selector: "cute-select", inputs: { userAriaDescribedBy: ["aria-describedby", "userAriaDescribedBy"], panelClass: "panelClass", disableRipple: ["disableRipple", "disableRipple", booleanAttribute], hideSingleSelectionIndicator: ["hideSingleSelectionIndicator", "hideSingleSelectionIndicator", booleanAttribute], placeholder: "placeholder", multiple: ["multiple", "multiple", booleanAttribute], disableOptionCentering: ["disableOptionCentering", "disableOptionCentering", booleanAttribute], compareWith: "compareWith", value: "value", errorStateMatcher: "errorStateMatcher", magnitude: "magnitude", typeaheadDebounceInterval: ["typeaheadDebounceInterval", "typeaheadDebounceInterval", numberAttribute], sortComparator: "sortComparator", panelWidth: "panelWidth", panelHeight: "panelHeight", canSelectNullableOptions: ["canSelectNullableOptions", "canSelectNullableOptions", booleanAttribute] }, outputs: { openedChange: "openedChange", _openedStream: "opened", _closedStream: "closed", selectionChange: "selectionChange", valueChange: "valueChange" }, host: { attributes: { "role": "combobox", "aria-autocomplete": "none", "aria-haspopup": "listbox", "ngSkipHydration": "" }, listeners: { "keydown": "_handleKeydown($event)", "focus": "_onFocus()", "blur": "_onBlur()" }, properties: { "class.active": "focused", "class.cute-select-disabled": "disabled", "class.cute-select-invalid": "errorState", "class.cute-select-required": "required", "class.cute-select-empty": "empty", "class.cute-select-multiple": "multiple", "attr.id": "id", "attr.tabindex": "-1", "attr.aria-controls": "panelOpen ? id + \"-panel\" : null", "attr.aria-expanded": "panelOpen", "attr.aria-label": "ariaLabel || null", "attr.aria-required": "required", "attr.aria-disabled": "disabled", "attr.aria-invalid": "errorState", "attr.aria-activedescendant": "_getAriaActiveDescendant()" }, classAttribute: "cute-select" }, providers: [
1043
+ { provide: CuteFormFieldControl, useExisting: CuteSelect },
1044
+ { provide: CUTE_OPTION_PARENT_COMPONENT, useExisting: CuteSelect },
1045
+ ], queries: [{ propertyName: "customTrigger", first: true, predicate: CUTE_SELECT_TRIGGER, descendants: true }, { propertyName: "options", predicate: CuteOption, descendants: true }, { propertyName: "optionGroups", predicate: CUTE_OPTGROUP, descendants: true }], viewQueries: [{ propertyName: "trigger", first: true, predicate: ["trigger"], descendants: true }, { propertyName: "panel", first: true, predicate: ["panel"], descendants: true }, { propertyName: "_overlayDir", first: true, predicate: CdkConnectedOverlay, descendants: true }], exportAs: ["cuteSelect"], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: "<div cdk-overlay-origin\r\n class=\"cute-select-trigger-wrapper\"\r\n [class.required]=\"required\"\r\n #fallbackOverlayOrigin=\"cdkOverlayOrigin\"\r\n>\r\n\r\n @if (!customTrigger) {\r\n <input #trigger\r\n class=\"form-select cute-select-trigger__input\"\r\n [class.form-select-sm]=\"magnitude=='small'\"\r\n [class.form-select-lg]=\"magnitude=='large'\"\r\n [attr.id]=\"inputId\"\r\n [attr.tabindex]=\"disabled ? -1 : tabIndex\"\r\n [disabled]=\"disabled\"\r\n [placeholder]=\"placeholder\"\r\n readonly\r\n [value]=\"triggerValue\"\r\n (click)=\"toggle()\"\r\n autocomplete=\"off\">\r\n } @else {\r\n <div #trigger\r\n class=\"form-select cute-select-trigger__custom\"\r\n [attr.tabindex]=\"disabled ? -1 : tabIndex\"\r\n [attr.id]=\"inputId\">\r\n <ng-content select=\"cute-select-trigger\"></ng-content>\r\n </div>\r\n }\r\n\r\n</div>\r\n\r\n<ng-template cdk-connected-overlay\r\n cdkConnectedOverlayHasBackdrop\r\n cdkConnectedOverlayBackdropClass=\"cdk-overlay-transparent-backdrop\"\r\n [cdkConnectedOverlayPanelClass]=\"_overlayPanelClass\"\r\n [cdkConnectedOverlayScrollStrategy]=\"_scrollStrategy\"\r\n [cdkConnectedOverlayOrigin]=\"_preferredOverlayOrigin || fallbackOverlayOrigin\"\r\n [cdkConnectedOverlayOpen]=\"panelOpen\"\r\n [cdkConnectedOverlayPositions]=\"_positions\"\r\n [cdkConnectedOverlayWidth]=\"_overlayWidth!\"\r\n (backdropClick)=\"close()\"\r\n (attach)=\"_onAttached()\"\r\n (detach)=\"close()\"> <!-- cdkConnectedOverlayLockPosition -->\r\n <div #panel\r\n role=\"listbox\"\r\n tabindex=\"-1\"\r\n class=\"cute-dropdown-overlay-content bg-body-tertiary shadow\"\r\n [style.max-height]=\"panelHeight || null\"\r\n [attr.id]=\"id + '-panel'\"\r\n [attr.aria-multiselectable]=\"multiple\"\r\n [attr.aria-label]=\"ariaLabel || null\"\r\n [attr.aria-labelledby]=\"_getPanelAriaLabelledby()\"\r\n [ngClass]=\"panelClass\"\r\n [@transformPanel]=\"'showing'\"\r\n (@transformPanel.done)=\"_panelDoneAnimatingStream.next($event.toState)\"\r\n (keydown)=\"_handleKeydown($event)\">\r\n <div class=\"cute-dropdown-content\">\r\n <ng-content></ng-content>\r\n </div>\r\n <!--<ng-template [cdkPortalOutlet]=\"_portal\"></ng-template>-->\r\n </div>\r\n</ng-template>\r\n\r\n", styles: [".cute-select{display:inline-block;width:100%}.cute-dropdown-overlay-content{display:block;width:100%;max-height:272px;overflow-y:auto;padding:var(--cute-select-padding-y, .5rem) 0;font-size:var(--bs-body-font-size);color:var(--bs-body-color);text-align:start;list-style:none;background-color:var(--bs-body-bg);border:var(--bs-border-width) solid var(--bs-border-color-translucent);border-radius:var(--bs-border-radius)}.cute-dropdown-overlay-content .cute-dropdown-content{overflow:auto;height:100%}.cute-dropdown-overlay-content .cute-dropdown-content .cute-option:hover:not(.disabled){background-color:var(--bs-secondary-bg)}.cute-select-trigger__input,.cute-select-trigger__custom{position:relative;cursor:pointer;-webkit-user-select:none;user-select:none}.cute-select-trigger__input:disabled,.cute-select-trigger__custom:disabled{cursor:auto;opacity:.65}cute-select-trigger{display:inline-block;-webkit-user-select:none;user-select:none}[dir=rtl] .form-select{padding:.375rem .75rem .375rem 2.25rem;background-position:left .75rem center}\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: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], animations: [cuteSelectAnimations.transformPanel], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
1046
+ }
1047
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteSelect, decorators: [{
1048
+ type: Component,
1049
+ args: [{ selector: 'cute-select', exportAs: 'cuteSelect', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, host: {
1050
+ 'class': 'cute-select',
1051
+ '[class.active]': 'focused',
1052
+ '[class.cute-select-disabled]': 'disabled',
1053
+ '[class.cute-select-invalid]': 'errorState',
1054
+ '[class.cute-select-required]': 'required',
1055
+ '[class.cute-select-empty]': 'empty',
1056
+ '[class.cute-select-multiple]': 'multiple',
1057
+ 'role': 'combobox',
1058
+ 'aria-autocomplete': 'none',
1059
+ 'aria-haspopup': 'listbox',
1060
+ '[attr.id]': 'id',
1061
+ '[attr.tabindex]': '-1', //'disabled ? -1 : tabIndex',
1062
+ '[attr.aria-controls]': 'panelOpen ? id + "-panel" : null',
1063
+ '[attr.aria-expanded]': 'panelOpen',
1064
+ '[attr.aria-label]': 'ariaLabel || null',
1065
+ '[attr.aria-required]': 'required',
1066
+ '[attr.aria-disabled]': 'disabled',
1067
+ '[attr.aria-invalid]': 'errorState',
1068
+ '[attr.aria-activedescendant]': '_getAriaActiveDescendant()',
1069
+ 'ngSkipHydration': '',
1070
+ '(keydown)': '_handleKeydown($event)',
1071
+ '(focus)': '_onFocus()',
1072
+ '(blur)': '_onBlur()',
1073
+ }, animations: [cuteSelectAnimations.transformPanel], providers: [
1074
+ { provide: CuteFormFieldControl, useExisting: CuteSelect },
1075
+ { provide: CUTE_OPTION_PARENT_COMPONENT, useExisting: CuteSelect },
1076
+ ], imports: [CdkOverlayOrigin, CdkConnectedOverlay, NgClass], template: "<div cdk-overlay-origin\r\n class=\"cute-select-trigger-wrapper\"\r\n [class.required]=\"required\"\r\n #fallbackOverlayOrigin=\"cdkOverlayOrigin\"\r\n>\r\n\r\n @if (!customTrigger) {\r\n <input #trigger\r\n class=\"form-select cute-select-trigger__input\"\r\n [class.form-select-sm]=\"magnitude=='small'\"\r\n [class.form-select-lg]=\"magnitude=='large'\"\r\n [attr.id]=\"inputId\"\r\n [attr.tabindex]=\"disabled ? -1 : tabIndex\"\r\n [disabled]=\"disabled\"\r\n [placeholder]=\"placeholder\"\r\n readonly\r\n [value]=\"triggerValue\"\r\n (click)=\"toggle()\"\r\n autocomplete=\"off\">\r\n } @else {\r\n <div #trigger\r\n class=\"form-select cute-select-trigger__custom\"\r\n [attr.tabindex]=\"disabled ? -1 : tabIndex\"\r\n [attr.id]=\"inputId\">\r\n <ng-content select=\"cute-select-trigger\"></ng-content>\r\n </div>\r\n }\r\n\r\n</div>\r\n\r\n<ng-template cdk-connected-overlay\r\n cdkConnectedOverlayHasBackdrop\r\n cdkConnectedOverlayBackdropClass=\"cdk-overlay-transparent-backdrop\"\r\n [cdkConnectedOverlayPanelClass]=\"_overlayPanelClass\"\r\n [cdkConnectedOverlayScrollStrategy]=\"_scrollStrategy\"\r\n [cdkConnectedOverlayOrigin]=\"_preferredOverlayOrigin || fallbackOverlayOrigin\"\r\n [cdkConnectedOverlayOpen]=\"panelOpen\"\r\n [cdkConnectedOverlayPositions]=\"_positions\"\r\n [cdkConnectedOverlayWidth]=\"_overlayWidth!\"\r\n (backdropClick)=\"close()\"\r\n (attach)=\"_onAttached()\"\r\n (detach)=\"close()\"> <!-- cdkConnectedOverlayLockPosition -->\r\n <div #panel\r\n role=\"listbox\"\r\n tabindex=\"-1\"\r\n class=\"cute-dropdown-overlay-content bg-body-tertiary shadow\"\r\n [style.max-height]=\"panelHeight || null\"\r\n [attr.id]=\"id + '-panel'\"\r\n [attr.aria-multiselectable]=\"multiple\"\r\n [attr.aria-label]=\"ariaLabel || null\"\r\n [attr.aria-labelledby]=\"_getPanelAriaLabelledby()\"\r\n [ngClass]=\"panelClass\"\r\n [@transformPanel]=\"'showing'\"\r\n (@transformPanel.done)=\"_panelDoneAnimatingStream.next($event.toState)\"\r\n (keydown)=\"_handleKeydown($event)\">\r\n <div class=\"cute-dropdown-content\">\r\n <ng-content></ng-content>\r\n </div>\r\n <!--<ng-template [cdkPortalOutlet]=\"_portal\"></ng-template>-->\r\n </div>\r\n</ng-template>\r\n\r\n", styles: [".cute-select{display:inline-block;width:100%}.cute-dropdown-overlay-content{display:block;width:100%;max-height:272px;overflow-y:auto;padding:var(--cute-select-padding-y, .5rem) 0;font-size:var(--bs-body-font-size);color:var(--bs-body-color);text-align:start;list-style:none;background-color:var(--bs-body-bg);border:var(--bs-border-width) solid var(--bs-border-color-translucent);border-radius:var(--bs-border-radius)}.cute-dropdown-overlay-content .cute-dropdown-content{overflow:auto;height:100%}.cute-dropdown-overlay-content .cute-dropdown-content .cute-option:hover:not(.disabled){background-color:var(--bs-secondary-bg)}.cute-select-trigger__input,.cute-select-trigger__custom{position:relative;cursor:pointer;-webkit-user-select:none;user-select:none}.cute-select-trigger__input:disabled,.cute-select-trigger__custom:disabled{cursor:auto;opacity:.65}cute-select-trigger{display:inline-block;-webkit-user-select:none;user-select:none}[dir=rtl] .form-select{padding:.375rem .75rem .375rem 2.25rem;background-position:left .75rem center}\n"] }]
1077
+ }], ctorParameters: () => [], propDecorators: { options: [{
1078
+ type: ContentChildren,
1079
+ args: [CuteOption, { descendants: true }]
1080
+ }], optionGroups: [{
1081
+ type: ContentChildren,
1082
+ args: [CUTE_OPTGROUP, { descendants: true }]
1083
+ }], customTrigger: [{
1084
+ type: ContentChild,
1085
+ args: [CUTE_SELECT_TRIGGER]
1086
+ }], trigger: [{
1087
+ type: ViewChild,
1088
+ args: ['trigger']
1089
+ }], panel: [{
1090
+ type: ViewChild,
1091
+ args: ['panel']
1092
+ }], _overlayDir: [{
1093
+ type: ViewChild,
1094
+ args: [CdkConnectedOverlay]
1095
+ }], userAriaDescribedBy: [{
1096
+ type: Input,
1097
+ args: ['aria-describedby']
1098
+ }], panelClass: [{
1099
+ type: Input
1100
+ }], disableRipple: [{
1101
+ type: Input,
1102
+ args: [{ transform: booleanAttribute }]
1103
+ }], hideSingleSelectionIndicator: [{
1104
+ type: Input,
1105
+ args: [{ transform: booleanAttribute }]
1106
+ }], placeholder: [{
1107
+ type: Input
1108
+ }], multiple: [{
1109
+ type: Input,
1110
+ args: [{ transform: booleanAttribute }]
1111
+ }], disableOptionCentering: [{
1112
+ type: Input,
1113
+ args: [{ transform: booleanAttribute }]
1114
+ }], compareWith: [{
1115
+ type: Input
1116
+ }], value: [{
1117
+ type: Input
1118
+ }], errorStateMatcher: [{
1119
+ type: Input
1120
+ }], magnitude: [{
1121
+ type: Input
1122
+ }], typeaheadDebounceInterval: [{
1123
+ type: Input,
1124
+ args: [{ transform: numberAttribute }]
1125
+ }], sortComparator: [{
1126
+ type: Input
1127
+ }], panelWidth: [{
1128
+ type: Input
1129
+ }], panelHeight: [{
1130
+ type: Input
1131
+ }], canSelectNullableOptions: [{
1132
+ type: Input,
1133
+ args: [{ transform: booleanAttribute }]
1134
+ }], openedChange: [{
1135
+ type: Output
1136
+ }], _openedStream: [{
1137
+ type: Output,
1138
+ args: ['opened']
1139
+ }], _closedStream: [{
1140
+ type: Output,
1141
+ args: ['closed']
1142
+ }], selectionChange: [{
1143
+ type: Output
1144
+ }], valueChange: [{
1145
+ type: Output
1146
+ }] } });
1147
+ /**
1148
+ * Allows the user to customize the trigger that is displayed when the select has a value.
1149
+ */
1150
+ class CuteSelectTrigger {
1151
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteSelectTrigger, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
1152
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.15", type: CuteSelectTrigger, isStandalone: true, selector: "cute-select-trigger", providers: [{ provide: CUTE_SELECT_TRIGGER, useExisting: CuteSelectTrigger }], ngImport: i0 }); }
1153
+ }
1154
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteSelectTrigger, decorators: [{
1155
+ type: Directive,
1156
+ args: [{
1157
+ selector: 'cute-select-trigger',
1158
+ providers: [{ provide: CUTE_SELECT_TRIGGER, useExisting: CuteSelectTrigger }],
1159
+ standalone: true,
1160
+ }]
1161
+ }] });
1162
+
1163
+ /**
1164
+ * @license Apache-2.0
1165
+ *
1166
+ * Copyright (c) 2025 CuteWidgets Team. All Rights Reserved.
1167
+ *
1168
+ * You may not use this file except in compliance with the License
1169
+ * that can be found at http://www.apache.org/licenses/LICENSE-2.0
1170
+ */
1171
+ const TYPES = [
1172
+ CuteSelect,
1173
+ CuteSelectTrigger,
1174
+ CuteOptgroup,
1175
+ CuteOption,
1176
+ ];
1177
+ class CuteSelectModule {
1178
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteSelectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
1179
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.15", ngImport: i0, type: CuteSelectModule, imports: [CommonModule, CuteSelect,
1180
+ CuteSelectTrigger,
1181
+ CuteOptgroup,
1182
+ CuteOption], exports: [CuteSelect,
1183
+ CuteSelectTrigger,
1184
+ CuteOptgroup,
1185
+ CuteOption] }); }
1186
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteSelectModule, providers: [
1187
+ CUTE_SELECT_SCROLL_STRATEGY_PROVIDER
1188
+ ], imports: [CommonModule, CuteOptgroup,
1189
+ CuteOption] }); }
1190
+ }
1191
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteSelectModule, decorators: [{
1192
+ type: NgModule,
1193
+ args: [{
1194
+ imports: [CommonModule, ...TYPES],
1195
+ exports: TYPES,
1196
+ providers: [
1197
+ CUTE_SELECT_SCROLL_STRATEGY_PROVIDER
1198
+ ],
1199
+ declarations: [],
1200
+ }]
1201
+ }] });
1202
+
1203
+ /**
1204
+ * Generated bundle index. Do not edit.
1205
+ */
1206
+
1207
+ export { CUTE_SELECT_CONFIG, CUTE_SELECT_SCROLL_STRATEGY, CUTE_SELECT_SCROLL_STRATEGY_PROVIDER, CUTE_SELECT_SCROLL_STRATEGY_PROVIDER_FACTORY, CUTE_SELECT_TRIGGER, CuteSelect, CuteSelectChange, CuteSelectModule, CuteSelectTrigger, cuteSelectAnimations };
1208
+ //# sourceMappingURL=cute-widgets-base-select.mjs.map