@angular/cdk-experimental 21.0.0-next.5 → 21.0.0-next.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/{polyfill.mjs → _polyfill-chunk.mjs} +1 -1
- package/fesm2022/_polyfill-chunk.mjs.map +1 -0
- package/fesm2022/cdk-experimental.mjs +1 -1
- package/fesm2022/cdk-experimental.mjs.map +1 -1
- package/fesm2022/column-resize.mjs +1 -1
- package/fesm2022/popover-edit.mjs +1 -1
- package/package.json +10 -45
- package/{column-resize/index.d.ts → types/column-resize.d.ts} +37 -37
- package/{popover-edit/index.d.ts → types/popover-edit.d.ts} +30 -30
- package/{scrolling/index.d.ts → types/scrolling.d.ts} +6 -6
- package/{selection/index.d.ts → types/selection.d.ts} +14 -14
- package/{table-scroll-container/index.d.ts → types/table-scroll-container.d.ts} +6 -6
- package/accordion/index.d.ts +0 -94
- package/accordion.d.d.ts +0 -89
- package/combobox/index.d.ts +0 -94
- package/deferred-content/index.d.ts +0 -37
- package/expansion.d.d.ts +0 -71
- package/fesm2022/accordion.mjs +0 -194
- package/fesm2022/accordion.mjs.map +0 -1
- package/fesm2022/accordion2.mjs +0 -152
- package/fesm2022/accordion2.mjs.map +0 -1
- package/fesm2022/combobox.mjs +0 -340
- package/fesm2022/combobox.mjs.map +0 -1
- package/fesm2022/deferred-content.mjs +0 -59
- package/fesm2022/deferred-content.mjs.map +0 -1
- package/fesm2022/expansion.mjs +0 -87
- package/fesm2022/expansion.mjs.map +0 -1
- package/fesm2022/list-navigation.mjs +0 -261
- package/fesm2022/list-navigation.mjs.map +0 -1
- package/fesm2022/list.mjs +0 -370
- package/fesm2022/list.mjs.map +0 -1
- package/fesm2022/listbox.mjs +0 -163
- package/fesm2022/listbox.mjs.map +0 -1
- package/fesm2022/option.mjs +0 -231
- package/fesm2022/option.mjs.map +0 -1
- package/fesm2022/polyfill.mjs.map +0 -1
- package/fesm2022/radio-group.mjs +0 -205
- package/fesm2022/radio-group.mjs.map +0 -1
- package/fesm2022/radio-group2.mjs +0 -143
- package/fesm2022/radio-group2.mjs.map +0 -1
- package/fesm2022/tabs.mjs +0 -302
- package/fesm2022/tabs.mjs.map +0 -1
- package/fesm2022/tabs2.mjs +0 -211
- package/fesm2022/tabs2.mjs.map +0 -1
- package/fesm2022/toolbar.mjs +0 -171
- package/fesm2022/toolbar.mjs.map +0 -1
- package/fesm2022/toolbar2.mjs +0 -224
- package/fesm2022/toolbar2.mjs.map +0 -1
- package/fesm2022/tree.mjs +0 -620
- package/fesm2022/tree.mjs.map +0 -1
- package/fesm2022/ui-patterns.mjs +0 -21
- package/fesm2022/ui-patterns.mjs.map +0 -1
- package/list.d.d.ts +0 -207
- package/listbox/index.d.ts +0 -89
- package/listbox.d.d.ts +0 -101
- package/pointer-event-manager.d.d.ts +0 -190
- package/radio-group/index.d.ts +0 -87
- package/radio-group.d.d.ts +0 -80
- package/tabs/index.d.ts +0 -159
- package/tabs.d.d.ts +0 -137
- package/toolbar/index.d.ts +0 -91
- package/toolbar.d.d.ts +0 -136
- package/tree/index.d.ts +0 -275
- package/ui-patterns/index.d.ts +0 -9
- /package/{index.d.ts → types/cdk-experimental.d.ts} +0 -0
package/fesm2022/option.mjs
DELETED
|
@@ -1,231 +0,0 @@
|
|
|
1
|
-
import { computed, signal } from '@angular/core';
|
|
2
|
-
import { List } from './list.mjs';
|
|
3
|
-
import { Modifier, KeyboardEventManager, PointerEventManager } from './list-navigation.mjs';
|
|
4
|
-
|
|
5
|
-
/** Controls the state of a listbox. */
|
|
6
|
-
class ListboxPattern {
|
|
7
|
-
inputs;
|
|
8
|
-
listBehavior;
|
|
9
|
-
/** Whether the list is vertically or horizontally oriented. */
|
|
10
|
-
orientation;
|
|
11
|
-
/** Whether the listbox is disabled. */
|
|
12
|
-
disabled = computed(() => this.listBehavior.disabled());
|
|
13
|
-
/** Whether the listbox is readonly. */
|
|
14
|
-
readonly;
|
|
15
|
-
/** The tabindex of the listbox. */
|
|
16
|
-
tabindex = computed(() => this.listBehavior.tabindex());
|
|
17
|
-
/** The id of the current active item. */
|
|
18
|
-
activedescendant = computed(() => this.listBehavior.activedescendant());
|
|
19
|
-
/** Whether multiple items in the list can be selected at once. */
|
|
20
|
-
multi;
|
|
21
|
-
/** The number of items in the listbox. */
|
|
22
|
-
setsize = computed(() => this.inputs.items().length);
|
|
23
|
-
/** Whether the listbox selection follows focus. */
|
|
24
|
-
followFocus = computed(() => this.inputs.selectionMode() === 'follow');
|
|
25
|
-
/** Whether the listbox should wrap. Used to disable wrapping while range selecting. */
|
|
26
|
-
wrap = signal(true);
|
|
27
|
-
/** The key used to navigate to the previous item in the list. */
|
|
28
|
-
prevKey = computed(() => {
|
|
29
|
-
if (this.inputs.orientation() === 'vertical') {
|
|
30
|
-
return 'ArrowUp';
|
|
31
|
-
}
|
|
32
|
-
return this.inputs.textDirection() === 'rtl' ? 'ArrowRight' : 'ArrowLeft';
|
|
33
|
-
});
|
|
34
|
-
/** The key used to navigate to the next item in the list. */
|
|
35
|
-
nextKey = computed(() => {
|
|
36
|
-
if (this.inputs.orientation() === 'vertical') {
|
|
37
|
-
return 'ArrowDown';
|
|
38
|
-
}
|
|
39
|
-
return this.inputs.textDirection() === 'rtl' ? 'ArrowLeft' : 'ArrowRight';
|
|
40
|
-
});
|
|
41
|
-
/** Represents the space key. Does nothing when the user is actively using typeahead. */
|
|
42
|
-
dynamicSpaceKey = computed(() => (this.listBehavior.isTyping() ? '' : ' '));
|
|
43
|
-
/** The regexp used to decide if a key should trigger typeahead. */
|
|
44
|
-
typeaheadRegexp = /^.$/; // TODO: Ignore spaces?
|
|
45
|
-
/** The keydown event manager for the listbox. */
|
|
46
|
-
keydown = computed(() => {
|
|
47
|
-
const manager = new KeyboardEventManager();
|
|
48
|
-
if (this.readonly()) {
|
|
49
|
-
return manager
|
|
50
|
-
.on(this.prevKey, () => this.listBehavior.prev())
|
|
51
|
-
.on(this.nextKey, () => this.listBehavior.next())
|
|
52
|
-
.on('Home', () => this.listBehavior.first())
|
|
53
|
-
.on('End', () => this.listBehavior.last())
|
|
54
|
-
.on(this.typeaheadRegexp, e => this.listBehavior.search(e.key));
|
|
55
|
-
}
|
|
56
|
-
if (!this.followFocus()) {
|
|
57
|
-
manager
|
|
58
|
-
.on(this.prevKey, () => this.listBehavior.prev())
|
|
59
|
-
.on(this.nextKey, () => this.listBehavior.next())
|
|
60
|
-
.on('Home', () => this.listBehavior.first())
|
|
61
|
-
.on('End', () => this.listBehavior.last())
|
|
62
|
-
.on(this.typeaheadRegexp, e => this.listBehavior.search(e.key));
|
|
63
|
-
}
|
|
64
|
-
if (this.followFocus()) {
|
|
65
|
-
manager
|
|
66
|
-
.on(this.prevKey, () => this.listBehavior.prev({ selectOne: true }))
|
|
67
|
-
.on(this.nextKey, () => this.listBehavior.next({ selectOne: true }))
|
|
68
|
-
.on('Home', () => this.listBehavior.first({ selectOne: true }))
|
|
69
|
-
.on('End', () => this.listBehavior.last({ selectOne: true }))
|
|
70
|
-
.on(this.typeaheadRegexp, e => this.listBehavior.search(e.key, { selectOne: true }));
|
|
71
|
-
}
|
|
72
|
-
if (this.inputs.multi()) {
|
|
73
|
-
manager
|
|
74
|
-
.on(Modifier.Any, 'Shift', () => this.listBehavior.anchor(this.listBehavior.activeIndex()))
|
|
75
|
-
.on(Modifier.Shift, this.prevKey, () => this.listBehavior.prev({ selectRange: true }))
|
|
76
|
-
.on(Modifier.Shift, this.nextKey, () => this.listBehavior.next({ selectRange: true }))
|
|
77
|
-
.on([Modifier.Ctrl | Modifier.Shift, Modifier.Meta | Modifier.Shift], 'Home', () => this.listBehavior.first({ selectRange: true, anchor: false }))
|
|
78
|
-
.on([Modifier.Ctrl | Modifier.Shift, Modifier.Meta | Modifier.Shift], 'End', () => this.listBehavior.last({ selectRange: true, anchor: false }))
|
|
79
|
-
.on(Modifier.Shift, 'Enter', () => this.listBehavior.updateSelection({ selectRange: true, anchor: false }))
|
|
80
|
-
.on(Modifier.Shift, this.dynamicSpaceKey, () => this.listBehavior.updateSelection({ selectRange: true, anchor: false }));
|
|
81
|
-
}
|
|
82
|
-
if (!this.followFocus() && this.inputs.multi()) {
|
|
83
|
-
manager
|
|
84
|
-
.on(this.dynamicSpaceKey, () => this.listBehavior.toggle())
|
|
85
|
-
.on('Enter', () => this.listBehavior.toggle())
|
|
86
|
-
.on([Modifier.Ctrl, Modifier.Meta], 'A', () => this.listBehavior.toggleAll());
|
|
87
|
-
}
|
|
88
|
-
if (!this.followFocus() && !this.inputs.multi()) {
|
|
89
|
-
manager.on(this.dynamicSpaceKey, () => this.listBehavior.toggleOne());
|
|
90
|
-
manager.on('Enter', () => this.listBehavior.toggleOne());
|
|
91
|
-
}
|
|
92
|
-
if (this.inputs.multi() && this.followFocus()) {
|
|
93
|
-
manager
|
|
94
|
-
.on([Modifier.Ctrl, Modifier.Meta], this.prevKey, () => this.listBehavior.prev())
|
|
95
|
-
.on([Modifier.Ctrl, Modifier.Meta], this.nextKey, () => this.listBehavior.next())
|
|
96
|
-
.on([Modifier.Ctrl, Modifier.Meta], ' ', () => this.listBehavior.toggle())
|
|
97
|
-
.on([Modifier.Ctrl, Modifier.Meta], 'Enter', () => this.listBehavior.toggle())
|
|
98
|
-
.on([Modifier.Ctrl, Modifier.Meta], 'Home', () => this.listBehavior.first())
|
|
99
|
-
.on([Modifier.Ctrl, Modifier.Meta], 'End', () => this.listBehavior.last())
|
|
100
|
-
.on([Modifier.Ctrl, Modifier.Meta], 'A', () => {
|
|
101
|
-
this.listBehavior.toggleAll();
|
|
102
|
-
this.listBehavior.select(); // Ensure the currect option remains selected.
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
return manager;
|
|
106
|
-
});
|
|
107
|
-
/** The pointerdown event manager for the listbox. */
|
|
108
|
-
pointerdown = computed(() => {
|
|
109
|
-
const manager = new PointerEventManager();
|
|
110
|
-
if (this.readonly()) {
|
|
111
|
-
return manager.on(e => this.listBehavior.goto(this._getItem(e)));
|
|
112
|
-
}
|
|
113
|
-
if (this.multi()) {
|
|
114
|
-
manager.on(Modifier.Shift, e => this.listBehavior.goto(this._getItem(e), { selectRange: true }));
|
|
115
|
-
}
|
|
116
|
-
if (!this.multi() && this.followFocus()) {
|
|
117
|
-
return manager.on(e => this.listBehavior.goto(this._getItem(e), { selectOne: true }));
|
|
118
|
-
}
|
|
119
|
-
if (!this.multi() && !this.followFocus()) {
|
|
120
|
-
return manager.on(e => this.listBehavior.goto(this._getItem(e), { toggle: true }));
|
|
121
|
-
}
|
|
122
|
-
if (this.multi() && this.followFocus()) {
|
|
123
|
-
return manager
|
|
124
|
-
.on(e => this.listBehavior.goto(this._getItem(e), { selectOne: true }))
|
|
125
|
-
.on(Modifier.Ctrl, e => this.listBehavior.goto(this._getItem(e), { toggle: true }));
|
|
126
|
-
}
|
|
127
|
-
if (this.multi() && !this.followFocus()) {
|
|
128
|
-
return manager.on(e => this.listBehavior.goto(this._getItem(e), { toggle: true }));
|
|
129
|
-
}
|
|
130
|
-
return manager;
|
|
131
|
-
});
|
|
132
|
-
constructor(inputs) {
|
|
133
|
-
this.inputs = inputs;
|
|
134
|
-
this.readonly = inputs.readonly;
|
|
135
|
-
this.orientation = inputs.orientation;
|
|
136
|
-
this.multi = inputs.multi;
|
|
137
|
-
this.listBehavior = new List(inputs);
|
|
138
|
-
}
|
|
139
|
-
/** Returns a set of violations */
|
|
140
|
-
validate() {
|
|
141
|
-
const violations = [];
|
|
142
|
-
if (!this.inputs.multi() && this.inputs.value().length > 1) {
|
|
143
|
-
violations.push(`A single-select listbox should not have multiple selected options. Selected options: ${this.inputs.value().join(', ')}`);
|
|
144
|
-
}
|
|
145
|
-
const activeItem = this.inputs.activeItem();
|
|
146
|
-
if (activeItem && !this.inputs.items().includes(activeItem)) {
|
|
147
|
-
violations.push(`The current active item does not exist in the list. Active item: ${activeItem.id()}.`);
|
|
148
|
-
}
|
|
149
|
-
return violations;
|
|
150
|
-
}
|
|
151
|
-
/** Handles keydown events for the listbox. */
|
|
152
|
-
onKeydown(event) {
|
|
153
|
-
if (!this.disabled()) {
|
|
154
|
-
this.keydown().handle(event);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
onPointerdown(event) {
|
|
158
|
-
if (!this.disabled()) {
|
|
159
|
-
this.pointerdown().handle(event);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Sets the listbox to it's default initial state.
|
|
164
|
-
*
|
|
165
|
-
* Sets the active index of the listbox to the first focusable selected
|
|
166
|
-
* item if one exists. Otherwise, sets focus to the first focusable item.
|
|
167
|
-
*
|
|
168
|
-
* This method should be called once the listbox and it's options are properly initialized,
|
|
169
|
-
* meaning the ListboxPattern and OptionPatterns should have references to each other before this
|
|
170
|
-
* is called.
|
|
171
|
-
*/
|
|
172
|
-
setDefaultState() {
|
|
173
|
-
let firstItem = null;
|
|
174
|
-
for (const item of this.inputs.items()) {
|
|
175
|
-
if (this.listBehavior.isFocusable(item)) {
|
|
176
|
-
if (!firstItem) {
|
|
177
|
-
firstItem = item;
|
|
178
|
-
}
|
|
179
|
-
if (item.selected()) {
|
|
180
|
-
this.inputs.activeItem.set(item);
|
|
181
|
-
return;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
if (firstItem) {
|
|
186
|
-
this.inputs.activeItem.set(firstItem);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
_getItem(e) {
|
|
190
|
-
if (!(e.target instanceof HTMLElement)) {
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
|
-
const element = e.target.closest('[role="option"]');
|
|
194
|
-
return this.inputs.items().find(i => i.element() === element);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
/** Represents an option in a listbox. */
|
|
199
|
-
class OptionPattern {
|
|
200
|
-
/** A unique identifier for the option. */
|
|
201
|
-
id;
|
|
202
|
-
/** The value of the option. */
|
|
203
|
-
value;
|
|
204
|
-
/** The position of the option in the list. */
|
|
205
|
-
index = computed(() => this.listbox()?.inputs.items().indexOf(this) ?? -1);
|
|
206
|
-
/** Whether the option is active. */
|
|
207
|
-
active = computed(() => this.listbox()?.inputs.activeItem() === this);
|
|
208
|
-
/** Whether the option is selected. */
|
|
209
|
-
selected = computed(() => this.listbox()?.inputs.value().includes(this.value()));
|
|
210
|
-
/** Whether the option is disabled. */
|
|
211
|
-
disabled;
|
|
212
|
-
/** The text used by the typeahead search. */
|
|
213
|
-
searchTerm;
|
|
214
|
-
/** A reference to the parent listbox. */
|
|
215
|
-
listbox;
|
|
216
|
-
/** The tabindex of the option. */
|
|
217
|
-
tabindex = computed(() => this.listbox()?.listBehavior.getItemTabindex(this));
|
|
218
|
-
/** The html element that should receive focus. */
|
|
219
|
-
element;
|
|
220
|
-
constructor(args) {
|
|
221
|
-
this.id = args.id;
|
|
222
|
-
this.value = args.value;
|
|
223
|
-
this.listbox = args.listbox;
|
|
224
|
-
this.element = args.element;
|
|
225
|
-
this.disabled = args.disabled;
|
|
226
|
-
this.searchTerm = args.searchTerm;
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
export { ListboxPattern, OptionPattern };
|
|
231
|
-
//# sourceMappingURL=option.mjs.map
|
package/fesm2022/option.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"option.mjs","sources":["../../../../../darwin_arm64-fastbuild-ST-199a4f3c4e20/bin/src/cdk-experimental/ui-patterns/listbox/listbox.ts","../../../../../darwin_arm64-fastbuild-ST-199a4f3c4e20/bin/src/cdk-experimental/ui-patterns/listbox/option.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {OptionPattern} from './option';\nimport {KeyboardEventManager, PointerEventManager, Modifier} from '../behaviors/event-manager';\nimport {computed, signal} from '@angular/core';\nimport {SignalLike} from '../behaviors/signal-like/signal-like';\nimport {List, ListInputs} from '../behaviors/list/list';\n\n/** Represents the required inputs for a listbox. */\nexport type ListboxInputs<V> = ListInputs<OptionPattern<V>, V> & {\n readonly: SignalLike<boolean>;\n};\n\n/** Controls the state of a listbox. */\nexport class ListboxPattern<V> {\n listBehavior: List<OptionPattern<V>, V>;\n\n /** Whether the list is vertically or horizontally oriented. */\n orientation: SignalLike<'vertical' | 'horizontal'>;\n\n /** Whether the listbox is disabled. */\n disabled = computed(() => this.listBehavior.disabled());\n\n /** Whether the listbox is readonly. */\n readonly: SignalLike<boolean>;\n\n /** The tabindex of the listbox. */\n tabindex = computed(() => this.listBehavior.tabindex());\n\n /** The id of the current active item. */\n activedescendant = computed(() => this.listBehavior.activedescendant());\n\n /** Whether multiple items in the list can be selected at once. */\n multi: SignalLike<boolean>;\n\n /** The number of items in the listbox. */\n setsize = computed(() => this.inputs.items().length);\n\n /** Whether the listbox selection follows focus. */\n followFocus = computed(() => this.inputs.selectionMode() === 'follow');\n\n /** Whether the listbox should wrap. Used to disable wrapping while range selecting. */\n wrap = signal(true);\n\n /** The key used to navigate to the previous item in the list. */\n prevKey = computed(() => {\n if (this.inputs.orientation() === 'vertical') {\n return 'ArrowUp';\n }\n return this.inputs.textDirection() === 'rtl' ? 'ArrowRight' : 'ArrowLeft';\n });\n\n /** The key used to navigate to the next item in the list. */\n nextKey = computed(() => {\n if (this.inputs.orientation() === 'vertical') {\n return 'ArrowDown';\n }\n return this.inputs.textDirection() === 'rtl' ? 'ArrowLeft' : 'ArrowRight';\n });\n\n /** Represents the space key. Does nothing when the user is actively using typeahead. */\n dynamicSpaceKey = computed(() => (this.listBehavior.isTyping() ? '' : ' '));\n\n /** The regexp used to decide if a key should trigger typeahead. */\n typeaheadRegexp = /^.$/; // TODO: Ignore spaces?\n\n /** The keydown event manager for the listbox. */\n keydown = computed(() => {\n const manager = new KeyboardEventManager();\n\n if (this.readonly()) {\n return manager\n .on(this.prevKey, () => this.listBehavior.prev())\n .on(this.nextKey, () => this.listBehavior.next())\n .on('Home', () => this.listBehavior.first())\n .on('End', () => this.listBehavior.last())\n .on(this.typeaheadRegexp, e => this.listBehavior.search(e.key));\n }\n\n if (!this.followFocus()) {\n manager\n .on(this.prevKey, () => this.listBehavior.prev())\n .on(this.nextKey, () => this.listBehavior.next())\n .on('Home', () => this.listBehavior.first())\n .on('End', () => this.listBehavior.last())\n .on(this.typeaheadRegexp, e => this.listBehavior.search(e.key));\n }\n\n if (this.followFocus()) {\n manager\n .on(this.prevKey, () => this.listBehavior.prev({selectOne: true}))\n .on(this.nextKey, () => this.listBehavior.next({selectOne: true}))\n .on('Home', () => this.listBehavior.first({selectOne: true}))\n .on('End', () => this.listBehavior.last({selectOne: true}))\n .on(this.typeaheadRegexp, e => this.listBehavior.search(e.key, {selectOne: true}));\n }\n\n if (this.inputs.multi()) {\n manager\n .on(Modifier.Any, 'Shift', () => this.listBehavior.anchor(this.listBehavior.activeIndex()))\n .on(Modifier.Shift, this.prevKey, () => this.listBehavior.prev({selectRange: true}))\n .on(Modifier.Shift, this.nextKey, () => this.listBehavior.next({selectRange: true}))\n .on([Modifier.Ctrl | Modifier.Shift, Modifier.Meta | Modifier.Shift], 'Home', () =>\n this.listBehavior.first({selectRange: true, anchor: false}),\n )\n .on([Modifier.Ctrl | Modifier.Shift, Modifier.Meta | Modifier.Shift], 'End', () =>\n this.listBehavior.last({selectRange: true, anchor: false}),\n )\n .on(Modifier.Shift, 'Enter', () =>\n this.listBehavior.updateSelection({selectRange: true, anchor: false}),\n )\n .on(Modifier.Shift, this.dynamicSpaceKey, () =>\n this.listBehavior.updateSelection({selectRange: true, anchor: false}),\n );\n }\n\n if (!this.followFocus() && this.inputs.multi()) {\n manager\n .on(this.dynamicSpaceKey, () => this.listBehavior.toggle())\n .on('Enter', () => this.listBehavior.toggle())\n .on([Modifier.Ctrl, Modifier.Meta], 'A', () => this.listBehavior.toggleAll());\n }\n\n if (!this.followFocus() && !this.inputs.multi()) {\n manager.on(this.dynamicSpaceKey, () => this.listBehavior.toggleOne());\n manager.on('Enter', () => this.listBehavior.toggleOne());\n }\n\n if (this.inputs.multi() && this.followFocus()) {\n manager\n .on([Modifier.Ctrl, Modifier.Meta], this.prevKey, () => this.listBehavior.prev())\n .on([Modifier.Ctrl, Modifier.Meta], this.nextKey, () => this.listBehavior.next())\n .on([Modifier.Ctrl, Modifier.Meta], ' ', () => this.listBehavior.toggle())\n .on([Modifier.Ctrl, Modifier.Meta], 'Enter', () => this.listBehavior.toggle())\n .on([Modifier.Ctrl, Modifier.Meta], 'Home', () => this.listBehavior.first())\n .on([Modifier.Ctrl, Modifier.Meta], 'End', () => this.listBehavior.last())\n .on([Modifier.Ctrl, Modifier.Meta], 'A', () => {\n this.listBehavior.toggleAll();\n this.listBehavior.select(); // Ensure the currect option remains selected.\n });\n }\n\n return manager;\n });\n\n /** The pointerdown event manager for the listbox. */\n pointerdown = computed(() => {\n const manager = new PointerEventManager();\n\n if (this.readonly()) {\n return manager.on(e => this.listBehavior.goto(this._getItem(e)!));\n }\n\n if (this.multi()) {\n manager.on(Modifier.Shift, e =>\n this.listBehavior.goto(this._getItem(e)!, {selectRange: true}),\n );\n }\n\n if (!this.multi() && this.followFocus()) {\n return manager.on(e => this.listBehavior.goto(this._getItem(e)!, {selectOne: true}));\n }\n\n if (!this.multi() && !this.followFocus()) {\n return manager.on(e => this.listBehavior.goto(this._getItem(e)!, {toggle: true}));\n }\n\n if (this.multi() && this.followFocus()) {\n return manager\n .on(e => this.listBehavior.goto(this._getItem(e)!, {selectOne: true}))\n .on(Modifier.Ctrl, e => this.listBehavior.goto(this._getItem(e)!, {toggle: true}));\n }\n\n if (this.multi() && !this.followFocus()) {\n return manager.on(e => this.listBehavior.goto(this._getItem(e)!, {toggle: true}));\n }\n\n return manager;\n });\n\n constructor(readonly inputs: ListboxInputs<V>) {\n this.readonly = inputs.readonly;\n this.orientation = inputs.orientation;\n this.multi = inputs.multi;\n\n this.listBehavior = new List(inputs);\n }\n\n /** Returns a set of violations */\n validate(): string[] {\n const violations: string[] = [];\n\n if (!this.inputs.multi() && this.inputs.value().length > 1) {\n violations.push(\n `A single-select listbox should not have multiple selected options. Selected options: ${this.inputs.value().join(', ')}`,\n );\n }\n\n const activeItem = this.inputs.activeItem();\n\n if (activeItem && !this.inputs.items().includes(activeItem)) {\n violations.push(\n `The current active item does not exist in the list. Active item: ${activeItem.id()}.`,\n );\n }\n\n return violations;\n }\n\n /** Handles keydown events for the listbox. */\n onKeydown(event: KeyboardEvent) {\n if (!this.disabled()) {\n this.keydown().handle(event);\n }\n }\n\n onPointerdown(event: PointerEvent) {\n if (!this.disabled()) {\n this.pointerdown().handle(event);\n }\n }\n\n /**\n * Sets the listbox to it's default initial state.\n *\n * Sets the active index of the listbox to the first focusable selected\n * item if one exists. Otherwise, sets focus to the first focusable item.\n *\n * This method should be called once the listbox and it's options are properly initialized,\n * meaning the ListboxPattern and OptionPatterns should have references to each other before this\n * is called.\n */\n setDefaultState() {\n let firstItem: OptionPattern<V> | null = null;\n\n for (const item of this.inputs.items()) {\n if (this.listBehavior.isFocusable(item)) {\n if (!firstItem) {\n firstItem = item;\n }\n if (item.selected()) {\n this.inputs.activeItem.set(item);\n return;\n }\n }\n }\n\n if (firstItem) {\n this.inputs.activeItem.set(firstItem);\n }\n }\n\n private _getItem(e: PointerEvent) {\n if (!(e.target instanceof HTMLElement)) {\n return;\n }\n\n const element = e.target.closest('[role=\"option\"]');\n return this.inputs.items().find(i => i.element() === element);\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {computed} from '@angular/core';\nimport {SignalLike} from '../behaviors/signal-like/signal-like';\nimport {List, ListInputs, ListItem} from '../behaviors/list/list';\n\n/**\n * Represents the properties exposed by a listbox that need to be accessed by an option.\n * This exists to avoid circular dependency errors between the listbox and option.\n */\ninterface ListboxPattern<V> {\n inputs: ListInputs<OptionPattern<V>, V>;\n listBehavior: List<OptionPattern<V>, V>;\n}\n\n/** Represents the required inputs for an option in a listbox. */\nexport interface OptionInputs<V> extends Omit<ListItem<V>, 'index'> {\n listbox: SignalLike<ListboxPattern<V> | undefined>;\n}\n\n/** Represents an option in a listbox. */\nexport class OptionPattern<V> {\n /** A unique identifier for the option. */\n id: SignalLike<string>;\n\n /** The value of the option. */\n value: SignalLike<V>;\n\n /** The position of the option in the list. */\n index = computed(() => this.listbox()?.inputs.items().indexOf(this) ?? -1);\n\n /** Whether the option is active. */\n active = computed(() => this.listbox()?.inputs.activeItem() === this);\n\n /** Whether the option is selected. */\n selected = computed(() => this.listbox()?.inputs.value().includes(this.value()));\n\n /** Whether the option is disabled. */\n disabled: SignalLike<boolean>;\n\n /** The text used by the typeahead search. */\n searchTerm: SignalLike<string>;\n\n /** A reference to the parent listbox. */\n listbox: SignalLike<ListboxPattern<V> | undefined>;\n\n /** The tabindex of the option. */\n tabindex = computed(() => this.listbox()?.listBehavior.getItemTabindex(this));\n\n /** The html element that should receive focus. */\n element: SignalLike<HTMLElement>;\n\n constructor(args: OptionInputs<V>) {\n this.id = args.id;\n this.value = args.value;\n this.listbox = args.listbox;\n this.element = args.element;\n this.disabled = args.disabled;\n this.searchTerm = args.searchTerm;\n }\n}\n"],"names":[],"mappings":";;;;AAmBA;MACa,cAAc,CAAA;AAsKJ,IAAA,MAAA;AArKrB,IAAA,YAAY;;AAGZ,IAAA,WAAW;;AAGX,IAAA,QAAQ,GAAG,QAAQ,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC;;AAGvD,IAAA,QAAQ;;AAGR,IAAA,QAAQ,GAAG,QAAQ,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC;;AAGvD,IAAA,gBAAgB,GAAG,QAAQ,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,gBAAgB,EAAE,CAAC;;AAGvE,IAAA,KAAK;;AAGL,IAAA,OAAO,GAAG,QAA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AExB,IAAA,EAAE;;AAGF,IAAA,KAAK;;IAGL,KAAK,GAAG,QAAQ,CAAC,MAAM,IAAI,CAAC,OAAO,EAAE,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;;AAG1E,IAAA,MAAM,GAAG,QAAQ,CAAC,MAAM,IAAI,CAAC,OAAO,EAAE,EAAE,MAAM,CAAC,UAAU,EAAE,KAAK,IAAI,CAAC;;IAGrE,QAAQ,GAAG,QAAQ,CAAC,MAAM,IAAI,CAAC,OAAO,EAAE,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;;AAGhF,IAAA,QAAQ;;AAGR,IAAA,UAAU;;AAGV,IAAA,OAAO;;AAGP,IAAA,QAAQ,GAAG,QAAQ,CAAC,MAAM,IAAI,CAAC,OAAO,EAAE,EAAE,YAAY,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;;AAG7E,IAAA,OAAO;AAEP,IAAA,WAAA,CAAY,IAAqB,EAAA;AAC/B,QAAA,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE;AACjB,QAAA,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK;AACvB,QAAA,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO;AAC3B,QAAA,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO;AAC3B,QAAA,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ;AAC7B,QAAA,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU;;AAEpC;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"polyfill.mjs","sources":["../../../../../darwin_arm64-fastbuild-ST-199a4f3c4e20/bin/src/cdk-experimental/popover-edit/polyfill.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\n/** closest implementation that is able to start from non-Element Nodes. */\nexport function closest(\n element: EventTarget | Element | null | undefined,\n selector: string,\n): Element | null {\n if (!(element instanceof Node)) {\n return null;\n }\n\n let curr: Node | null = element;\n while (curr != null && !(curr instanceof Element)) {\n curr = curr.parentNode;\n }\n\n return curr?.closest(selector) ?? null;\n}\n"],"names":[],"mappings":"AAQA;AACgB,SAAA,OAAO,CACrB,OAAiD,EACjD,QAAgB,EAAA;AAEhB,IAAA,IAAI,EAAE,OAAO,YAAY,IAAI,CAAC,EAAE;AAC9B,QAAA,OAAO,IAAI;;IAGb,IAAI,IAAI,GAAgB,OAAO;IAC/B,OAAO,IAAI,IAAI,IAAI,IAAI,EAAE,IAAI,YAAY,OAAO,CAAC,EAAE;AACjD,QAAA,IAAI,GAAG,IAAI,CAAC,UAAU;;IAGxB,OAAO,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,IAAI,IAAI;AACxC;;;;"}
|
package/fesm2022/radio-group.mjs
DELETED
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
import * as i0 from '@angular/core';
|
|
2
|
-
import { inject, ElementRef, contentChildren, computed, input, booleanAttribute, model, signal, afterRenderEffect, Directive, linkedSignal } from '@angular/core';
|
|
3
|
-
import { Directionality } from '@angular/cdk/bidi';
|
|
4
|
-
import { _IdGenerator } from '@angular/cdk/a11y';
|
|
5
|
-
import { CdkToolbar } from './toolbar.mjs';
|
|
6
|
-
import { RadioGroupPattern } from './radio-group2.mjs';
|
|
7
|
-
import { RadioButtonPattern } from './toolbar2.mjs';
|
|
8
|
-
import './list.mjs';
|
|
9
|
-
import './list-navigation.mjs';
|
|
10
|
-
|
|
11
|
-
// TODO: Move mapSignal to it's own file so it can be reused across components.
|
|
12
|
-
/**
|
|
13
|
-
* Creates a new writable signal (signal V) whose value is connected to the given original
|
|
14
|
-
* writable signal (signal T) such that updating signal V updates signal T and vice-versa.
|
|
15
|
-
*
|
|
16
|
-
* This function establishes a two-way synchronization between the source signal and the new mapped
|
|
17
|
-
* signal. When the source signal changes, the mapped signal updates by applying the `transform`
|
|
18
|
-
* function. When the mapped signal is explicitly set or updated, the change is propagated back to
|
|
19
|
-
* the source signal by applying the `reverse` function.
|
|
20
|
-
*/
|
|
21
|
-
function mapSignal(originalSignal, operations) {
|
|
22
|
-
const mappedSignal = linkedSignal(() => operations.transform(originalSignal()));
|
|
23
|
-
const updateMappedSignal = mappedSignal.update;
|
|
24
|
-
const setMappedSignal = mappedSignal.set;
|
|
25
|
-
mappedSignal.set = (newValue) => {
|
|
26
|
-
setMappedSignal(newValue);
|
|
27
|
-
originalSignal.set(operations.reverse(newValue));
|
|
28
|
-
};
|
|
29
|
-
mappedSignal.update = (updateFn) => {
|
|
30
|
-
updateMappedSignal(oldValue => updateFn(oldValue));
|
|
31
|
-
originalSignal.update(oldValue => operations.reverse(updateFn(operations.transform(oldValue))));
|
|
32
|
-
};
|
|
33
|
-
return mappedSignal;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* A radio button group container.
|
|
37
|
-
*
|
|
38
|
-
* Radio groups are used to group multiple radio buttons or radio group labels so they function as
|
|
39
|
-
* a single form control. The CdkRadioGroup is meant to be used in conjunction with CdkRadioButton
|
|
40
|
-
* as follows:
|
|
41
|
-
*
|
|
42
|
-
* ```html
|
|
43
|
-
* <div cdkRadioGroup>
|
|
44
|
-
* <label cdkRadioButton value="1">Option 1</label>
|
|
45
|
-
* <label cdkRadioButton value="2">Option 2</label>
|
|
46
|
-
* <label cdkRadioButton value="3">Option 3</label>
|
|
47
|
-
* </div>
|
|
48
|
-
* ```
|
|
49
|
-
*/
|
|
50
|
-
class CdkRadioGroup {
|
|
51
|
-
/** A reference to the radio group element. */
|
|
52
|
-
_elementRef = inject(ElementRef);
|
|
53
|
-
/** The CdkRadioButtons nested inside of the CdkRadioGroup. */
|
|
54
|
-
_cdkRadioButtons = contentChildren(CdkRadioButton, ...(ngDevMode ? [{ debugName: "_cdkRadioButtons", descendants: true }] : [{ descendants: true }]));
|
|
55
|
-
/** A signal wrapper for directionality. */
|
|
56
|
-
textDirection = inject(Directionality).valueSignal;
|
|
57
|
-
/** A signal wrapper for toolbar. */
|
|
58
|
-
toolbar = inject(CdkToolbar, { optional: true });
|
|
59
|
-
/** Toolbar pattern if applicable */
|
|
60
|
-
_toolbarPattern = computed(() => this.toolbar?.pattern, ...(ngDevMode ? [{ debugName: "_toolbarPattern" }] : []));
|
|
61
|
-
/** The RadioButton UIPatterns of the child CdkRadioButtons. */
|
|
62
|
-
items = computed(() => this._cdkRadioButtons().map(radio => radio.pattern), ...(ngDevMode ? [{ debugName: "items" }] : []));
|
|
63
|
-
/** Whether the radio group is vertically or horizontally oriented. */
|
|
64
|
-
orientation = input('vertical', ...(ngDevMode ? [{ debugName: "orientation" }] : []));
|
|
65
|
-
/** Whether disabled items in the group should be skipped when navigating. */
|
|
66
|
-
skipDisabled = input(true, ...(ngDevMode ? [{ debugName: "skipDisabled", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
|
|
67
|
-
/** The focus strategy used by the radio group. */
|
|
68
|
-
focusMode = input('roving', ...(ngDevMode ? [{ debugName: "focusMode" }] : []));
|
|
69
|
-
/** Whether the radio group is disabled. */
|
|
70
|
-
disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
|
|
71
|
-
/** Whether the radio group is readonly. */
|
|
72
|
-
readonly = input(false, ...(ngDevMode ? [{ debugName: "readonly", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
|
|
73
|
-
/** The value of the currently selected radio button. */
|
|
74
|
-
value = model(null, ...(ngDevMode ? [{ debugName: "value" }] : []));
|
|
75
|
-
/** The internal selection state for the radio group. */
|
|
76
|
-
_value = mapSignal(this.value, {
|
|
77
|
-
transform: value => (value !== null ? [value] : []),
|
|
78
|
-
reverse: values => (values.length === 0 ? null : values[0]),
|
|
79
|
-
});
|
|
80
|
-
/** The RadioGroup UIPattern. */
|
|
81
|
-
pattern = new RadioGroupPattern({
|
|
82
|
-
...this,
|
|
83
|
-
items: this.items,
|
|
84
|
-
value: this._value,
|
|
85
|
-
activeItem: signal(undefined),
|
|
86
|
-
textDirection: this.textDirection,
|
|
87
|
-
toolbar: this._toolbarPattern,
|
|
88
|
-
element: () => this._elementRef.nativeElement,
|
|
89
|
-
focusMode: this._toolbarPattern()?.inputs.focusMode ?? this.focusMode,
|
|
90
|
-
skipDisabled: this._toolbarPattern()?.inputs.skipDisabled ?? this.skipDisabled,
|
|
91
|
-
});
|
|
92
|
-
/** Whether the radio group has received focus yet. */
|
|
93
|
-
_hasFocused = signal(false, ...(ngDevMode ? [{ debugName: "_hasFocused" }] : []));
|
|
94
|
-
constructor() {
|
|
95
|
-
afterRenderEffect(() => {
|
|
96
|
-
if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
|
97
|
-
const violations = this.pattern.validate();
|
|
98
|
-
for (const violation of violations) {
|
|
99
|
-
console.error(violation);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
afterRenderEffect(() => {
|
|
104
|
-
if (!this._hasFocused() && !this.toolbar) {
|
|
105
|
-
this.pattern.setDefaultState();
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
// TODO: Refactor to be handled within list behavior
|
|
109
|
-
afterRenderEffect(() => {
|
|
110
|
-
if (this.toolbar) {
|
|
111
|
-
const radioButtons = this._cdkRadioButtons();
|
|
112
|
-
// If the group is disabled and the toolbar is set to skip disabled items,
|
|
113
|
-
// the radio buttons should not be part of the toolbar's navigation.
|
|
114
|
-
if (this.disabled() && this.toolbar.skipDisabled()) {
|
|
115
|
-
radioButtons.forEach(radio => this.toolbar.unregister(radio));
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
radioButtons.forEach(radio => this.toolbar.register(radio));
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
onFocus() {
|
|
124
|
-
this._hasFocused.set(true);
|
|
125
|
-
}
|
|
126
|
-
toolbarButtonUnregister(radio) {
|
|
127
|
-
if (this.toolbar) {
|
|
128
|
-
this.toolbar.unregister(radio);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.0-next.2", ngImport: i0, type: CdkRadioGroup, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
132
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "20.2.0-next.2", type: CdkRadioGroup, isStandalone: true, selector: "[cdkRadioGroup]", inputs: { orientation: { classPropertyName: "orientation", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null }, skipDisabled: { classPropertyName: "skipDisabled", publicName: "skipDisabled", isSignal: true, isRequired: false, transformFunction: null }, focusMode: { classPropertyName: "focusMode", publicName: "focusMode", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange" }, host: { attributes: { "role": "radiogroup" }, listeners: { "keydown": "pattern.onKeydown($event)", "pointerdown": "pattern.onPointerdown($event)", "focusin": "onFocus()" }, properties: { "attr.tabindex": "pattern.tabindex()", "attr.aria-readonly": "pattern.readonly()", "attr.aria-disabled": "pattern.disabled()", "attr.aria-orientation": "pattern.orientation()", "attr.aria-activedescendant": "pattern.activedescendant()" }, classAttribute: "cdk-radio-group" }, queries: [{ propertyName: "_cdkRadioButtons", predicate: CdkRadioButton, descendants: true, isSignal: true }], exportAs: ["cdkRadioGroup"], ngImport: i0 });
|
|
133
|
-
}
|
|
134
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.0-next.2", ngImport: i0, type: CdkRadioGroup, decorators: [{
|
|
135
|
-
type: Directive,
|
|
136
|
-
args: [{
|
|
137
|
-
selector: '[cdkRadioGroup]',
|
|
138
|
-
exportAs: 'cdkRadioGroup',
|
|
139
|
-
host: {
|
|
140
|
-
'role': 'radiogroup',
|
|
141
|
-
'class': 'cdk-radio-group',
|
|
142
|
-
'[attr.tabindex]': 'pattern.tabindex()',
|
|
143
|
-
'[attr.aria-readonly]': 'pattern.readonly()',
|
|
144
|
-
'[attr.aria-disabled]': 'pattern.disabled()',
|
|
145
|
-
'[attr.aria-orientation]': 'pattern.orientation()',
|
|
146
|
-
'[attr.aria-activedescendant]': 'pattern.activedescendant()',
|
|
147
|
-
'(keydown)': 'pattern.onKeydown($event)',
|
|
148
|
-
'(pointerdown)': 'pattern.onPointerdown($event)',
|
|
149
|
-
'(focusin)': 'onFocus()',
|
|
150
|
-
},
|
|
151
|
-
}]
|
|
152
|
-
}], ctorParameters: () => [] });
|
|
153
|
-
/** A selectable radio button in a CdkRadioGroup. */
|
|
154
|
-
class CdkRadioButton {
|
|
155
|
-
/** A reference to the radio button element. */
|
|
156
|
-
_elementRef = inject(ElementRef);
|
|
157
|
-
/** The parent CdkRadioGroup. */
|
|
158
|
-
_cdkRadioGroup = inject(CdkRadioGroup);
|
|
159
|
-
/** A unique identifier for the radio button. */
|
|
160
|
-
_generatedId = inject(_IdGenerator).getId('cdk-radio-button-');
|
|
161
|
-
/** A unique identifier for the radio button. */
|
|
162
|
-
id = computed(() => this._generatedId, ...(ngDevMode ? [{ debugName: "id" }] : []));
|
|
163
|
-
/** The value associated with the radio button. */
|
|
164
|
-
value = input.required(...(ngDevMode ? [{ debugName: "value" }] : []));
|
|
165
|
-
/** The parent RadioGroup UIPattern. */
|
|
166
|
-
group = computed(() => this._cdkRadioGroup.pattern, ...(ngDevMode ? [{ debugName: "group" }] : []));
|
|
167
|
-
/** A reference to the radio button element to be focused on navigation. */
|
|
168
|
-
element = computed(() => this._elementRef.nativeElement, ...(ngDevMode ? [{ debugName: "element" }] : []));
|
|
169
|
-
/** Whether the radio button is disabled. */
|
|
170
|
-
disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
|
|
171
|
-
/** The RadioButton UIPattern. */
|
|
172
|
-
pattern = new RadioButtonPattern({
|
|
173
|
-
...this,
|
|
174
|
-
id: this.id,
|
|
175
|
-
value: this.value,
|
|
176
|
-
group: this.group,
|
|
177
|
-
element: this.element,
|
|
178
|
-
});
|
|
179
|
-
ngOnDestroy() {
|
|
180
|
-
if (this._cdkRadioGroup.toolbar) {
|
|
181
|
-
this._cdkRadioGroup.toolbarButtonUnregister(this);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.0-next.2", ngImport: i0, type: CdkRadioButton, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
185
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.2.0-next.2", type: CdkRadioButton, isStandalone: true, selector: "[cdkRadioButton]", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: true, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "radio" }, properties: { "class.cdk-active": "pattern.active()", "attr.tabindex": "pattern.tabindex()", "attr.aria-checked": "pattern.selected()", "attr.aria-disabled": "pattern.disabled()", "id": "pattern.id()" }, classAttribute: "cdk-radio-button" }, exportAs: ["cdkRadioButton"], ngImport: i0 });
|
|
186
|
-
}
|
|
187
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.0-next.2", ngImport: i0, type: CdkRadioButton, decorators: [{
|
|
188
|
-
type: Directive,
|
|
189
|
-
args: [{
|
|
190
|
-
selector: '[cdkRadioButton]',
|
|
191
|
-
exportAs: 'cdkRadioButton',
|
|
192
|
-
host: {
|
|
193
|
-
'role': 'radio',
|
|
194
|
-
'class': 'cdk-radio-button',
|
|
195
|
-
'[class.cdk-active]': 'pattern.active()',
|
|
196
|
-
'[attr.tabindex]': 'pattern.tabindex()',
|
|
197
|
-
'[attr.aria-checked]': 'pattern.selected()',
|
|
198
|
-
'[attr.aria-disabled]': 'pattern.disabled()',
|
|
199
|
-
'[id]': 'pattern.id()',
|
|
200
|
-
},
|
|
201
|
-
}]
|
|
202
|
-
}] });
|
|
203
|
-
|
|
204
|
-
export { CdkRadioButton, CdkRadioGroup };
|
|
205
|
-
//# sourceMappingURL=radio-group.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"radio-group.mjs","sources":["../../../../../darwin_arm64-fastbuild-ST-199a4f3c4e20/bin/src/cdk-experimental/radio-group/radio-group.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {\n afterRenderEffect,\n booleanAttribute,\n computed,\n contentChildren,\n Directive,\n ElementRef,\n inject,\n input,\n linkedSignal,\n model,\n signal,\n WritableSignal,\n OnDestroy,\n} from '@angular/core';\nimport {RadioButtonPattern, RadioGroupPattern} from '../ui-patterns';\nimport {Directionality} from '@angular/cdk/bidi';\nimport {_IdGenerator} from '@angular/cdk/a11y';\nimport {CdkToolbar} from '../toolbar';\n\n// TODO: Move mapSignal to it's own file so it can be reused across components.\n\n/**\n * Creates a new writable signal (signal V) whose value is connected to the given original\n * writable signal (signal T) such that updating signal V updates signal T and vice-versa.\n *\n * This function establishes a two-way synchronization between the source signal and the new mapped\n * signal. When the source signal changes, the mapped signal updates by applying the `transform`\n * function. When the mapped signal is explicitly set or updated, the change is propagated back to\n * the source signal by applying the `reverse` function.\n */\nexport function mapSignal<T, V>(\n originalSignal: WritableSignal<T>,\n operations: {\n transform: (value: T) => V;\n reverse: (value: V) => T;\n },\n) {\n const mappedSignal = linkedSignal(() => operations.transform(originalSignal()));\n const updateMappedSignal = mappedSignal.update;\n const setMappedSignal = mappedSignal.set;\n\n mappedSignal.set = (newValue: V) => {\n setMappedSignal(newValue);\n originalSignal.set(operations.reverse(newValue));\n };\n\n mappedSignal.update = (updateFn: (value: V) => V) => {\n updateMappedSignal(oldValue => updateFn(oldValue));\n originalSignal.update(oldValue => operations.reverse(updateFn(operations.transform(oldValue))));\n };\n\n return mappedSignal;\n}\n\n/**\n * A radio button group container.\n *\n * Radio groups are used to group multiple radio buttons or radio group labels so they function as\n * a single form control. The CdkRadioGroup is meant to be used in conjunction with CdkRadioButton\n * as follows:\n *\n * ```html\n * <div cdkRadioGroup>\n * <label cdkRadioButton value=\"1\">Option 1</label>\n * <label cdkRadioButton value=\"2\">Option 2</label>\n * <label cdkRadioButton value=\"3\">Option 3</label>\n * </div>\n * ```\n */\n@Directive({\n selector: '[cdkRadioGroup]',\n exportAs: 'cdkRadioGroup',\n host: {\n 'role': 'radiogroup',\n 'class': 'cdk-radio-group',\n '[attr.tabindex]': 'pattern.tabindex()',\n '[attr.aria-readonly]': 'pattern.readonly()',\n '[attr.aria-disabled]': 'pattern.disabled()',\n '[attr.aria-orientation]': 'pattern.orientation()',\n '[attr.aria-activedescendant]': 'pattern.activedescendant()',\n '(keydown)': 'pattern.onKeydown($event)',\n '(pointerdown)': 'pattern.onPointerdown($event)',\n '(focusin)': 'onFocus()',\n },\n})\nexport class CdkRadioGroup<V> {\n /** A reference to the radio group element. */\n private readonly _elementRef = inject(ElementRef);\n\n /** The CdkRadioButtons nested inside of the CdkRadioGroup. */\n private readonly _cdkRadioButtons = contentChildren(CdkRadioButton, {descendants: true});\n\n /** A signal wrapper for directionality. */\n protected textDirection = inject(Directionality).valueSignal;\n\n /** A signal wrapper for toolbar. */\n toolbar = inject(CdkToolbar, {optional: true});\n\n /** Toolbar pattern if applicable */\n private readonly _toolbarPattern = computed(() => this.toolbar?.pattern);\n\n /** The RadioButton UIPatterns of the child CdkRadioButtons. */\n protected items = computed(() => this._cdkRadioButtons().map(radio => radio.pattern));\n\n /** Whether the radio group is vertically or horizontally oriented. */\n orientation = input<'vertical' | 'horizontal'>('vertical');\n\n /** Whether disabled items in the group should be skipped when navigating. */\n skipDisabled = input(true, {transform: booleanAttribute});\n\n /** The focus strategy used by the radio group. */\n focusMode = input<'roving' | 'activedescendant'>('roving');\n\n /** Whether the radio group is disabled. */\n disabled = input(false, {transform: booleanAttribute});\n\n /** Whether the radio group is readonly. */\n readonly = input(false, {transform: booleanAttribute});\n\n /** The value of the currently selected radio button. */\n value = model<V | null>(null);\n\n /** The internal selection state for the radio group. */\n private readonly _value = mapSignal<V | null, V[]>(this.value, {\n transform: value => (value !== null ? [value] : []),\n reverse: values => (values.length === 0 ? null : values[0]),\n });\n\n /** The RadioGroup UIPattern. */\n pattern: RadioGroupPattern<V> = new RadioGroupPattern<V>({\n ...this,\n items: this.items,\n value: this._value,\n activeItem: signal(undefined),\n textDirection: this.textDirection,\n toolbar: this._toolbarPattern,\n element: () => this._elementRef.nativeElement,\n focusMode: this._toolbarPattern()?.inputs.focusMode ?? this.focusMode,\n skipDisabled: this._toolbarPattern()?.inputs.skipDisabled ?? this.skipDisabled,\n });\n\n /** Whether the radio group has received focus yet. */\n private _hasFocused = signal(false);\n\n constructor() {\n afterRenderEffect(() => {\n if (typeof ngDevMode === 'undefined' || ngDevMode) {\n const violations = this.pattern.validate();\n for (const violation of violations) {\n console.error(violation);\n }\n }\n });\n\n afterRenderEffect(() => {\n if (!this._hasFocused() && !this.toolbar) {\n this.pattern.setDefaultState();\n }\n });\n\n // TODO: Refactor to be handled within list behavior\n afterRenderEffect(() => {\n if (this.toolbar) {\n const radioButtons = this._cdkRadioButtons();\n // If the group is disabled and the toolbar is set to skip disabled items,\n // the radio buttons should not be part of the toolbar's navigation.\n if (this.disabled() && this.toolbar.skipDisabled()) {\n radioButtons.forEach(radio => this.toolbar!.unregister(radio));\n } else {\n radioButtons.forEach(radio => this.toolbar!.register(radio));\n }\n }\n });\n }\n\n onFocus() {\n this._hasFocused.set(true);\n }\n\n toolbarButtonUnregister(radio: CdkRadioButton<V>) {\n if (this.toolbar) {\n this.toolbar.unregister(radio);\n }\n }\n}\n\n/** A selectable radio button in a CdkRadioGroup. */\n@Directive({\n selector: '[cdkRadioButton]',\n exportAs: 'cdkRadioButton',\n host: {\n 'role': 'radio',\n 'class': 'cdk-radio-button',\n '[class.cdk-active]': 'pattern.active()',\n '[attr.tabindex]': 'pattern.tabindex()',\n '[attr.aria-checked]': 'pattern.selected()',\n '[attr.aria-disabled]': 'pattern.disabled()',\n '[id]': 'pattern.id()',\n },\n})\nexport class CdkRadioButton<V> implements OnDestroy {\n /** A reference to the radio button element. */\n private readonly _elementRef = inject(ElementRef);\n\n /** The parent CdkRadioGroup. */\n private readonly _cdkRadioGroup = inject(CdkRadioGroup);\n\n /** A unique identifier for the radio button. */\n private readonly _generatedId = inject(_IdGenerator).getId('cdk-radio-button-');\n\n /** A unique identifier for the radio button. */\n protected id = computed(() => this._generatedId);\n\n /** The value associated with the radio button. */\n readonly value = input.required<V>();\n\n /** The parent RadioGroup UIPattern. */\n protected group = computed(() => this._cdkRadioGroup.pattern);\n\n /** A reference to the radio button element to be focused on navigation. */\n element = computed(() => this._elementRef.nativeElement);\n\n /** Whether the radio button is disabled. */\n disabled = input(false, {transform: booleanAttribute});\n\n /** The RadioButton UIPattern. */\n pattern = new RadioButtonPattern<V>({\n ...this,\n id: this.id,\n value: this.value,\n group: this.group,\n element: this.element,\n });\n\n ngOnDestroy() {\n if (this._cdkRadioGroup.toolbar) {\n this._cdkRadioGroup.toolbarButtonUnregister(this);\n }\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;AA4BA;AAEA;;;;;;;;AAQG;AACa,SAAA,SAAS,CACvB,cAAiC,EACjC,UAGC,EAAA;AAED,IAAA,MAAM,YAAY,GAAG,YAAY,CAAC,MAAM,UAAU,CAAC,SAAS,CAAC,cAAc,EAAE,C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