@angular/cdk 21.0.0-next.9 → 21.0.0-rc.0

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 (123) hide show
  1. package/_adev_assets/cdk_drag_drop.json +13 -12
  2. package/_adev_assets/cdk_testing.json +9 -9
  3. package/_adev_assets/cdk_testing_protractor.json +1 -1
  4. package/_adev_assets/cdk_testing_selenium_webdriver.json +1 -1
  5. package/_adev_assets/cdk_testing_testbed.json +1 -1
  6. package/fesm2022/_a11y-module-chunk.mjs +755 -869
  7. package/fesm2022/_a11y-module-chunk.mjs.map +1 -1
  8. package/fesm2022/_activedescendant-key-manager-chunk.mjs +8 -8
  9. package/fesm2022/_activedescendant-key-manager-chunk.mjs.map +1 -1
  10. package/fesm2022/_array-chunk.mjs +1 -1
  11. package/fesm2022/_array-chunk.mjs.map +1 -1
  12. package/fesm2022/_breakpoints-observer-chunk.mjs +149 -152
  13. package/fesm2022/_breakpoints-observer-chunk.mjs.map +1 -1
  14. package/fesm2022/_css-pixel-value-chunk.mjs +4 -5
  15. package/fesm2022/_css-pixel-value-chunk.mjs.map +1 -1
  16. package/fesm2022/_data-source-chunk.mjs +2 -8
  17. package/fesm2022/_data-source-chunk.mjs.map +1 -1
  18. package/fesm2022/_directionality-chunk.mjs +54 -54
  19. package/fesm2022/_directionality-chunk.mjs.map +1 -1
  20. package/fesm2022/_dispose-view-repeater-strategy-chunk.mjs +25 -36
  21. package/fesm2022/_dispose-view-repeater-strategy-chunk.mjs.map +1 -1
  22. package/fesm2022/_element-chunk.mjs +6 -17
  23. package/fesm2022/_element-chunk.mjs.map +1 -1
  24. package/fesm2022/_fake-event-detection-chunk.mjs +3 -17
  25. package/fesm2022/_fake-event-detection-chunk.mjs.map +1 -1
  26. package/fesm2022/_focus-key-manager-chunk.mjs +10 -14
  27. package/fesm2022/_focus-key-manager-chunk.mjs.map +1 -1
  28. package/fesm2022/_focus-monitor-chunk.mjs +376 -566
  29. package/fesm2022/_focus-monitor-chunk.mjs.map +1 -1
  30. package/fesm2022/_id-generator-chunk.mjs +36 -27
  31. package/fesm2022/_id-generator-chunk.mjs.map +1 -1
  32. package/fesm2022/_keycodes-chunk.mjs +9 -9
  33. package/fesm2022/_keycodes-chunk.mjs.map +1 -1
  34. package/fesm2022/_list-key-manager-chunk.mjs +248 -336
  35. package/fesm2022/_list-key-manager-chunk.mjs.map +1 -1
  36. package/fesm2022/_overlay-module-chunk.mjs +2534 -2948
  37. package/fesm2022/_overlay-module-chunk.mjs.map +1 -1
  38. package/fesm2022/_passive-listeners-chunk.mjs +10 -22
  39. package/fesm2022/_passive-listeners-chunk.mjs.map +1 -1
  40. package/fesm2022/_platform-chunk.mjs +42 -65
  41. package/fesm2022/_platform-chunk.mjs.map +1 -1
  42. package/fesm2022/_recycle-view-repeater-strategy-chunk.mjs +78 -134
  43. package/fesm2022/_recycle-view-repeater-strategy-chunk.mjs.map +1 -1
  44. package/fesm2022/_scrolling-chunk.mjs +44 -85
  45. package/fesm2022/_scrolling-chunk.mjs.map +1 -1
  46. package/fesm2022/_selection-model-chunk.mjs +138 -209
  47. package/fesm2022/_selection-model-chunk.mjs.map +1 -1
  48. package/fesm2022/_shadow-dom-chunk.mjs +21 -35
  49. package/fesm2022/_shadow-dom-chunk.mjs.map +1 -1
  50. package/fesm2022/_style-loader-chunk.mjs +50 -37
  51. package/fesm2022/_style-loader-chunk.mjs.map +1 -1
  52. package/fesm2022/_test-environment-chunk.mjs +2 -14
  53. package/fesm2022/_test-environment-chunk.mjs.map +1 -1
  54. package/fesm2022/_tree-key-manager-chunk.mjs +229 -308
  55. package/fesm2022/_tree-key-manager-chunk.mjs.map +1 -1
  56. package/fesm2022/_typeahead-chunk.mjs +52 -74
  57. package/fesm2022/_typeahead-chunk.mjs.map +1 -1
  58. package/fesm2022/_unique-selection-dispatcher-chunk.mjs +43 -40
  59. package/fesm2022/_unique-selection-dispatcher-chunk.mjs.map +1 -1
  60. package/fesm2022/a11y.mjs +351 -449
  61. package/fesm2022/a11y.mjs.map +1 -1
  62. package/fesm2022/accordion.mjs +254 -192
  63. package/fesm2022/accordion.mjs.map +1 -1
  64. package/fesm2022/bidi.mjs +121 -64
  65. package/fesm2022/bidi.mjs.map +1 -1
  66. package/fesm2022/cdk.mjs +1 -2
  67. package/fesm2022/cdk.mjs.map +1 -1
  68. package/fesm2022/clipboard.mjs +208 -186
  69. package/fesm2022/clipboard.mjs.map +1 -1
  70. package/fesm2022/coercion-private.mjs +4 -8
  71. package/fesm2022/coercion-private.mjs.map +1 -1
  72. package/fesm2022/coercion.mjs +11 -29
  73. package/fesm2022/coercion.mjs.map +1 -1
  74. package/fesm2022/dialog.mjs +660 -808
  75. package/fesm2022/dialog.mjs.map +1 -1
  76. package/fesm2022/drag-drop.mjs +3347 -4286
  77. package/fesm2022/drag-drop.mjs.map +1 -1
  78. package/fesm2022/keycodes.mjs +4 -8
  79. package/fesm2022/keycodes.mjs.map +1 -1
  80. package/fesm2022/layout.mjs +44 -26
  81. package/fesm2022/layout.mjs.map +1 -1
  82. package/fesm2022/listbox.mjs +841 -895
  83. package/fesm2022/listbox.mjs.map +1 -1
  84. package/fesm2022/menu.mjs +1942 -1858
  85. package/fesm2022/menu.mjs.map +1 -1
  86. package/fesm2022/observers-private.mjs +88 -106
  87. package/fesm2022/observers-private.mjs.map +1 -1
  88. package/fesm2022/observers.mjs +262 -184
  89. package/fesm2022/observers.mjs.map +1 -1
  90. package/fesm2022/overlay.mjs +72 -68
  91. package/fesm2022/overlay.mjs.map +1 -1
  92. package/fesm2022/platform.mjs +43 -54
  93. package/fesm2022/platform.mjs.map +1 -1
  94. package/fesm2022/portal.mjs +402 -560
  95. package/fesm2022/portal.mjs.map +1 -1
  96. package/fesm2022/private.mjs +38 -10
  97. package/fesm2022/private.mjs.map +1 -1
  98. package/fesm2022/scrolling.mjs +1323 -1400
  99. package/fesm2022/scrolling.mjs.map +1 -1
  100. package/fesm2022/stepper.mjs +758 -590
  101. package/fesm2022/stepper.mjs.map +1 -1
  102. package/fesm2022/table.mjs +2327 -2319
  103. package/fesm2022/table.mjs.map +1 -1
  104. package/fesm2022/testing-selenium-webdriver.mjs +252 -325
  105. package/fesm2022/testing-selenium-webdriver.mjs.map +1 -1
  106. package/fesm2022/testing-testbed.mjs +592 -709
  107. package/fesm2022/testing-testbed.mjs.map +1 -1
  108. package/fesm2022/testing.mjs +368 -889
  109. package/fesm2022/testing.mjs.map +1 -1
  110. package/fesm2022/text-field.mjs +459 -388
  111. package/fesm2022/text-field.mjs.map +1 -1
  112. package/fesm2022/tree.mjs +1483 -1731
  113. package/fesm2022/tree.mjs.map +1 -1
  114. package/overlay/_index.scss +28 -0
  115. package/overlay-prebuilt.css +1 -1
  116. package/package.json +1 -1
  117. package/schematics/ng-add/index.js +1 -1
  118. package/types/_overlay-module-chunk.d.ts +59 -7
  119. package/types/_portal-directives-chunk.d.ts +2 -18
  120. package/types/accordion.d.ts +3 -1
  121. package/types/dialog.d.ts +1 -1
  122. package/types/overlay.d.ts +6 -2
  123. package/types/portal.d.ts +1 -1
@@ -15,914 +15,860 @@ import './_list-key-manager-chunk.mjs';
15
15
  import './_typeahead-chunk.mjs';
16
16
  import '@angular/common';
17
17
 
18
- /**
19
- * An implementation of SelectionModel that internally always represents the selection as a
20
- * multi-selection. This is necessary so that we can recover the full selection if the user
21
- * switches the listbox from single-selection to multi-selection after initialization.
22
- *
23
- * This selection model may report multiple selected values, even if it is in single-selection
24
- * mode. It is up to the user (CdkListbox) to check for invalid selections.
25
- */
26
18
  class ListboxSelectionModel extends SelectionModel {
27
- multiple;
28
- constructor(multiple = false, initiallySelectedValues, emitChanges = true, compareWith) {
29
- super(true, initiallySelectedValues, emitChanges, compareWith);
30
- this.multiple = multiple;
31
- }
32
- isMultipleSelection() {
33
- return this.multiple;
34
- }
35
- select(...values) {
36
- // The super class is always in multi-selection mode, so we need to override the behavior if
37
- // this selection model actually belongs to a single-selection listbox.
38
- if (this.multiple) {
39
- return super.select(...values);
40
- }
41
- else {
42
- return super.setSelection(...values);
43
- }
44
- }
19
+ multiple;
20
+ constructor(multiple = false, initiallySelectedValues, emitChanges = true, compareWith) {
21
+ super(true, initiallySelectedValues, emitChanges, compareWith);
22
+ this.multiple = multiple;
23
+ }
24
+ isMultipleSelection() {
25
+ return this.multiple;
26
+ }
27
+ select(...values) {
28
+ if (this.multiple) {
29
+ return super.select(...values);
30
+ } else {
31
+ return super.setSelection(...values);
32
+ }
33
+ }
45
34
  }
46
- /** A selectable option in a listbox. */
47
35
  class CdkOption {
48
- /** The id of the option's host element. */
49
- get id() {
50
- return this._id || this._generatedId;
51
- }
52
- set id(value) {
53
- this._id = value;
54
- }
55
- _id;
56
- _generatedId = inject(_IdGenerator).getId('cdk-option-');
57
- /** The value of this option. */
58
- value;
59
- /**
60
- * The text used to locate this item during listbox typeahead. If not specified,
61
- * the `textContent` of the item will be used.
62
- */
63
- typeaheadLabel;
64
- /** Whether this option is disabled. */
65
- get disabled() {
66
- return this.listbox.disabled || this._disabled();
67
- }
68
- set disabled(value) {
69
- this._disabled.set(value);
70
- }
71
- _disabled = signal(false, ...(ngDevMode ? [{ debugName: "_disabled" }] : []));
72
- /** The tabindex of the option when it is enabled. */
73
- get enabledTabIndex() {
74
- return this._enabledTabIndex() === undefined
75
- ? this.listbox.enabledTabIndex
76
- : this._enabledTabIndex();
77
- }
78
- set enabledTabIndex(value) {
79
- this._enabledTabIndex.set(value);
80
- }
81
- _enabledTabIndex = signal(undefined, ...(ngDevMode ? [{ debugName: "_enabledTabIndex" }] : []));
82
- /** The option's host element */
83
- element = inject(ElementRef).nativeElement;
84
- /** The parent listbox this option belongs to. */
85
- listbox = inject(CdkListbox);
86
- /** Emits when the option is destroyed. */
87
- destroyed = new Subject();
88
- /** Emits when the option is clicked. */
89
- _clicked = new Subject();
90
- ngOnDestroy() {
91
- this.destroyed.next();
92
- this.destroyed.complete();
93
- }
94
- /** Whether this option is selected. */
95
- isSelected() {
96
- return this.listbox.isSelected(this);
97
- }
98
- /** Whether this option is active. */
99
- isActive() {
100
- return this.listbox.isActive(this);
101
- }
102
- /** Toggle the selected state of this option. */
103
- toggle() {
104
- this.listbox.toggle(this);
105
- }
106
- /** Select this option if it is not selected. */
107
- select() {
108
- this.listbox.select(this);
109
- }
110
- /** Deselect this option if it is selected. */
111
- deselect() {
112
- this.listbox.deselect(this);
113
- }
114
- /** Focus this option. */
115
- focus() {
116
- this.element.focus();
117
- }
118
- /** Get the label for this element which is required by the FocusableOption interface. */
119
- getLabel() {
120
- return (this.typeaheadLabel ?? this.element.textContent?.trim()) || '';
121
- }
122
- /**
123
- * No-op implemented as a part of `Highlightable`.
124
- * @docs-private
125
- */
126
- setActiveStyles() {
127
- // If the listbox is using `aria-activedescendant` the option won't have focus so the
128
- // browser won't scroll them into view automatically so we need to do it ourselves.
129
- if (this.listbox.useActiveDescendant) {
130
- this.element.scrollIntoView({ block: 'nearest', inline: 'nearest' });
131
- }
132
- }
133
- /**
134
- * No-op implemented as a part of `Highlightable`.
135
- * @docs-private
136
- */
137
- setInactiveStyles() { }
138
- /** Handle focus events on the option. */
139
- _handleFocus() {
140
- // Options can wind up getting focused in active descendant mode if the user clicks on them.
141
- // In this case, we push focus back to the parent listbox to prevent an extra tab stop when
142
- // the user performs a shift+tab.
143
- if (this.listbox.useActiveDescendant) {
144
- this.listbox._setActiveOption(this);
145
- this.listbox.focus();
146
- }
147
- }
148
- /** Get the tabindex for this option. */
149
- _getTabIndex() {
150
- if (this.listbox.useActiveDescendant || this.disabled) {
151
- return -1;
152
- }
153
- return this.isActive() ? this.enabledTabIndex : -1;
154
- }
155
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.0-next.2", ngImport: i0, type: CdkOption, deps: [], target: i0.ɵɵFactoryTarget.Directive });
156
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "16.1.0", version: "20.2.0-next.2", type: CdkOption, isStandalone: true, selector: "[cdkOption]", inputs: { id: "id", value: ["cdkOption", "value"], typeaheadLabel: ["cdkOptionTypeaheadLabel", "typeaheadLabel"], disabled: ["cdkOptionDisabled", "disabled", booleanAttribute], enabledTabIndex: ["tabindex", "enabledTabIndex", (value) => (value == null ? undefined : numberAttribute(value))] }, host: { attributes: { "role": "option" }, listeners: { "click": "_clicked.next($event)", "focus": "_handleFocus()" }, properties: { "id": "id", "attr.aria-selected": "isSelected()", "attr.tabindex": "_getTabIndex()", "attr.aria-disabled": "disabled", "class.cdk-option-active": "isActive()" }, classAttribute: "cdk-option" }, exportAs: ["cdkOption"], ngImport: i0 });
36
+ get id() {
37
+ return this._id || this._generatedId;
38
+ }
39
+ set id(value) {
40
+ this._id = value;
41
+ }
42
+ _id;
43
+ _generatedId = inject(_IdGenerator).getId('cdk-option-');
44
+ value;
45
+ typeaheadLabel;
46
+ get disabled() {
47
+ return this.listbox.disabled || this._disabled();
48
+ }
49
+ set disabled(value) {
50
+ this._disabled.set(value);
51
+ }
52
+ _disabled = signal(false, ...(ngDevMode ? [{
53
+ debugName: "_disabled"
54
+ }] : []));
55
+ get enabledTabIndex() {
56
+ return this._enabledTabIndex() === undefined ? this.listbox.enabledTabIndex : this._enabledTabIndex();
57
+ }
58
+ set enabledTabIndex(value) {
59
+ this._enabledTabIndex.set(value);
60
+ }
61
+ _enabledTabIndex = signal(undefined, ...(ngDevMode ? [{
62
+ debugName: "_enabledTabIndex"
63
+ }] : []));
64
+ element = inject(ElementRef).nativeElement;
65
+ listbox = inject(CdkListbox);
66
+ destroyed = new Subject();
67
+ _clicked = new Subject();
68
+ ngOnDestroy() {
69
+ this.destroyed.next();
70
+ this.destroyed.complete();
71
+ }
72
+ isSelected() {
73
+ return this.listbox.isSelected(this);
74
+ }
75
+ isActive() {
76
+ return this.listbox.isActive(this);
77
+ }
78
+ toggle() {
79
+ this.listbox.toggle(this);
80
+ }
81
+ select() {
82
+ this.listbox.select(this);
83
+ }
84
+ deselect() {
85
+ this.listbox.deselect(this);
86
+ }
87
+ focus() {
88
+ this.element.focus();
89
+ }
90
+ getLabel() {
91
+ return (this.typeaheadLabel ?? this.element.textContent?.trim()) || '';
92
+ }
93
+ setActiveStyles() {
94
+ if (this.listbox.useActiveDescendant) {
95
+ this.element.scrollIntoView({
96
+ block: 'nearest',
97
+ inline: 'nearest'
98
+ });
99
+ }
100
+ }
101
+ setInactiveStyles() {}
102
+ _handleFocus() {
103
+ if (this.listbox.useActiveDescendant) {
104
+ this.listbox._setActiveOption(this);
105
+ this.listbox.focus();
106
+ }
107
+ }
108
+ _getTabIndex() {
109
+ if (this.listbox.useActiveDescendant || this.disabled) {
110
+ return -1;
111
+ }
112
+ return this.isActive() ? this.enabledTabIndex : -1;
113
+ }
114
+ static ɵfac = i0.ɵɵngDeclareFactory({
115
+ minVersion: "12.0.0",
116
+ version: "20.2.0-next.2",
117
+ ngImport: i0,
118
+ type: CdkOption,
119
+ deps: [],
120
+ target: i0.ɵɵFactoryTarget.Directive
121
+ });
122
+ static ɵdir = i0.ɵɵngDeclareDirective({
123
+ minVersion: "16.1.0",
124
+ version: "20.2.0-next.2",
125
+ type: CdkOption,
126
+ isStandalone: true,
127
+ selector: "[cdkOption]",
128
+ inputs: {
129
+ id: "id",
130
+ value: ["cdkOption", "value"],
131
+ typeaheadLabel: ["cdkOptionTypeaheadLabel", "typeaheadLabel"],
132
+ disabled: ["cdkOptionDisabled", "disabled", booleanAttribute],
133
+ enabledTabIndex: ["tabindex", "enabledTabIndex", value => value == null ? undefined : numberAttribute(value)]
134
+ },
135
+ host: {
136
+ attributes: {
137
+ "role": "option"
138
+ },
139
+ listeners: {
140
+ "click": "_clicked.next($event)",
141
+ "focus": "_handleFocus()"
142
+ },
143
+ properties: {
144
+ "id": "id",
145
+ "attr.aria-selected": "isSelected()",
146
+ "attr.tabindex": "_getTabIndex()",
147
+ "attr.aria-disabled": "disabled",
148
+ "class.cdk-option-active": "isActive()"
149
+ },
150
+ classAttribute: "cdk-option"
151
+ },
152
+ exportAs: ["cdkOption"],
153
+ ngImport: i0
154
+ });
157
155
  }
158
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.0-next.2", ngImport: i0, type: CdkOption, decorators: [{
159
- type: Directive,
160
- args: [{
161
- selector: '[cdkOption]',
162
- exportAs: 'cdkOption',
163
- host: {
164
- 'role': 'option',
165
- 'class': 'cdk-option',
166
- '[id]': 'id',
167
- '[attr.aria-selected]': 'isSelected()',
168
- '[attr.tabindex]': '_getTabIndex()',
169
- '[attr.aria-disabled]': 'disabled',
170
- '[class.cdk-option-active]': 'isActive()',
171
- '(click)': '_clicked.next($event)',
172
- '(focus)': '_handleFocus()',
173
- },
174
- }]
175
- }], propDecorators: { id: [{
176
- type: Input
177
- }], value: [{
178
- type: Input,
179
- args: ['cdkOption']
180
- }], typeaheadLabel: [{
181
- type: Input,
182
- args: ['cdkOptionTypeaheadLabel']
183
- }], disabled: [{
184
- type: Input,
185
- args: [{ alias: 'cdkOptionDisabled', transform: booleanAttribute }]
186
- }], enabledTabIndex: [{
187
- type: Input,
188
- args: [{
189
- alias: 'tabindex',
190
- transform: (value) => (value == null ? undefined : numberAttribute(value)),
191
- }]
192
- }] } });
156
+ i0.ɵɵngDeclareClassMetadata({
157
+ minVersion: "12.0.0",
158
+ version: "20.2.0-next.2",
159
+ ngImport: i0,
160
+ type: CdkOption,
161
+ decorators: [{
162
+ type: Directive,
163
+ args: [{
164
+ selector: '[cdkOption]',
165
+ exportAs: 'cdkOption',
166
+ host: {
167
+ 'role': 'option',
168
+ 'class': 'cdk-option',
169
+ '[id]': 'id',
170
+ '[attr.aria-selected]': 'isSelected()',
171
+ '[attr.tabindex]': '_getTabIndex()',
172
+ '[attr.aria-disabled]': 'disabled',
173
+ '[class.cdk-option-active]': 'isActive()',
174
+ '(click)': '_clicked.next($event)',
175
+ '(focus)': '_handleFocus()'
176
+ }
177
+ }]
178
+ }],
179
+ propDecorators: {
180
+ id: [{
181
+ type: Input
182
+ }],
183
+ value: [{
184
+ type: Input,
185
+ args: ['cdkOption']
186
+ }],
187
+ typeaheadLabel: [{
188
+ type: Input,
189
+ args: ['cdkOptionTypeaheadLabel']
190
+ }],
191
+ disabled: [{
192
+ type: Input,
193
+ args: [{
194
+ alias: 'cdkOptionDisabled',
195
+ transform: booleanAttribute
196
+ }]
197
+ }],
198
+ enabledTabIndex: [{
199
+ type: Input,
200
+ args: [{
201
+ alias: 'tabindex',
202
+ transform: value => value == null ? undefined : numberAttribute(value)
203
+ }]
204
+ }]
205
+ }
206
+ });
193
207
  class CdkListbox {
194
- _cleanupWindowBlur;
195
- /** The id of the option's host element. */
196
- get id() {
197
- return this._id || this._generatedId;
198
- }
199
- set id(value) {
200
- this._id = value;
201
- }
202
- _id;
203
- _generatedId = inject(_IdGenerator).getId('cdk-listbox-');
204
- /** The tabindex to use when the listbox is enabled. */
205
- get enabledTabIndex() {
206
- return this._enabledTabIndex() === undefined ? 0 : this._enabledTabIndex();
207
- }
208
- set enabledTabIndex(value) {
209
- this._enabledTabIndex.set(value);
210
- }
211
- _enabledTabIndex = signal(undefined, ...(ngDevMode ? [{ debugName: "_enabledTabIndex" }] : []));
212
- /** The value selected in the listbox, represented as an array of option values. */
213
- get value() {
214
- return this._invalid ? [] : this.selectionModel.selected;
215
- }
216
- set value(value) {
217
- this._setSelection(value);
218
- }
219
- /**
220
- * Whether the listbox allows multiple options to be selected. If the value switches from `true`
221
- * to `false`, and more than one option is selected, all options are deselected.
222
- */
223
- get multiple() {
224
- return this.selectionModel.multiple;
225
- }
226
- set multiple(value) {
227
- this.selectionModel.multiple = value;
228
- if (this.options) {
229
- this._updateInternalValue();
230
- }
231
- }
232
- /** Whether the listbox is disabled. */
233
- get disabled() {
234
- return this._disabled();
235
- }
236
- set disabled(value) {
237
- this._disabled.set(value);
238
- }
239
- _disabled = signal(false, ...(ngDevMode ? [{ debugName: "_disabled" }] : []));
240
- /** Whether the listbox will use active descendant or will move focus onto the options. */
241
- get useActiveDescendant() {
242
- return this._useActiveDescendant();
243
- }
244
- set useActiveDescendant(value) {
245
- this._useActiveDescendant.set(value);
246
- }
247
- _useActiveDescendant = signal(false, ...(ngDevMode ? [{ debugName: "_useActiveDescendant" }] : []));
248
- /** The orientation of the listbox. Only affects keyboard interaction, not visual layout. */
249
- get orientation() {
250
- return this._orientation;
251
- }
252
- set orientation(value) {
253
- this._orientation = value === 'horizontal' ? 'horizontal' : 'vertical';
254
- if (value === 'horizontal') {
255
- this.listKeyManager?.withHorizontalOrientation(this._dir?.value || 'ltr');
256
- }
257
- else {
258
- this.listKeyManager?.withVerticalOrientation();
259
- }
260
- }
261
- _orientation = 'vertical';
262
- /** The function used to compare option values. */
263
- get compareWith() {
264
- return this.selectionModel.compareWith;
265
- }
266
- set compareWith(fn) {
267
- this.selectionModel.compareWith = fn;
268
- }
269
- /**
270
- * Whether the keyboard navigation should wrap when the user presses arrow down on the last item
271
- * or arrow up on the first item.
272
- */
273
- get navigationWrapDisabled() {
274
- return this._navigationWrapDisabled;
275
- }
276
- set navigationWrapDisabled(wrap) {
277
- this._navigationWrapDisabled = wrap;
278
- this.listKeyManager?.withWrap(!this._navigationWrapDisabled);
279
- }
280
- _navigationWrapDisabled = false;
281
- /** Whether keyboard navigation should skip over disabled items. */
282
- get navigateDisabledOptions() {
283
- return this._navigateDisabledOptions;
284
- }
285
- set navigateDisabledOptions(skip) {
286
- this._navigateDisabledOptions = skip;
287
- this.listKeyManager?.skipPredicate(this._navigateDisabledOptions ? this._skipNonePredicate : this._skipDisabledPredicate);
288
- }
289
- _navigateDisabledOptions = false;
290
- /** Emits when the selected value(s) in the listbox change. */
291
- valueChange = new Subject();
292
- /** The child options in this listbox. */
293
- options;
294
- /** The selection model used by the listbox. */
295
- selectionModel = new ListboxSelectionModel();
296
- /** The key manager that manages keyboard navigation for this listbox. */
297
- listKeyManager;
298
- /** Emits when the listbox is destroyed. */
299
- destroyed = new Subject();
300
- /** The host element of the listbox. */
301
- element = inject(ElementRef).nativeElement;
302
- /** The Angular zone. */
303
- ngZone = inject(NgZone);
304
- /** The change detector for this listbox. */
305
- changeDetectorRef = inject(ChangeDetectorRef);
306
- /** Whether the currently selected value in the selection model is invalid. */
307
- _invalid = false;
308
- /** The last user-triggered option. */
309
- _lastTriggered = null;
310
- /** Callback called when the listbox has been touched */
311
- _onTouched = () => { };
312
- /** Callback called when the listbox value changes */
313
- _onChange = () => { };
314
- /** Emits when an option has been clicked. */
315
- _optionClicked = defer(() => this.options.changes.pipe(startWith(this.options), switchMap(options => merge(...options.map(option => option._clicked.pipe(map(event => ({ option, event }))))))));
316
- /** The directionality of the page. */
317
- _dir = inject(Directionality, { optional: true });
318
- /** Whether the component is being rendered in the browser. */
319
- _isBrowser = inject(Platform).isBrowser;
320
- /** A predicate that skips disabled options. */
321
- _skipDisabledPredicate = (option) => option.disabled;
322
- /** A predicate that does not skip any options. */
323
- _skipNonePredicate = () => false;
324
- /** Whether the listbox currently has focus. */
325
- _hasFocus = false;
326
- /** A reference to the option that was active before the listbox lost focus. */
327
- _previousActiveOption = null;
328
- constructor() {
329
- if (this._isBrowser) {
330
- const renderer = inject(Renderer2);
331
- this._cleanupWindowBlur = this.ngZone.runOutsideAngular(() => {
332
- return renderer.listen('window', 'blur', () => {
333
- if (this.element.contains(document.activeElement) && this._previousActiveOption) {
334
- this._setActiveOption(this._previousActiveOption);
335
- this._previousActiveOption = null;
336
- }
337
- });
338
- });
339
- }
340
- }
341
- ngAfterContentInit() {
342
- if (typeof ngDevMode === 'undefined' || ngDevMode) {
343
- this._verifyNoOptionValueCollisions();
344
- this._verifyOptionValues();
345
- }
346
- this._initKeyManager();
347
- // Update the internal value whenever the options or the model value changes.
348
- merge(this.selectionModel.changed, this.options.changes)
349
- .pipe(startWith(null), takeUntil(this.destroyed))
350
- .subscribe(() => this._updateInternalValue());
351
- this._optionClicked
352
- .pipe(filter(({ option }) => !option.disabled), takeUntil(this.destroyed))
353
- .subscribe(({ option, event }) => this._handleOptionClicked(option, event));
354
- }
355
- ngOnDestroy() {
356
- this._cleanupWindowBlur?.();
357
- this.listKeyManager?.destroy();
358
- this.destroyed.next();
359
- this.destroyed.complete();
360
- }
361
- /**
362
- * Toggle the selected state of the given option.
363
- * @param option The option to toggle
364
- */
365
- toggle(option) {
366
- this.toggleValue(option.value);
367
- }
368
- /**
369
- * Toggle the selected state of the given value.
370
- * @param value The value to toggle
371
- */
372
- toggleValue(value) {
373
- if (this._invalid) {
374
- this.selectionModel.clear(false);
375
- }
376
- this.selectionModel.toggle(value);
377
- }
378
- /**
379
- * Select the given option.
380
- * @param option The option to select
381
- */
382
- select(option) {
383
- this.selectValue(option.value);
384
- }
385
- /**
386
- * Select the given value.
387
- * @param value The value to select
388
- */
389
- selectValue(value) {
390
- if (this._invalid) {
391
- this.selectionModel.clear(false);
392
- }
393
- this.selectionModel.select(value);
394
- }
395
- /**
396
- * Deselect the given option.
397
- * @param option The option to deselect
398
- */
399
- deselect(option) {
400
- this.deselectValue(option.value);
401
- }
402
- /**
403
- * Deselect the given value.
404
- * @param value The value to deselect
405
- */
406
- deselectValue(value) {
407
- if (this._invalid) {
408
- this.selectionModel.clear(false);
409
- }
410
- this.selectionModel.deselect(value);
411
- }
412
- /**
413
- * Set the selected state of all options.
414
- * @param isSelected The new selected state to set
415
- */
416
- setAllSelected(isSelected) {
417
- if (!isSelected) {
418
- this.selectionModel.clear();
419
- }
420
- else {
421
- if (this._invalid) {
422
- this.selectionModel.clear(false);
423
- }
424
- this.selectionModel.select(...this.options.map(option => option.value));
425
- }
426
- }
427
- /**
428
- * Get whether the given option is selected.
429
- * @param option The option to get the selected state of
430
- */
431
- isSelected(option) {
432
- return this.isValueSelected(option.value);
433
- }
434
- /**
435
- * Get whether the given option is active.
436
- * @param option The option to get the active state of
437
- */
438
- isActive(option) {
439
- return !!(this.listKeyManager?.activeItem === option);
440
- }
441
- /**
442
- * Get whether the given value is selected.
443
- * @param value The value to get the selected state of
444
- */
445
- isValueSelected(value) {
446
- if (this._invalid) {
447
- return false;
448
- }
449
- return this.selectionModel.isSelected(value);
450
- }
451
- /**
452
- * Registers a callback to be invoked when the listbox's value changes from user input.
453
- * @param fn The callback to register
454
- * @docs-private
455
- */
456
- registerOnChange(fn) {
457
- this._onChange = fn;
458
- }
459
- /**
460
- * Registers a callback to be invoked when the listbox is blurred by the user.
461
- * @param fn The callback to register
462
- * @docs-private
463
- */
464
- registerOnTouched(fn) {
465
- this._onTouched = fn;
466
- }
467
- /**
468
- * Sets the listbox's value.
469
- * @param value The new value of the listbox
470
- * @docs-private
471
- */
472
- writeValue(value) {
473
- this._setSelection(value);
474
- this._verifyOptionValues();
475
- }
476
- /**
477
- * Sets the disabled state of the listbox.
478
- * @param isDisabled The new disabled state
479
- * @docs-private
480
- */
481
- setDisabledState(isDisabled) {
482
- this.disabled = isDisabled;
483
- this.changeDetectorRef.markForCheck();
484
- }
485
- /** Focus the listbox's host element. */
486
- focus() {
487
- this.element.focus();
488
- }
489
- /**
490
- * Triggers the given option in response to user interaction.
491
- * - In single selection mode: selects the option and deselects any other selected option.
492
- * - In multi selection mode: toggles the selected state of the option.
493
- * @param option The option to trigger
494
- */
495
- triggerOption(option) {
496
- if (option && !option.disabled) {
497
- this._lastTriggered = option;
498
- const changed = this.multiple
499
- ? this.selectionModel.toggle(option.value)
500
- : this.selectionModel.select(option.value);
501
- if (changed) {
502
- this._onChange(this.value);
503
- this.valueChange.next({
504
- value: this.value,
505
- listbox: this,
506
- option: option,
507
- });
508
- }
509
- }
510
- }
511
- /**
512
- * Trigger the given range of options in response to user interaction.
513
- * Should only be called in multi-selection mode.
514
- * @param trigger The option that was triggered
515
- * @param from The start index of the options to toggle
516
- * @param to The end index of the options to toggle
517
- * @param on Whether to toggle the option range on
518
- */
519
- triggerRange(trigger, from, to, on) {
520
- if (this.disabled || (trigger && trigger.disabled)) {
521
- return;
522
- }
523
- this._lastTriggered = trigger;
524
- const isEqual = this.compareWith ?? Object.is;
525
- const updateValues = [...this.options]
526
- .slice(Math.max(0, Math.min(from, to)), Math.min(this.options.length, Math.max(from, to) + 1))
527
- .filter(option => !option.disabled)
528
- .map(option => option.value);
529
- const selected = [...this.value];
530
- for (const updateValue of updateValues) {
531
- const selectedIndex = selected.findIndex(selectedValue => isEqual(selectedValue, updateValue));
532
- if (on && selectedIndex === -1) {
533
- selected.push(updateValue);
534
- }
535
- else if (!on && selectedIndex !== -1) {
536
- selected.splice(selectedIndex, 1);
537
- }
538
- }
539
- let changed = this.selectionModel.setSelection(...selected);
540
- if (changed) {
541
- this._onChange(this.value);
542
- this.valueChange.next({
543
- value: this.value,
544
- listbox: this,
545
- option: trigger,
546
- });
547
- }
548
- }
549
- /**
550
- * Sets the given option as active.
551
- * @param option The option to make active
552
- */
553
- _setActiveOption(option) {
554
- this.listKeyManager.setActiveItem(option);
555
- }
556
- /** Called when the listbox receives focus. */
557
- _handleFocus() {
558
- if (!this.useActiveDescendant) {
559
- if (this.selectionModel.selected.length > 0) {
560
- this._setNextFocusToSelectedOption();
561
- }
562
- else {
563
- this.listKeyManager.setNextItemActive();
564
- }
565
- this._focusActiveOption();
566
- }
567
- }
568
- /** Called when the user presses keydown on the listbox. */
569
- _handleKeydown(event) {
570
- if (this.disabled) {
571
- return;
572
- }
573
- const { keyCode } = event;
574
- const previousActiveIndex = this.listKeyManager.activeItemIndex;
575
- const ctrlKeys = ['ctrlKey', 'metaKey'];
576
- if (this.multiple && keyCode === A && hasModifierKey(event, ...ctrlKeys)) {
577
- // Toggle all options off if they're all selected, otherwise toggle them all on.
578
- this.triggerRange(null, 0, this.options.length - 1, this.options.length !== this.value.length);
579
- event.preventDefault();
580
- return;
581
- }
582
- if (this.multiple &&
583
- (keyCode === SPACE || keyCode === ENTER) &&
584
- hasModifierKey(event, 'shiftKey')) {
585
- if (this.listKeyManager.activeItem && this.listKeyManager.activeItemIndex != null) {
586
- this.triggerRange(this.listKeyManager.activeItem, this._getLastTriggeredIndex() ?? this.listKeyManager.activeItemIndex, this.listKeyManager.activeItemIndex, !this.listKeyManager.activeItem.isSelected());
587
- }
588
- event.preventDefault();
589
- return;
590
- }
591
- if (this.multiple &&
592
- keyCode === HOME &&
593
- hasModifierKey(event, ...ctrlKeys) &&
594
- hasModifierKey(event, 'shiftKey')) {
595
- const trigger = this.listKeyManager.activeItem;
596
- if (trigger) {
597
- const from = this.listKeyManager.activeItemIndex;
598
- this.listKeyManager.setFirstItemActive();
599
- this.triggerRange(trigger, from, this.listKeyManager.activeItemIndex, !trigger.isSelected());
600
- }
601
- event.preventDefault();
602
- return;
603
- }
604
- if (this.multiple &&
605
- keyCode === END &&
606
- hasModifierKey(event, ...ctrlKeys) &&
607
- hasModifierKey(event, 'shiftKey')) {
608
- const trigger = this.listKeyManager.activeItem;
609
- if (trigger) {
610
- const from = this.listKeyManager.activeItemIndex;
611
- this.listKeyManager.setLastItemActive();
612
- this.triggerRange(trigger, from, this.listKeyManager.activeItemIndex, !trigger.isSelected());
613
- }
614
- event.preventDefault();
615
- return;
616
- }
617
- if (keyCode === SPACE || keyCode === ENTER) {
618
- this.triggerOption(this.listKeyManager.activeItem);
619
- event.preventDefault();
620
- return;
621
- }
622
- const isNavKey = keyCode === UP_ARROW ||
623
- keyCode === DOWN_ARROW ||
624
- keyCode === LEFT_ARROW ||
625
- keyCode === RIGHT_ARROW ||
626
- keyCode === HOME ||
627
- keyCode === END;
628
- this.listKeyManager.onKeydown(event);
629
- // Will select an option if shift was pressed while navigating to the option
630
- if (isNavKey && event.shiftKey && previousActiveIndex !== this.listKeyManager.activeItemIndex) {
631
- this.triggerOption(this.listKeyManager.activeItem);
632
- }
633
- }
634
- /** Called when a focus moves into the listbox. */
635
- _handleFocusIn() {
636
- // Note that we use a `focusin` handler for this instead of the existing `focus` handler,
637
- // because focus won't land on the listbox if `useActiveDescendant` is enabled.
638
- this._hasFocus = true;
639
- }
640
- /**
641
- * Called when the focus leaves an element in the listbox.
642
- * @param event The focusout event
643
- */
644
- _handleFocusOut(event) {
645
- // Some browsers (e.g. Chrome and Firefox) trigger the focusout event when the user returns back to the document.
646
- // To prevent losing the active option in this case, we store it in `_previousActiveOption` and restore it on the window `blur` event
647
- // This ensures that the `activeItem` matches the actual focused element when the user returns to the document.
648
- this._previousActiveOption = this.listKeyManager.activeItem;
649
- const otherElement = event.relatedTarget;
650
- if (this.element !== otherElement && !this.element.contains(otherElement)) {
651
- this._onTouched();
652
- this._hasFocus = false;
653
- this._setNextFocusToSelectedOption();
654
- }
655
- }
656
- /** Get the id of the active option if active descendant is being used. */
657
- _getAriaActiveDescendant() {
658
- return this.useActiveDescendant ? this.listKeyManager?.activeItem?.id : null;
659
- }
660
- /** Get the tabindex for the listbox. */
661
- _getTabIndex() {
662
- if (this.disabled) {
663
- return -1;
664
- }
665
- return this.useActiveDescendant || !this.listKeyManager.activeItem ? this.enabledTabIndex : -1;
666
- }
667
- /** Initialize the key manager. */
668
- _initKeyManager() {
669
- this.listKeyManager = new ActiveDescendantKeyManager(this.options)
670
- .withWrap(!this._navigationWrapDisabled)
671
- .withTypeAhead()
672
- .withHomeAndEnd()
673
- .withAllowedModifierKeys(['shiftKey'])
674
- .skipPredicate(this._navigateDisabledOptions ? this._skipNonePredicate : this._skipDisabledPredicate);
675
- if (this.orientation === 'vertical') {
676
- this.listKeyManager.withVerticalOrientation();
677
- }
678
- else {
679
- this.listKeyManager.withHorizontalOrientation(this._dir?.value || 'ltr');
680
- }
681
- if (this.selectionModel.selected.length) {
682
- Promise.resolve().then(() => this._setNextFocusToSelectedOption());
683
- }
684
- this.listKeyManager.change.subscribe(() => this._focusActiveOption());
685
- this.options.changes.pipe(takeUntil(this.destroyed)).subscribe(() => {
686
- const activeOption = this.listKeyManager.activeItem;
687
- // If the active option was deleted, we need to reset
688
- // the key manager so it can allow focus back in.
689
- if (activeOption && !this.options.find(option => option === activeOption)) {
690
- this.listKeyManager.setActiveItem(-1);
691
- this.changeDetectorRef.markForCheck();
692
- }
208
+ _cleanupWindowBlur;
209
+ get id() {
210
+ return this._id || this._generatedId;
211
+ }
212
+ set id(value) {
213
+ this._id = value;
214
+ }
215
+ _id;
216
+ _generatedId = inject(_IdGenerator).getId('cdk-listbox-');
217
+ get enabledTabIndex() {
218
+ return this._enabledTabIndex() === undefined ? 0 : this._enabledTabIndex();
219
+ }
220
+ set enabledTabIndex(value) {
221
+ this._enabledTabIndex.set(value);
222
+ }
223
+ _enabledTabIndex = signal(undefined, ...(ngDevMode ? [{
224
+ debugName: "_enabledTabIndex"
225
+ }] : []));
226
+ get value() {
227
+ return this._invalid ? [] : this.selectionModel.selected;
228
+ }
229
+ set value(value) {
230
+ this._setSelection(value);
231
+ }
232
+ get multiple() {
233
+ return this.selectionModel.multiple;
234
+ }
235
+ set multiple(value) {
236
+ this.selectionModel.multiple = value;
237
+ if (this.options) {
238
+ this._updateInternalValue();
239
+ }
240
+ }
241
+ get disabled() {
242
+ return this._disabled();
243
+ }
244
+ set disabled(value) {
245
+ this._disabled.set(value);
246
+ }
247
+ _disabled = signal(false, ...(ngDevMode ? [{
248
+ debugName: "_disabled"
249
+ }] : []));
250
+ get useActiveDescendant() {
251
+ return this._useActiveDescendant();
252
+ }
253
+ set useActiveDescendant(value) {
254
+ this._useActiveDescendant.set(value);
255
+ }
256
+ _useActiveDescendant = signal(false, ...(ngDevMode ? [{
257
+ debugName: "_useActiveDescendant"
258
+ }] : []));
259
+ get orientation() {
260
+ return this._orientation;
261
+ }
262
+ set orientation(value) {
263
+ this._orientation = value === 'horizontal' ? 'horizontal' : 'vertical';
264
+ if (value === 'horizontal') {
265
+ this.listKeyManager?.withHorizontalOrientation(this._dir?.value || 'ltr');
266
+ } else {
267
+ this.listKeyManager?.withVerticalOrientation();
268
+ }
269
+ }
270
+ _orientation = 'vertical';
271
+ get compareWith() {
272
+ return this.selectionModel.compareWith;
273
+ }
274
+ set compareWith(fn) {
275
+ this.selectionModel.compareWith = fn;
276
+ }
277
+ get navigationWrapDisabled() {
278
+ return this._navigationWrapDisabled;
279
+ }
280
+ set navigationWrapDisabled(wrap) {
281
+ this._navigationWrapDisabled = wrap;
282
+ this.listKeyManager?.withWrap(!this._navigationWrapDisabled);
283
+ }
284
+ _navigationWrapDisabled = false;
285
+ get navigateDisabledOptions() {
286
+ return this._navigateDisabledOptions;
287
+ }
288
+ set navigateDisabledOptions(skip) {
289
+ this._navigateDisabledOptions = skip;
290
+ this.listKeyManager?.skipPredicate(this._navigateDisabledOptions ? this._skipNonePredicate : this._skipDisabledPredicate);
291
+ }
292
+ _navigateDisabledOptions = false;
293
+ valueChange = new Subject();
294
+ options;
295
+ selectionModel = new ListboxSelectionModel();
296
+ listKeyManager;
297
+ destroyed = new Subject();
298
+ element = inject(ElementRef).nativeElement;
299
+ ngZone = inject(NgZone);
300
+ changeDetectorRef = inject(ChangeDetectorRef);
301
+ _invalid = false;
302
+ _lastTriggered = null;
303
+ _onTouched = () => {};
304
+ _onChange = () => {};
305
+ _optionClicked = defer(() => this.options.changes.pipe(startWith(this.options), switchMap(options => merge(...options.map(option => option._clicked.pipe(map(event => ({
306
+ option,
307
+ event
308
+ }))))))));
309
+ _dir = inject(Directionality, {
310
+ optional: true
311
+ });
312
+ _isBrowser = inject(Platform).isBrowser;
313
+ _skipDisabledPredicate = option => option.disabled;
314
+ _skipNonePredicate = () => false;
315
+ _hasFocus = false;
316
+ _previousActiveOption = null;
317
+ constructor() {
318
+ if (this._isBrowser) {
319
+ const renderer = inject(Renderer2);
320
+ this._cleanupWindowBlur = this.ngZone.runOutsideAngular(() => {
321
+ return renderer.listen('window', 'blur', () => {
322
+ if (this.element.contains(document.activeElement) && this._previousActiveOption) {
323
+ this._setActiveOption(this._previousActiveOption);
324
+ this._previousActiveOption = null;
325
+ }
693
326
  });
694
- }
695
- /** Focus the active option. */
696
- _focusActiveOption() {
697
- if (!this.useActiveDescendant) {
698
- this.listKeyManager.activeItem?.focus();
699
- }
700
- this.changeDetectorRef.markForCheck();
701
- }
702
- /**
703
- * Set the selected values.
704
- * @param value The list of new selected values.
705
- */
706
- _setSelection(value) {
707
- if (this._invalid) {
708
- this.selectionModel.clear(false);
709
- }
710
- this.selectionModel.setSelection(...this._coerceValue(value));
711
- if (!this._hasFocus) {
712
- this._setNextFocusToSelectedOption();
713
- }
714
- }
715
- /** Sets the first selected option as first in the keyboard focus order. */
716
- _setNextFocusToSelectedOption() {
717
- // Null check the options since they only get defined after `ngAfterContentInit`.
718
- const selected = this.options?.find(option => option.isSelected());
719
- if (selected) {
720
- this.listKeyManager.updateActiveItem(selected);
721
- }
722
- }
723
- /** Update the internal value of the listbox based on the selection model. */
724
- _updateInternalValue() {
725
- const indexCache = new Map();
726
- this.selectionModel.sort((a, b) => {
727
- const aIndex = this._getIndexForValue(indexCache, a);
728
- const bIndex = this._getIndexForValue(indexCache, b);
729
- return aIndex - bIndex;
327
+ });
328
+ }
329
+ }
330
+ ngAfterContentInit() {
331
+ if (typeof ngDevMode === 'undefined' || ngDevMode) {
332
+ this._verifyNoOptionValueCollisions();
333
+ this._verifyOptionValues();
334
+ }
335
+ this._initKeyManager();
336
+ merge(this.selectionModel.changed, this.options.changes).pipe(startWith(null), takeUntil(this.destroyed)).subscribe(() => this._updateInternalValue());
337
+ this._optionClicked.pipe(filter(({
338
+ option
339
+ }) => !option.disabled), takeUntil(this.destroyed)).subscribe(({
340
+ option,
341
+ event
342
+ }) => this._handleOptionClicked(option, event));
343
+ }
344
+ ngOnDestroy() {
345
+ this._cleanupWindowBlur?.();
346
+ this.listKeyManager?.destroy();
347
+ this.destroyed.next();
348
+ this.destroyed.complete();
349
+ }
350
+ toggle(option) {
351
+ this.toggleValue(option.value);
352
+ }
353
+ toggleValue(value) {
354
+ if (this._invalid) {
355
+ this.selectionModel.clear(false);
356
+ }
357
+ this.selectionModel.toggle(value);
358
+ }
359
+ select(option) {
360
+ this.selectValue(option.value);
361
+ }
362
+ selectValue(value) {
363
+ if (this._invalid) {
364
+ this.selectionModel.clear(false);
365
+ }
366
+ this.selectionModel.select(value);
367
+ }
368
+ deselect(option) {
369
+ this.deselectValue(option.value);
370
+ }
371
+ deselectValue(value) {
372
+ if (this._invalid) {
373
+ this.selectionModel.clear(false);
374
+ }
375
+ this.selectionModel.deselect(value);
376
+ }
377
+ setAllSelected(isSelected) {
378
+ if (!isSelected) {
379
+ this.selectionModel.clear();
380
+ } else {
381
+ if (this._invalid) {
382
+ this.selectionModel.clear(false);
383
+ }
384
+ this.selectionModel.select(...this.options.map(option => option.value));
385
+ }
386
+ }
387
+ isSelected(option) {
388
+ return this.isValueSelected(option.value);
389
+ }
390
+ isActive(option) {
391
+ return !!(this.listKeyManager?.activeItem === option);
392
+ }
393
+ isValueSelected(value) {
394
+ if (this._invalid) {
395
+ return false;
396
+ }
397
+ return this.selectionModel.isSelected(value);
398
+ }
399
+ registerOnChange(fn) {
400
+ this._onChange = fn;
401
+ }
402
+ registerOnTouched(fn) {
403
+ this._onTouched = fn;
404
+ }
405
+ writeValue(value) {
406
+ this._setSelection(value);
407
+ this._verifyOptionValues();
408
+ }
409
+ setDisabledState(isDisabled) {
410
+ this.disabled = isDisabled;
411
+ this.changeDetectorRef.markForCheck();
412
+ }
413
+ focus() {
414
+ this.element.focus();
415
+ }
416
+ triggerOption(option) {
417
+ if (option && !option.disabled) {
418
+ this._lastTriggered = option;
419
+ const changed = this.multiple ? this.selectionModel.toggle(option.value) : this.selectionModel.select(option.value);
420
+ if (changed) {
421
+ this._onChange(this.value);
422
+ this.valueChange.next({
423
+ value: this.value,
424
+ listbox: this,
425
+ option: option
730
426
  });
731
- const selected = this.selectionModel.selected;
732
- this._invalid =
733
- (!this.multiple && selected.length > 1) || !!this._getInvalidOptionValues(selected).length;
427
+ }
428
+ }
429
+ }
430
+ triggerRange(trigger, from, to, on) {
431
+ if (this.disabled || trigger && trigger.disabled) {
432
+ return;
433
+ }
434
+ this._lastTriggered = trigger;
435
+ const isEqual = this.compareWith ?? Object.is;
436
+ const updateValues = [...this.options].slice(Math.max(0, Math.min(from, to)), Math.min(this.options.length, Math.max(from, to) + 1)).filter(option => !option.disabled).map(option => option.value);
437
+ const selected = [...this.value];
438
+ for (const updateValue of updateValues) {
439
+ const selectedIndex = selected.findIndex(selectedValue => isEqual(selectedValue, updateValue));
440
+ if (on && selectedIndex === -1) {
441
+ selected.push(updateValue);
442
+ } else if (!on && selectedIndex !== -1) {
443
+ selected.splice(selectedIndex, 1);
444
+ }
445
+ }
446
+ let changed = this.selectionModel.setSelection(...selected);
447
+ if (changed) {
448
+ this._onChange(this.value);
449
+ this.valueChange.next({
450
+ value: this.value,
451
+ listbox: this,
452
+ option: trigger
453
+ });
454
+ }
455
+ }
456
+ _setActiveOption(option) {
457
+ this.listKeyManager.setActiveItem(option);
458
+ }
459
+ _handleFocus() {
460
+ if (!this.useActiveDescendant) {
461
+ if (this.selectionModel.selected.length > 0) {
462
+ this._setNextFocusToSelectedOption();
463
+ } else {
464
+ this.listKeyManager.setNextItemActive();
465
+ }
466
+ this._focusActiveOption();
467
+ }
468
+ }
469
+ _handleKeydown(event) {
470
+ if (this.disabled) {
471
+ return;
472
+ }
473
+ const {
474
+ keyCode
475
+ } = event;
476
+ const previousActiveIndex = this.listKeyManager.activeItemIndex;
477
+ const ctrlKeys = ['ctrlKey', 'metaKey'];
478
+ if (this.multiple && keyCode === A && hasModifierKey(event, ...ctrlKeys)) {
479
+ this.triggerRange(null, 0, this.options.length - 1, this.options.length !== this.value.length);
480
+ event.preventDefault();
481
+ return;
482
+ }
483
+ if (this.multiple && (keyCode === SPACE || keyCode === ENTER) && hasModifierKey(event, 'shiftKey')) {
484
+ if (this.listKeyManager.activeItem && this.listKeyManager.activeItemIndex != null) {
485
+ this.triggerRange(this.listKeyManager.activeItem, this._getLastTriggeredIndex() ?? this.listKeyManager.activeItemIndex, this.listKeyManager.activeItemIndex, !this.listKeyManager.activeItem.isSelected());
486
+ }
487
+ event.preventDefault();
488
+ return;
489
+ }
490
+ if (this.multiple && keyCode === HOME && hasModifierKey(event, ...ctrlKeys) && hasModifierKey(event, 'shiftKey')) {
491
+ const trigger = this.listKeyManager.activeItem;
492
+ if (trigger) {
493
+ const from = this.listKeyManager.activeItemIndex;
494
+ this.listKeyManager.setFirstItemActive();
495
+ this.triggerRange(trigger, from, this.listKeyManager.activeItemIndex, !trigger.isSelected());
496
+ }
497
+ event.preventDefault();
498
+ return;
499
+ }
500
+ if (this.multiple && keyCode === END && hasModifierKey(event, ...ctrlKeys) && hasModifierKey(event, 'shiftKey')) {
501
+ const trigger = this.listKeyManager.activeItem;
502
+ if (trigger) {
503
+ const from = this.listKeyManager.activeItemIndex;
504
+ this.listKeyManager.setLastItemActive();
505
+ this.triggerRange(trigger, from, this.listKeyManager.activeItemIndex, !trigger.isSelected());
506
+ }
507
+ event.preventDefault();
508
+ return;
509
+ }
510
+ if (keyCode === SPACE || keyCode === ENTER) {
511
+ this.triggerOption(this.listKeyManager.activeItem);
512
+ event.preventDefault();
513
+ return;
514
+ }
515
+ const isNavKey = keyCode === UP_ARROW || keyCode === DOWN_ARROW || keyCode === LEFT_ARROW || keyCode === RIGHT_ARROW || keyCode === HOME || keyCode === END;
516
+ this.listKeyManager.onKeydown(event);
517
+ if (isNavKey && event.shiftKey && previousActiveIndex !== this.listKeyManager.activeItemIndex) {
518
+ this.triggerOption(this.listKeyManager.activeItem);
519
+ }
520
+ }
521
+ _handleFocusIn() {
522
+ this._hasFocus = true;
523
+ }
524
+ _handleFocusOut(event) {
525
+ this._previousActiveOption = this.listKeyManager.activeItem;
526
+ const otherElement = event.relatedTarget;
527
+ if (this.element !== otherElement && !this.element.contains(otherElement)) {
528
+ this._onTouched();
529
+ this._hasFocus = false;
530
+ this._setNextFocusToSelectedOption();
531
+ }
532
+ }
533
+ _getAriaActiveDescendant() {
534
+ return this.useActiveDescendant ? this.listKeyManager?.activeItem?.id : null;
535
+ }
536
+ _getTabIndex() {
537
+ if (this.disabled) {
538
+ return -1;
539
+ }
540
+ return this.useActiveDescendant || !this.listKeyManager.activeItem ? this.enabledTabIndex : -1;
541
+ }
542
+ _initKeyManager() {
543
+ this.listKeyManager = new ActiveDescendantKeyManager(this.options).withWrap(!this._navigationWrapDisabled).withTypeAhead().withHomeAndEnd().withAllowedModifierKeys(['shiftKey']).skipPredicate(this._navigateDisabledOptions ? this._skipNonePredicate : this._skipDisabledPredicate);
544
+ if (this.orientation === 'vertical') {
545
+ this.listKeyManager.withVerticalOrientation();
546
+ } else {
547
+ this.listKeyManager.withHorizontalOrientation(this._dir?.value || 'ltr');
548
+ }
549
+ if (this.selectionModel.selected.length) {
550
+ Promise.resolve().then(() => this._setNextFocusToSelectedOption());
551
+ }
552
+ this.listKeyManager.change.subscribe(() => this._focusActiveOption());
553
+ this.options.changes.pipe(takeUntil(this.destroyed)).subscribe(() => {
554
+ const activeOption = this.listKeyManager.activeItem;
555
+ if (activeOption && !this.options.find(option => option === activeOption)) {
556
+ this.listKeyManager.setActiveItem(-1);
734
557
  this.changeDetectorRef.markForCheck();
735
- }
736
- /**
737
- * Gets the index of the given value in the given list of options.
738
- * @param cache The cache of indices found so far
739
- * @param value The value to find
740
- * @return The index of the value in the options list
741
- */
742
- _getIndexForValue(cache, value) {
743
- const isEqual = this.compareWith || Object.is;
744
- if (!cache.has(value)) {
745
- let index = -1;
746
- for (let i = 0; i < this.options.length; i++) {
747
- if (isEqual(value, this.options.get(i).value)) {
748
- index = i;
749
- break;
750
- }
751
- }
752
- cache.set(value, index);
753
- }
754
- return cache.get(value);
755
- }
756
- /**
757
- * Handle the user clicking an option.
758
- * @param option The option that was clicked.
759
- */
760
- _handleOptionClicked(option, event) {
761
- event.preventDefault();
762
- this.listKeyManager.setActiveItem(option);
763
- if (event.shiftKey && this.multiple) {
764
- this.triggerRange(option, this._getLastTriggeredIndex() ?? this.listKeyManager.activeItemIndex, this.listKeyManager.activeItemIndex, !option.isSelected());
765
- }
766
- else {
767
- this.triggerOption(option);
768
- }
769
- }
770
- /** Verifies that no two options represent the same value under the compareWith function. */
771
- _verifyNoOptionValueCollisions() {
772
- this.options.changes.pipe(startWith(this.options), takeUntil(this.destroyed)).subscribe(() => {
773
- const isEqual = this.compareWith ?? Object.is;
774
- for (let i = 0; i < this.options.length; i++) {
775
- const option = this.options.get(i);
776
- let duplicate = null;
777
- for (let j = i + 1; j < this.options.length; j++) {
778
- const other = this.options.get(j);
779
- if (isEqual(option.value, other.value)) {
780
- duplicate = other;
781
- break;
782
- }
783
- }
784
- if (duplicate) {
785
- // TODO(mmalerba): Link to docs about this.
786
- if (this.compareWith) {
787
- console.warn(`Found multiple CdkOption representing the same value under the given compareWith function`, {
788
- option1: option.element,
789
- option2: duplicate.element,
790
- compareWith: this.compareWith,
791
- });
792
- }
793
- else {
794
- console.warn(`Found multiple CdkOption with the same value`, {
795
- option1: option.element,
796
- option2: duplicate.element,
797
- });
798
- }
799
- return;
800
- }
801
- }
802
- });
803
- }
804
- /** Verifies that the option values are valid. */
805
- _verifyOptionValues() {
806
- if (this.options && (typeof ngDevMode === 'undefined' || ngDevMode)) {
807
- const selected = this.selectionModel.selected;
808
- const invalidValues = this._getInvalidOptionValues(selected);
809
- if (!this.multiple && selected.length > 1) {
810
- throw Error('Listbox cannot have more than one selected value in multi-selection mode.');
811
- }
812
- if (invalidValues.length) {
813
- throw Error('Listbox has selected values that do not match any of its options.');
814
- }
815
- }
816
- }
817
- /**
818
- * Coerces a value into an array representing a listbox selection.
819
- * @param value The value to coerce
820
- * @return An array
821
- */
822
- _coerceValue(value) {
823
- return value == null ? [] : coerceArray(value);
824
- }
825
- /**
826
- * Get the sublist of values that do not represent valid option values in this listbox.
827
- * @param values The list of values
828
- * @return The sublist of values that are not valid option values
829
- */
830
- _getInvalidOptionValues(values) {
831
- const isEqual = this.compareWith || Object.is;
832
- const validValues = (this.options || []).map(option => option.value);
833
- return values.filter(value => !validValues.some(validValue => isEqual(value, validValue)));
834
- }
835
- /** Get the index of the last triggered option. */
836
- _getLastTriggeredIndex() {
837
- const index = this.options.toArray().indexOf(this._lastTriggered);
838
- return index === -1 ? null : index;
839
- }
840
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.0-next.2", ngImport: i0, type: CdkListbox, deps: [], target: i0.ɵɵFactoryTarget.Directive });
841
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "16.1.0", version: "20.2.0-next.2", type: CdkListbox, isStandalone: true, selector: "[cdkListbox]", inputs: { id: "id", enabledTabIndex: ["tabindex", "enabledTabIndex"], value: ["cdkListboxValue", "value"], multiple: ["cdkListboxMultiple", "multiple", booleanAttribute], disabled: ["cdkListboxDisabled", "disabled", booleanAttribute], useActiveDescendant: ["cdkListboxUseActiveDescendant", "useActiveDescendant", booleanAttribute], orientation: ["cdkListboxOrientation", "orientation"], compareWith: ["cdkListboxCompareWith", "compareWith"], navigationWrapDisabled: ["cdkListboxNavigationWrapDisabled", "navigationWrapDisabled", booleanAttribute], navigateDisabledOptions: ["cdkListboxNavigatesDisabledOptions", "navigateDisabledOptions", booleanAttribute] }, outputs: { valueChange: "cdkListboxValueChange" }, host: { attributes: { "role": "listbox" }, listeners: { "focus": "_handleFocus()", "keydown": "_handleKeydown($event)", "focusout": "_handleFocusOut($event)", "focusin": "_handleFocusIn()" }, properties: { "id": "id", "attr.tabindex": "_getTabIndex()", "attr.aria-disabled": "disabled", "attr.aria-multiselectable": "multiple", "attr.aria-activedescendant": "_getAriaActiveDescendant()", "attr.aria-orientation": "orientation" }, classAttribute: "cdk-listbox" }, providers: [
842
- {
843
- provide: NG_VALUE_ACCESSOR,
844
- useExisting: forwardRef(() => CdkListbox),
845
- multi: true,
846
- },
847
- ], queries: [{ propertyName: "options", predicate: CdkOption, descendants: true }], exportAs: ["cdkListbox"], ngImport: i0 });
558
+ }
559
+ });
560
+ }
561
+ _focusActiveOption() {
562
+ if (!this.useActiveDescendant) {
563
+ this.listKeyManager.activeItem?.focus();
564
+ }
565
+ this.changeDetectorRef.markForCheck();
566
+ }
567
+ _setSelection(value) {
568
+ if (this._invalid) {
569
+ this.selectionModel.clear(false);
570
+ }
571
+ this.selectionModel.setSelection(...this._coerceValue(value));
572
+ if (!this._hasFocus) {
573
+ this._setNextFocusToSelectedOption();
574
+ }
575
+ }
576
+ _setNextFocusToSelectedOption() {
577
+ const selected = this.options?.find(option => option.isSelected());
578
+ if (selected) {
579
+ this.listKeyManager.updateActiveItem(selected);
580
+ }
581
+ }
582
+ _updateInternalValue() {
583
+ const indexCache = new Map();
584
+ this.selectionModel.sort((a, b) => {
585
+ const aIndex = this._getIndexForValue(indexCache, a);
586
+ const bIndex = this._getIndexForValue(indexCache, b);
587
+ return aIndex - bIndex;
588
+ });
589
+ const selected = this.selectionModel.selected;
590
+ this._invalid = !this.multiple && selected.length > 1 || !!this._getInvalidOptionValues(selected).length;
591
+ this.changeDetectorRef.markForCheck();
592
+ }
593
+ _getIndexForValue(cache, value) {
594
+ const isEqual = this.compareWith || Object.is;
595
+ if (!cache.has(value)) {
596
+ let index = -1;
597
+ for (let i = 0; i < this.options.length; i++) {
598
+ if (isEqual(value, this.options.get(i).value)) {
599
+ index = i;
600
+ break;
601
+ }
602
+ }
603
+ cache.set(value, index);
604
+ }
605
+ return cache.get(value);
606
+ }
607
+ _handleOptionClicked(option, event) {
608
+ event.preventDefault();
609
+ this.listKeyManager.setActiveItem(option);
610
+ if (event.shiftKey && this.multiple) {
611
+ this.triggerRange(option, this._getLastTriggeredIndex() ?? this.listKeyManager.activeItemIndex, this.listKeyManager.activeItemIndex, !option.isSelected());
612
+ } else {
613
+ this.triggerOption(option);
614
+ }
615
+ }
616
+ _verifyNoOptionValueCollisions() {
617
+ this.options.changes.pipe(startWith(this.options), takeUntil(this.destroyed)).subscribe(() => {
618
+ const isEqual = this.compareWith ?? Object.is;
619
+ for (let i = 0; i < this.options.length; i++) {
620
+ const option = this.options.get(i);
621
+ let duplicate = null;
622
+ for (let j = i + 1; j < this.options.length; j++) {
623
+ const other = this.options.get(j);
624
+ if (isEqual(option.value, other.value)) {
625
+ duplicate = other;
626
+ break;
627
+ }
628
+ }
629
+ if (duplicate) {
630
+ if (this.compareWith) {
631
+ console.warn(`Found multiple CdkOption representing the same value under the given compareWith function`, {
632
+ option1: option.element,
633
+ option2: duplicate.element,
634
+ compareWith: this.compareWith
635
+ });
636
+ } else {
637
+ console.warn(`Found multiple CdkOption with the same value`, {
638
+ option1: option.element,
639
+ option2: duplicate.element
640
+ });
641
+ }
642
+ return;
643
+ }
644
+ }
645
+ });
646
+ }
647
+ _verifyOptionValues() {
648
+ if (this.options && (typeof ngDevMode === 'undefined' || ngDevMode)) {
649
+ const selected = this.selectionModel.selected;
650
+ const invalidValues = this._getInvalidOptionValues(selected);
651
+ if (!this.multiple && selected.length > 1) {
652
+ throw Error('Listbox cannot have more than one selected value in multi-selection mode.');
653
+ }
654
+ if (invalidValues.length) {
655
+ throw Error('Listbox has selected values that do not match any of its options.');
656
+ }
657
+ }
658
+ }
659
+ _coerceValue(value) {
660
+ return value == null ? [] : coerceArray(value);
661
+ }
662
+ _getInvalidOptionValues(values) {
663
+ const isEqual = this.compareWith || Object.is;
664
+ const validValues = (this.options || []).map(option => option.value);
665
+ return values.filter(value => !validValues.some(validValue => isEqual(value, validValue)));
666
+ }
667
+ _getLastTriggeredIndex() {
668
+ const index = this.options.toArray().indexOf(this._lastTriggered);
669
+ return index === -1 ? null : index;
670
+ }
671
+ static ɵfac = i0.ɵɵngDeclareFactory({
672
+ minVersion: "12.0.0",
673
+ version: "20.2.0-next.2",
674
+ ngImport: i0,
675
+ type: CdkListbox,
676
+ deps: [],
677
+ target: i0.ɵɵFactoryTarget.Directive
678
+ });
679
+ static ɵdir = i0.ɵɵngDeclareDirective({
680
+ minVersion: "16.1.0",
681
+ version: "20.2.0-next.2",
682
+ type: CdkListbox,
683
+ isStandalone: true,
684
+ selector: "[cdkListbox]",
685
+ inputs: {
686
+ id: "id",
687
+ enabledTabIndex: ["tabindex", "enabledTabIndex"],
688
+ value: ["cdkListboxValue", "value"],
689
+ multiple: ["cdkListboxMultiple", "multiple", booleanAttribute],
690
+ disabled: ["cdkListboxDisabled", "disabled", booleanAttribute],
691
+ useActiveDescendant: ["cdkListboxUseActiveDescendant", "useActiveDescendant", booleanAttribute],
692
+ orientation: ["cdkListboxOrientation", "orientation"],
693
+ compareWith: ["cdkListboxCompareWith", "compareWith"],
694
+ navigationWrapDisabled: ["cdkListboxNavigationWrapDisabled", "navigationWrapDisabled", booleanAttribute],
695
+ navigateDisabledOptions: ["cdkListboxNavigatesDisabledOptions", "navigateDisabledOptions", booleanAttribute]
696
+ },
697
+ outputs: {
698
+ valueChange: "cdkListboxValueChange"
699
+ },
700
+ host: {
701
+ attributes: {
702
+ "role": "listbox"
703
+ },
704
+ listeners: {
705
+ "focus": "_handleFocus()",
706
+ "keydown": "_handleKeydown($event)",
707
+ "focusout": "_handleFocusOut($event)",
708
+ "focusin": "_handleFocusIn()"
709
+ },
710
+ properties: {
711
+ "id": "id",
712
+ "attr.tabindex": "_getTabIndex()",
713
+ "attr.aria-disabled": "disabled",
714
+ "attr.aria-multiselectable": "multiple",
715
+ "attr.aria-activedescendant": "_getAriaActiveDescendant()",
716
+ "attr.aria-orientation": "orientation"
717
+ },
718
+ classAttribute: "cdk-listbox"
719
+ },
720
+ providers: [{
721
+ provide: NG_VALUE_ACCESSOR,
722
+ useExisting: forwardRef(() => CdkListbox),
723
+ multi: true
724
+ }],
725
+ queries: [{
726
+ propertyName: "options",
727
+ predicate: CdkOption,
728
+ descendants: true
729
+ }],
730
+ exportAs: ["cdkListbox"],
731
+ ngImport: i0
732
+ });
848
733
  }
849
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.0-next.2", ngImport: i0, type: CdkListbox, decorators: [{
850
- type: Directive,
851
- args: [{
852
- selector: '[cdkListbox]',
853
- exportAs: 'cdkListbox',
854
- host: {
855
- 'role': 'listbox',
856
- 'class': 'cdk-listbox',
857
- '[id]': 'id',
858
- '[attr.tabindex]': '_getTabIndex()',
859
- '[attr.aria-disabled]': 'disabled',
860
- '[attr.aria-multiselectable]': 'multiple',
861
- '[attr.aria-activedescendant]': '_getAriaActiveDescendant()',
862
- '[attr.aria-orientation]': 'orientation',
863
- '(focus)': '_handleFocus()',
864
- '(keydown)': '_handleKeydown($event)',
865
- '(focusout)': '_handleFocusOut($event)',
866
- '(focusin)': '_handleFocusIn()',
867
- },
868
- providers: [
869
- {
870
- provide: NG_VALUE_ACCESSOR,
871
- useExisting: forwardRef(() => CdkListbox),
872
- multi: true,
873
- },
874
- ],
875
- }]
876
- }], ctorParameters: () => [], propDecorators: { id: [{
877
- type: Input
878
- }], enabledTabIndex: [{
879
- type: Input,
880
- args: ['tabindex']
881
- }], value: [{
882
- type: Input,
883
- args: ['cdkListboxValue']
884
- }], multiple: [{
885
- type: Input,
886
- args: [{ alias: 'cdkListboxMultiple', transform: booleanAttribute }]
887
- }], disabled: [{
888
- type: Input,
889
- args: [{ alias: 'cdkListboxDisabled', transform: booleanAttribute }]
890
- }], useActiveDescendant: [{
891
- type: Input,
892
- args: [{ alias: 'cdkListboxUseActiveDescendant', transform: booleanAttribute }]
893
- }], orientation: [{
894
- type: Input,
895
- args: ['cdkListboxOrientation']
896
- }], compareWith: [{
897
- type: Input,
898
- args: ['cdkListboxCompareWith']
899
- }], navigationWrapDisabled: [{
900
- type: Input,
901
- args: [{ alias: 'cdkListboxNavigationWrapDisabled', transform: booleanAttribute }]
902
- }], navigateDisabledOptions: [{
903
- type: Input,
904
- args: [{ alias: 'cdkListboxNavigatesDisabledOptions', transform: booleanAttribute }]
905
- }], valueChange: [{
906
- type: Output,
907
- args: ['cdkListboxValueChange']
908
- }], options: [{
909
- type: ContentChildren,
910
- args: [CdkOption, { descendants: true }]
911
- }] } });
734
+ i0.ɵɵngDeclareClassMetadata({
735
+ minVersion: "12.0.0",
736
+ version: "20.2.0-next.2",
737
+ ngImport: i0,
738
+ type: CdkListbox,
739
+ decorators: [{
740
+ type: Directive,
741
+ args: [{
742
+ selector: '[cdkListbox]',
743
+ exportAs: 'cdkListbox',
744
+ host: {
745
+ 'role': 'listbox',
746
+ 'class': 'cdk-listbox',
747
+ '[id]': 'id',
748
+ '[attr.tabindex]': '_getTabIndex()',
749
+ '[attr.aria-disabled]': 'disabled',
750
+ '[attr.aria-multiselectable]': 'multiple',
751
+ '[attr.aria-activedescendant]': '_getAriaActiveDescendant()',
752
+ '[attr.aria-orientation]': 'orientation',
753
+ '(focus)': '_handleFocus()',
754
+ '(keydown)': '_handleKeydown($event)',
755
+ '(focusout)': '_handleFocusOut($event)',
756
+ '(focusin)': '_handleFocusIn()'
757
+ },
758
+ providers: [{
759
+ provide: NG_VALUE_ACCESSOR,
760
+ useExisting: forwardRef(() => CdkListbox),
761
+ multi: true
762
+ }]
763
+ }]
764
+ }],
765
+ ctorParameters: () => [],
766
+ propDecorators: {
767
+ id: [{
768
+ type: Input
769
+ }],
770
+ enabledTabIndex: [{
771
+ type: Input,
772
+ args: ['tabindex']
773
+ }],
774
+ value: [{
775
+ type: Input,
776
+ args: ['cdkListboxValue']
777
+ }],
778
+ multiple: [{
779
+ type: Input,
780
+ args: [{
781
+ alias: 'cdkListboxMultiple',
782
+ transform: booleanAttribute
783
+ }]
784
+ }],
785
+ disabled: [{
786
+ type: Input,
787
+ args: [{
788
+ alias: 'cdkListboxDisabled',
789
+ transform: booleanAttribute
790
+ }]
791
+ }],
792
+ useActiveDescendant: [{
793
+ type: Input,
794
+ args: [{
795
+ alias: 'cdkListboxUseActiveDescendant',
796
+ transform: booleanAttribute
797
+ }]
798
+ }],
799
+ orientation: [{
800
+ type: Input,
801
+ args: ['cdkListboxOrientation']
802
+ }],
803
+ compareWith: [{
804
+ type: Input,
805
+ args: ['cdkListboxCompareWith']
806
+ }],
807
+ navigationWrapDisabled: [{
808
+ type: Input,
809
+ args: [{
810
+ alias: 'cdkListboxNavigationWrapDisabled',
811
+ transform: booleanAttribute
812
+ }]
813
+ }],
814
+ navigateDisabledOptions: [{
815
+ type: Input,
816
+ args: [{
817
+ alias: 'cdkListboxNavigatesDisabledOptions',
818
+ transform: booleanAttribute
819
+ }]
820
+ }],
821
+ valueChange: [{
822
+ type: Output,
823
+ args: ['cdkListboxValueChange']
824
+ }],
825
+ options: [{
826
+ type: ContentChildren,
827
+ args: [CdkOption, {
828
+ descendants: true
829
+ }]
830
+ }]
831
+ }
832
+ });
912
833
 
913
834
  const EXPORTED_DECLARATIONS = [CdkListbox, CdkOption];
914
835
  class CdkListboxModule {
915
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.0-next.2", ngImport: i0, type: CdkListboxModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
916
- static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.2.0-next.2", ngImport: i0, type: CdkListboxModule, imports: [CdkListbox, CdkOption], exports: [CdkListbox, CdkOption] });
917
- static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.2.0-next.2", ngImport: i0, type: CdkListboxModule });
836
+ static ɵfac = i0.ɵɵngDeclareFactory({
837
+ minVersion: "12.0.0",
838
+ version: "20.2.0-next.2",
839
+ ngImport: i0,
840
+ type: CdkListboxModule,
841
+ deps: [],
842
+ target: i0.ɵɵFactoryTarget.NgModule
843
+ });
844
+ static ɵmod = i0.ɵɵngDeclareNgModule({
845
+ minVersion: "14.0.0",
846
+ version: "20.2.0-next.2",
847
+ ngImport: i0,
848
+ type: CdkListboxModule,
849
+ imports: [CdkListbox, CdkOption],
850
+ exports: [CdkListbox, CdkOption]
851
+ });
852
+ static ɵinj = i0.ɵɵngDeclareInjector({
853
+ minVersion: "12.0.0",
854
+ version: "20.2.0-next.2",
855
+ ngImport: i0,
856
+ type: CdkListboxModule
857
+ });
918
858
  }
919
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.0-next.2", ngImport: i0, type: CdkListboxModule, decorators: [{
920
- type: NgModule,
921
- args: [{
922
- imports: [...EXPORTED_DECLARATIONS],
923
- exports: [...EXPORTED_DECLARATIONS],
924
- }]
925
- }] });
859
+ i0.ɵɵngDeclareClassMetadata({
860
+ minVersion: "12.0.0",
861
+ version: "20.2.0-next.2",
862
+ ngImport: i0,
863
+ type: CdkListboxModule,
864
+ decorators: [{
865
+ type: NgModule,
866
+ args: [{
867
+ imports: [...EXPORTED_DECLARATIONS],
868
+ exports: [...EXPORTED_DECLARATIONS]
869
+ }]
870
+ }]
871
+ });
926
872
 
927
873
  export { CdkListbox, CdkListboxModule, CdkOption };
928
874
  //# sourceMappingURL=listbox.mjs.map