@angular/aria 21.0.0-next.8 → 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.
- package/_adev_assets/aria-accordion.json +373 -0
- package/_adev_assets/aria-combobox.json +383 -0
- package/_adev_assets/aria-grid.json +578 -0
- package/_adev_assets/aria-listbox.json +511 -0
- package/_adev_assets/aria-menu.json +752 -0
- package/_adev_assets/aria-radio-group.json +389 -0
- package/_adev_assets/aria-tabs.json +987 -0
- package/_adev_assets/aria-toolbar.json +717 -0
- package/_adev_assets/aria-tree.json +1067 -0
- package/fesm2022/_widget-chunk.mjs +827 -0
- package/fesm2022/_widget-chunk.mjs.map +1 -0
- package/fesm2022/accordion.mjs +371 -172
- package/fesm2022/accordion.mjs.map +1 -1
- package/fesm2022/aria.mjs +1 -2
- package/fesm2022/aria.mjs.map +1 -1
- package/fesm2022/combobox.mjs +304 -114
- package/fesm2022/combobox.mjs.map +1 -1
- package/fesm2022/deferred-content.mjs +89 -49
- package/fesm2022/deferred-content.mjs.map +1 -1
- package/fesm2022/grid.mjs +517 -0
- package/fesm2022/grid.mjs.map +1 -0
- package/fesm2022/listbox.mjs +384 -183
- package/fesm2022/listbox.mjs.map +1 -1
- package/fesm2022/menu.mjs +535 -0
- package/fesm2022/menu.mjs.map +1 -0
- package/fesm2022/private.mjs +2347 -0
- package/fesm2022/private.mjs.map +1 -0
- package/fesm2022/radio-group.mjs +320 -179
- package/fesm2022/radio-group.mjs.map +1 -1
- package/fesm2022/tabs.mjs +483 -274
- package/fesm2022/tabs.mjs.map +1 -1
- package/fesm2022/toolbar.mjs +330 -199
- package/fesm2022/toolbar.mjs.map +1 -1
- package/fesm2022/tree.mjs +511 -309
- package/fesm2022/tree.mjs.map +1 -1
- package/package.json +14 -6
- package/types/_grid-chunk.d.ts +546 -0
- package/types/accordion.d.ts +4 -4
- package/types/combobox.d.ts +18 -5
- package/types/deferred-content.d.ts +1 -0
- package/types/grid.d.ts +111 -0
- package/types/listbox.d.ts +6 -3
- package/types/menu.d.ts +158 -0
- package/types/{ui-patterns.d.ts → private.d.ts} +333 -133
- package/types/radio-group.d.ts +5 -3
- package/types/tabs.d.ts +4 -4
- package/types/toolbar.d.ts +4 -4
- package/types/tree.d.ts +17 -32
- package/fesm2022/ui-patterns.mjs +0 -2504
- package/fesm2022/ui-patterns.mjs.map +0 -1
package/fesm2022/radio-group.mjs
CHANGED
|
@@ -1,197 +1,338 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { inject, ElementRef, computed, contentChildren, input, booleanAttribute, model, signal, afterRenderEffect, Directive, linkedSignal } from '@angular/core';
|
|
3
|
-
import { ToolbarRadioGroupPattern, RadioGroupPattern, RadioButtonPattern } from '@angular/aria/
|
|
3
|
+
import { ToolbarRadioGroupPattern, RadioGroupPattern, RadioButtonPattern } from '@angular/aria/private';
|
|
4
4
|
import { Directionality } from '@angular/cdk/bidi';
|
|
5
5
|
import { _IdGenerator } from '@angular/cdk/a11y';
|
|
6
6
|
import * as i1 from '@angular/aria/toolbar';
|
|
7
7
|
import { ToolbarWidgetGroup } from '@angular/aria/toolbar';
|
|
8
8
|
|
|
9
|
-
// TODO: Move mapSignal to it's own file so it can be reused across components.
|
|
10
|
-
/**
|
|
11
|
-
* Creates a new writable signal (signal V) whose value is connected to the given original
|
|
12
|
-
* writable signal (signal T) such that updating signal V updates signal T and vice-versa.
|
|
13
|
-
*
|
|
14
|
-
* This function establishes a two-way synchronization between the source signal and the new mapped
|
|
15
|
-
* signal. When the source signal changes, the mapped signal updates by applying the `transform`
|
|
16
|
-
* function. When the mapped signal is explicitly set or updated, the change is propagated back to
|
|
17
|
-
* the source signal by applying the `reverse` function.
|
|
18
|
-
*/
|
|
19
9
|
function mapSignal(originalSignal, operations) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
10
|
+
const mappedSignal = linkedSignal(() => operations.transform(originalSignal()));
|
|
11
|
+
const updateMappedSignal = mappedSignal.update;
|
|
12
|
+
const setMappedSignal = mappedSignal.set;
|
|
13
|
+
mappedSignal.set = newValue => {
|
|
14
|
+
setMappedSignal(newValue);
|
|
15
|
+
originalSignal.set(operations.reverse(newValue));
|
|
16
|
+
};
|
|
17
|
+
mappedSignal.update = updateFn => {
|
|
18
|
+
updateMappedSignal(oldValue => updateFn(oldValue));
|
|
19
|
+
originalSignal.update(oldValue => operations.reverse(updateFn(operations.transform(oldValue))));
|
|
20
|
+
};
|
|
21
|
+
return mappedSignal;
|
|
32
22
|
}
|
|
33
|
-
/**
|
|
34
|
-
* A radio button group container.
|
|
35
|
-
*
|
|
36
|
-
* Radio groups are used to group multiple radio buttons or radio group labels so they function as
|
|
37
|
-
* a single form control. The RadioGroup is meant to be used in conjunction with RadioButton
|
|
38
|
-
* as follows:
|
|
39
|
-
*
|
|
40
|
-
* ```html
|
|
41
|
-
* <div ngRadioGroup>
|
|
42
|
-
* <div ngRadioButton value="1">Option 1</div>
|
|
43
|
-
* <div ngRadioButton value="2">Option 2</div>
|
|
44
|
-
* <div ngRadioButton value="3">Option 3</div>
|
|
45
|
-
* </div>
|
|
46
|
-
* ```
|
|
47
|
-
*/
|
|
48
23
|
class RadioGroup {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
24
|
+
_elementRef = inject(ElementRef);
|
|
25
|
+
_toolbarWidgetGroup = inject(ToolbarWidgetGroup);
|
|
26
|
+
_hasToolbar = computed(() => !!this._toolbarWidgetGroup.toolbar(), ...(ngDevMode ? [{
|
|
27
|
+
debugName: "_hasToolbar"
|
|
28
|
+
}] : []));
|
|
29
|
+
_radioButtons = contentChildren(RadioButton, ...(ngDevMode ? [{
|
|
30
|
+
debugName: "_radioButtons",
|
|
31
|
+
descendants: true
|
|
32
|
+
}] : [{
|
|
33
|
+
descendants: true
|
|
34
|
+
}]));
|
|
35
|
+
textDirection = inject(Directionality).valueSignal;
|
|
36
|
+
items = computed(() => this._radioButtons().map(radio => radio._pattern), ...(ngDevMode ? [{
|
|
37
|
+
debugName: "items"
|
|
38
|
+
}] : []));
|
|
39
|
+
orientation = input('vertical', ...(ngDevMode ? [{
|
|
40
|
+
debugName: "orientation"
|
|
41
|
+
}] : []));
|
|
42
|
+
skipDisabled = input(true, ...(ngDevMode ? [{
|
|
43
|
+
debugName: "skipDisabled",
|
|
44
|
+
transform: booleanAttribute
|
|
45
|
+
}] : [{
|
|
46
|
+
transform: booleanAttribute
|
|
47
|
+
}]));
|
|
48
|
+
focusMode = input('roving', ...(ngDevMode ? [{
|
|
49
|
+
debugName: "focusMode"
|
|
50
|
+
}] : []));
|
|
51
|
+
disabled = input(false, ...(ngDevMode ? [{
|
|
52
|
+
debugName: "disabled",
|
|
53
|
+
transform: booleanAttribute
|
|
54
|
+
}] : [{
|
|
55
|
+
transform: booleanAttribute
|
|
56
|
+
}]));
|
|
57
|
+
readonly = input(false, ...(ngDevMode ? [{
|
|
58
|
+
debugName: "readonly",
|
|
59
|
+
transform: booleanAttribute
|
|
60
|
+
}] : [{
|
|
61
|
+
transform: booleanAttribute
|
|
62
|
+
}]));
|
|
63
|
+
value = model(null, ...(ngDevMode ? [{
|
|
64
|
+
debugName: "value"
|
|
65
|
+
}] : []));
|
|
66
|
+
_value = mapSignal(this.value, {
|
|
67
|
+
transform: value => value !== null ? [value] : [],
|
|
68
|
+
reverse: values => values.length === 0 ? null : values[0]
|
|
69
|
+
});
|
|
70
|
+
_pattern;
|
|
71
|
+
_hasFocused = signal(false, ...(ngDevMode ? [{
|
|
72
|
+
debugName: "_hasFocused"
|
|
73
|
+
}] : []));
|
|
74
|
+
constructor() {
|
|
75
|
+
const inputs = {
|
|
76
|
+
...this,
|
|
77
|
+
items: this.items,
|
|
78
|
+
value: this._value,
|
|
79
|
+
activeItem: signal(undefined),
|
|
80
|
+
textDirection: this.textDirection,
|
|
81
|
+
element: () => this._elementRef.nativeElement,
|
|
82
|
+
getItem: e => {
|
|
83
|
+
if (!(e.target instanceof HTMLElement)) {
|
|
84
|
+
return undefined;
|
|
104
85
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
afterRenderEffect(() => {
|
|
114
|
-
if (!this._hasFocused() && !this._hasToolbar()) {
|
|
115
|
-
this.pattern.setDefaultState();
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
onFocus() {
|
|
120
|
-
this._hasFocused.set(true);
|
|
86
|
+
const element = e.target.closest('[role="radio"]');
|
|
87
|
+
return this.items().find(i => i.element() === element);
|
|
88
|
+
},
|
|
89
|
+
toolbar: this._toolbarWidgetGroup.toolbar
|
|
90
|
+
};
|
|
91
|
+
this._pattern = this._hasToolbar() ? new ToolbarRadioGroupPattern(inputs) : new RadioGroupPattern(inputs);
|
|
92
|
+
if (this._hasToolbar()) {
|
|
93
|
+
this._toolbarWidgetGroup.controls.set(this._pattern);
|
|
121
94
|
}
|
|
122
|
-
|
|
123
|
-
|
|
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._hasToolbar()) {
|
|
105
|
+
this._pattern.setDefaultState();
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
onFocus() {
|
|
110
|
+
this._hasFocused.set(true);
|
|
111
|
+
}
|
|
112
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
113
|
+
minVersion: "12.0.0",
|
|
114
|
+
version: "20.2.0-next.2",
|
|
115
|
+
ngImport: i0,
|
|
116
|
+
type: RadioGroup,
|
|
117
|
+
deps: [],
|
|
118
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
119
|
+
});
|
|
120
|
+
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
121
|
+
minVersion: "17.2.0",
|
|
122
|
+
version: "20.2.0-next.2",
|
|
123
|
+
type: RadioGroup,
|
|
124
|
+
isStandalone: true,
|
|
125
|
+
selector: "[ngRadioGroup]",
|
|
126
|
+
inputs: {
|
|
127
|
+
orientation: {
|
|
128
|
+
classPropertyName: "orientation",
|
|
129
|
+
publicName: "orientation",
|
|
130
|
+
isSignal: true,
|
|
131
|
+
isRequired: false,
|
|
132
|
+
transformFunction: null
|
|
133
|
+
},
|
|
134
|
+
skipDisabled: {
|
|
135
|
+
classPropertyName: "skipDisabled",
|
|
136
|
+
publicName: "skipDisabled",
|
|
137
|
+
isSignal: true,
|
|
138
|
+
isRequired: false,
|
|
139
|
+
transformFunction: null
|
|
140
|
+
},
|
|
141
|
+
focusMode: {
|
|
142
|
+
classPropertyName: "focusMode",
|
|
143
|
+
publicName: "focusMode",
|
|
144
|
+
isSignal: true,
|
|
145
|
+
isRequired: false,
|
|
146
|
+
transformFunction: null
|
|
147
|
+
},
|
|
148
|
+
disabled: {
|
|
149
|
+
classPropertyName: "disabled",
|
|
150
|
+
publicName: "disabled",
|
|
151
|
+
isSignal: true,
|
|
152
|
+
isRequired: false,
|
|
153
|
+
transformFunction: null
|
|
154
|
+
},
|
|
155
|
+
readonly: {
|
|
156
|
+
classPropertyName: "readonly",
|
|
157
|
+
publicName: "readonly",
|
|
158
|
+
isSignal: true,
|
|
159
|
+
isRequired: false,
|
|
160
|
+
transformFunction: null
|
|
161
|
+
},
|
|
162
|
+
value: {
|
|
163
|
+
classPropertyName: "value",
|
|
164
|
+
publicName: "value",
|
|
165
|
+
isSignal: true,
|
|
166
|
+
isRequired: false,
|
|
167
|
+
transformFunction: null
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
outputs: {
|
|
171
|
+
value: "valueChange"
|
|
172
|
+
},
|
|
173
|
+
host: {
|
|
174
|
+
attributes: {
|
|
175
|
+
"role": "radiogroup"
|
|
176
|
+
},
|
|
177
|
+
listeners: {
|
|
178
|
+
"keydown": "_pattern.onKeydown($event)",
|
|
179
|
+
"pointerdown": "_pattern.onPointerdown($event)",
|
|
180
|
+
"focusin": "onFocus()"
|
|
181
|
+
},
|
|
182
|
+
properties: {
|
|
183
|
+
"attr.tabindex": "_pattern.tabindex()",
|
|
184
|
+
"attr.aria-readonly": "_pattern.readonly()",
|
|
185
|
+
"attr.aria-disabled": "_pattern.disabled()",
|
|
186
|
+
"attr.aria-orientation": "_pattern.orientation()",
|
|
187
|
+
"attr.aria-activedescendant": "_pattern.activedescendant()"
|
|
188
|
+
},
|
|
189
|
+
classAttribute: "ng-radio-group"
|
|
190
|
+
},
|
|
191
|
+
queries: [{
|
|
192
|
+
propertyName: "_radioButtons",
|
|
193
|
+
predicate: RadioButton,
|
|
194
|
+
descendants: true,
|
|
195
|
+
isSignal: true
|
|
196
|
+
}],
|
|
197
|
+
exportAs: ["ngRadioGroup"],
|
|
198
|
+
hostDirectives: [{
|
|
199
|
+
directive: i1.ToolbarWidgetGroup,
|
|
200
|
+
inputs: ["disabled", "disabled"]
|
|
201
|
+
}],
|
|
202
|
+
ngImport: i0
|
|
203
|
+
});
|
|
124
204
|
}
|
|
125
|
-
i0.ɵɵngDeclareClassMetadata({
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
205
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
206
|
+
minVersion: "12.0.0",
|
|
207
|
+
version: "20.2.0-next.2",
|
|
208
|
+
ngImport: i0,
|
|
209
|
+
type: RadioGroup,
|
|
210
|
+
decorators: [{
|
|
211
|
+
type: Directive,
|
|
212
|
+
args: [{
|
|
213
|
+
selector: '[ngRadioGroup]',
|
|
214
|
+
exportAs: 'ngRadioGroup',
|
|
215
|
+
host: {
|
|
216
|
+
'role': 'radiogroup',
|
|
217
|
+
'class': 'ng-radio-group',
|
|
218
|
+
'[attr.tabindex]': '_pattern.tabindex()',
|
|
219
|
+
'[attr.aria-readonly]': '_pattern.readonly()',
|
|
220
|
+
'[attr.aria-disabled]': '_pattern.disabled()',
|
|
221
|
+
'[attr.aria-orientation]': '_pattern.orientation()',
|
|
222
|
+
'[attr.aria-activedescendant]': '_pattern.activedescendant()',
|
|
223
|
+
'(keydown)': '_pattern.onKeydown($event)',
|
|
224
|
+
'(pointerdown)': '_pattern.onPointerdown($event)',
|
|
225
|
+
'(focusin)': 'onFocus()'
|
|
226
|
+
},
|
|
227
|
+
hostDirectives: [{
|
|
228
|
+
directive: ToolbarWidgetGroup,
|
|
229
|
+
inputs: ['disabled']
|
|
230
|
+
}]
|
|
231
|
+
}]
|
|
232
|
+
}],
|
|
233
|
+
ctorParameters: () => []
|
|
234
|
+
});
|
|
151
235
|
class RadioButton {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
236
|
+
_elementRef = inject(ElementRef);
|
|
237
|
+
_radioGroup = inject(RadioGroup);
|
|
238
|
+
_generatedId = inject(_IdGenerator).getId('ng-radio-button-');
|
|
239
|
+
id = computed(() => this._generatedId, ...(ngDevMode ? [{
|
|
240
|
+
debugName: "id"
|
|
241
|
+
}] : []));
|
|
242
|
+
value = input.required(...(ngDevMode ? [{
|
|
243
|
+
debugName: "value"
|
|
244
|
+
}] : []));
|
|
245
|
+
group = computed(() => this._radioGroup._pattern, ...(ngDevMode ? [{
|
|
246
|
+
debugName: "group"
|
|
247
|
+
}] : []));
|
|
248
|
+
element = computed(() => this._elementRef.nativeElement, ...(ngDevMode ? [{
|
|
249
|
+
debugName: "element"
|
|
250
|
+
}] : []));
|
|
251
|
+
disabled = input(false, ...(ngDevMode ? [{
|
|
252
|
+
debugName: "disabled",
|
|
253
|
+
transform: booleanAttribute
|
|
254
|
+
}] : [{
|
|
255
|
+
transform: booleanAttribute
|
|
256
|
+
}]));
|
|
257
|
+
selected = computed(() => this._pattern.selected(), ...(ngDevMode ? [{
|
|
258
|
+
debugName: "selected"
|
|
259
|
+
}] : []));
|
|
260
|
+
_pattern = new RadioButtonPattern({
|
|
261
|
+
...this,
|
|
262
|
+
id: this.id,
|
|
263
|
+
value: this.value,
|
|
264
|
+
group: this.group,
|
|
265
|
+
element: this.element
|
|
266
|
+
});
|
|
267
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
268
|
+
minVersion: "12.0.0",
|
|
269
|
+
version: "20.2.0-next.2",
|
|
270
|
+
ngImport: i0,
|
|
271
|
+
type: RadioButton,
|
|
272
|
+
deps: [],
|
|
273
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
274
|
+
});
|
|
275
|
+
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
276
|
+
minVersion: "17.1.0",
|
|
277
|
+
version: "20.2.0-next.2",
|
|
278
|
+
type: RadioButton,
|
|
279
|
+
isStandalone: true,
|
|
280
|
+
selector: "[ngRadioButton]",
|
|
281
|
+
inputs: {
|
|
282
|
+
value: {
|
|
283
|
+
classPropertyName: "value",
|
|
284
|
+
publicName: "value",
|
|
285
|
+
isSignal: true,
|
|
286
|
+
isRequired: true,
|
|
287
|
+
transformFunction: null
|
|
288
|
+
},
|
|
289
|
+
disabled: {
|
|
290
|
+
classPropertyName: "disabled",
|
|
291
|
+
publicName: "disabled",
|
|
292
|
+
isSignal: true,
|
|
293
|
+
isRequired: false,
|
|
294
|
+
transformFunction: null
|
|
295
|
+
}
|
|
296
|
+
},
|
|
297
|
+
host: {
|
|
298
|
+
attributes: {
|
|
299
|
+
"role": "radio"
|
|
300
|
+
},
|
|
301
|
+
properties: {
|
|
302
|
+
"attr.data-active": "_pattern.active()",
|
|
303
|
+
"attr.tabindex": "_pattern.tabindex()",
|
|
304
|
+
"attr.aria-checked": "_pattern.selected()",
|
|
305
|
+
"attr.aria-disabled": "_pattern.disabled()",
|
|
306
|
+
"id": "_pattern.id()"
|
|
307
|
+
},
|
|
308
|
+
classAttribute: "ng-radio-button"
|
|
309
|
+
},
|
|
310
|
+
exportAs: ["ngRadioButton"],
|
|
311
|
+
ngImport: i0
|
|
312
|
+
});
|
|
178
313
|
}
|
|
179
|
-
i0.ɵɵngDeclareClassMetadata({
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
314
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
315
|
+
minVersion: "12.0.0",
|
|
316
|
+
version: "20.2.0-next.2",
|
|
317
|
+
ngImport: i0,
|
|
318
|
+
type: RadioButton,
|
|
319
|
+
decorators: [{
|
|
320
|
+
type: Directive,
|
|
321
|
+
args: [{
|
|
322
|
+
selector: '[ngRadioButton]',
|
|
323
|
+
exportAs: 'ngRadioButton',
|
|
324
|
+
host: {
|
|
325
|
+
'role': 'radio',
|
|
326
|
+
'class': 'ng-radio-button',
|
|
327
|
+
'[attr.data-active]': '_pattern.active()',
|
|
328
|
+
'[attr.tabindex]': '_pattern.tabindex()',
|
|
329
|
+
'[attr.aria-checked]': '_pattern.selected()',
|
|
330
|
+
'[attr.aria-disabled]': '_pattern.disabled()',
|
|
331
|
+
'[id]': '_pattern.id()'
|
|
332
|
+
}
|
|
333
|
+
}]
|
|
334
|
+
}]
|
|
335
|
+
});
|
|
195
336
|
|
|
196
337
|
export { RadioButton, RadioGroup };
|
|
197
338
|
//# sourceMappingURL=radio-group.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radio-group.mjs","sources":["../../../../../darwin_arm64-fastbuild-ST-199a4f3c4e20/bin/src/aria/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} from '@angular/core';\nimport {\n RadioButtonPattern,\n RadioGroupInputs,\n RadioGroupPattern,\n ToolbarRadioGroupInputs,\n ToolbarRadioGroupPattern,\n} from '@angular/aria/ui-patterns';\nimport {Directionality} from '@angular/cdk/bidi';\nimport {_IdGenerator} from '@angular/cdk/a11y';\nimport {ToolbarWidgetGroup} from '@angular/aria/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 RadioGroup is meant to be used in conjunction with RadioButton\n * as follows:\n *\n * ```html\n * <div ngRadioGroup>\n * <div ngRadioButton value=\"1\">Option 1</div>\n * <div ngRadioButton value=\"2\">Option 2</div>\n * <div ngRadioButton value=\"3\">Option 3</div>\n * </div>\n * ```\n */\n@Directive({\n selector: '[ngRadioGroup]',\n exportAs: 'ngRadioGroup',\n host: {\n 'role': 'radiogroup',\n 'class': 'ng-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 hostDirectives: [\n {\n directive: ToolbarWidgetGroup,\n inputs: ['disabled'],\n },\n ],\n})\nexport class RadioGroup<V> {\n /** A reference to the radio group element. */\n private readonly _elementRef = inject(ElementRef);\n\n /** A reference to the ToolbarWidgetGroup, if the radio group is in a toolbar. */\n private readonly _toolbarWidgetGroup = inject(ToolbarWidgetGroup);\n\n /** Whether the radio group is inside of a Toolbar. */\n private readonly _hasToolbar = computed(() => !!this._toolbarWidgetGroup.toolbar());\n\n /** The RadioButtons nested inside of the RadioGroup. */\n private readonly _radioButtons = contentChildren(RadioButton, {descendants: true});\n\n /** A signal wrapper for directionality. */\n protected textDirection = inject(Directionality).valueSignal;\n\n /** The RadioButton UIPatterns of the child RadioButtons. */\n protected items = computed(() => this._radioButtons().map(radio => radio.pattern));\n\n /** Whether the radio group is vertically or horizontally oriented. */\n readonly orientation = input<'vertical' | 'horizontal'>('vertical');\n\n /** Whether disabled items in the group should be skipped when navigating. */\n readonly skipDisabled = input(true, {transform: booleanAttribute});\n\n /** The focus strategy used by the radio group. */\n readonly focusMode = input<'roving' | 'activedescendant'>('roving');\n\n /** Whether the radio group is disabled. */\n readonly disabled = input(false, {transform: booleanAttribute});\n\n /** Whether the radio group is readonly. */\n readonly readonly = input(false, {transform: booleanAttribute});\n\n /** The value of the currently selected radio button. */\n readonly 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 readonly pattern: RadioGroupPattern<V>;\n\n /** Whether the radio group has received focus yet. */\n private _hasFocused = signal(false);\n\n constructor() {\n const inputs: RadioGroupInputs<V> | ToolbarRadioGroupInputs<V> = {\n ...this,\n items: this.items,\n value: this._value,\n activeItem: signal(undefined),\n textDirection: this.textDirection,\n element: () => this._elementRef.nativeElement,\n getItem: e => {\n if (!(e.target instanceof HTMLElement)) {\n return undefined;\n }\n const element = e.target.closest('[role=\"radio\"]');\n return this.items().find(i => i.element() === element);\n },\n toolbar: this._toolbarWidgetGroup.toolbar,\n };\n\n this.pattern = this._hasToolbar()\n ? new ToolbarRadioGroupPattern<V>(inputs as ToolbarRadioGroupInputs<V>)\n : new RadioGroupPattern<V>(inputs as RadioGroupInputs<V>);\n\n if (this._hasToolbar()) {\n this._toolbarWidgetGroup.controls.set(this.pattern as ToolbarRadioGroupPattern<V>);\n }\n\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._hasToolbar()) {\n this.pattern.setDefaultState();\n }\n });\n }\n\n onFocus() {\n this._hasFocused.set(true);\n }\n}\n\n/** A selectable radio button in a RadioGroup. */\n@Directive({\n selector: '[ngRadioButton]',\n exportAs: 'ngRadioButton',\n host: {\n 'role': 'radio',\n 'class': 'ng-radio-button',\n '[attr.data-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 RadioButton<V> {\n /** A reference to the radio button element. */\n private readonly _elementRef = inject(ElementRef);\n\n /** The parent RadioGroup. */\n private readonly _radioGroup = inject(RadioGroup);\n\n /** A unique identifier for the radio button. */\n private readonly _generatedId = inject(_IdGenerator).getId('ng-radio-button-');\n\n /** A unique identifier for the radio button. */\n readonly 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 readonly group = computed(() => this._radioGroup.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"],"names":[],"mappings":";;;;;;;;AAiCA;AAEA;;;;;;;;AAQG;AACa,SAAA,SAAS,CACvB,cAAiC,EACjC,UAGC,EAAA;AAED,IAAA,MAAM,YAAY,GAAG,YAAY,CAAC,MAAM,UAAU,CAAC,SAAS,CAAC,cAAc,EAAE,CAAC,CAAC;AAC/E,IAAA,MAAM,kBAAkB,GAAG,YAAY,CAAC,MAAM;AAC9C,IAAA,MAAM,eAAe,GAAG,YAAY,CAAC,GAAG;AAExC,IAAA,YAAY,CAAC,GAAG,GAAG,CAAC,QAAW,KAAI;QACjC,eAAe,CAAC,QAAQ,CAAC;QACzB,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;AAClD,KAAC;AAED,IAAA,YAAY,CAAC,MAAM,GAAG,CAAC,QAAyB,KAAI;QAClD,kBAAkB,CAAC,QAAQ,IAAI,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAClD,cAAc,CAAC,MAAM,CAAC,QAAQ,IAAI,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;AACjG,KAAC;AAED,IAAA,OAAO,YAAY;AACrB;AAEA;;;;;;;;;;;;;;AAcG;MAuBU,UAAU,CAAA;;AAEJ,IAAA,WAAW,GAAG,MAAM,CAAC,UAAU,CAAC;;AAGhC,IAAA,mBAAmB,GAAG,MAAM,CAAC,kBAAkB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A,IAAI,EAAE;AACJ,wBAAA,MAAM,EAAE,OAAO;AACf,wBAAA,OAAO,EAAE,iBAAiB;AAC1B,wBAAA,oBAAoB,EAAE,kBAAkB;AACxC,wBAAA,iBAAiB,EAAE,oBAAoB;AACvC,wBAAA,qBAAqB,EAAE,oBAAoB;AAC3C,wBAAA,sBAAsB,EAAE,oBAAoB;AAC5C,wBAAA,MAAM,EAAE,cAAc;AACvB,qBAAA;AACF,iBAAA;;;;;"}
|
|
1
|
+
{"version":3,"file":"radio-group.mjs","sources":["../../../../../darwin_arm64-fastbuild-ST-199a4f3c4e20/bin/src/aria/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} from '@angular/core';\nimport {\n RadioButtonPattern,\n RadioGroupInputs,\n RadioGroupPattern,\n ToolbarRadioGroupInputs,\n ToolbarRadioGroupPattern,\n} from '@angular/aria/private';\nimport {Directionality} from '@angular/cdk/bidi';\nimport {_IdGenerator} from '@angular/cdk/a11y';\nimport {ToolbarWidgetGroup} from '@angular/aria/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 RadioGroup is meant to be used in conjunction with RadioButton\n * as follows:\n *\n * ```html\n * <div ngRadioGroup>\n * <div ngRadioButton value=\"1\">Option 1</div>\n * <div ngRadioButton value=\"2\">Option 2</div>\n * <div ngRadioButton value=\"3\">Option 3</div>\n * </div>\n * ```\n */\n@Directive({\n selector: '[ngRadioGroup]',\n exportAs: 'ngRadioGroup',\n host: {\n 'role': 'radiogroup',\n 'class': 'ng-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 hostDirectives: [\n {\n directive: ToolbarWidgetGroup,\n inputs: ['disabled'],\n },\n ],\n})\nexport class RadioGroup<V> {\n /** A reference to the radio group element. */\n private readonly _elementRef = inject(ElementRef);\n\n /** A reference to the ToolbarWidgetGroup, if the radio group is in a toolbar. */\n private readonly _toolbarWidgetGroup = inject(ToolbarWidgetGroup);\n\n /** Whether the radio group is inside of a Toolbar. */\n private readonly _hasToolbar = computed(() => !!this._toolbarWidgetGroup.toolbar());\n\n /** The RadioButtons nested inside of the RadioGroup. */\n private readonly _radioButtons = contentChildren(RadioButton, {descendants: true});\n\n /** A signal wrapper for directionality. */\n protected textDirection = inject(Directionality).valueSignal;\n\n /** The RadioButton UIPatterns of the child RadioButtons. */\n protected items = computed(() => this._radioButtons().map(radio => radio._pattern));\n\n /** Whether the radio group is vertically or horizontally oriented. */\n readonly orientation = input<'vertical' | 'horizontal'>('vertical');\n\n /** Whether disabled items in the group should be skipped when navigating. */\n readonly skipDisabled = input(true, {transform: booleanAttribute});\n\n /** The focus strategy used by the radio group. */\n readonly focusMode = input<'roving' | 'activedescendant'>('roving');\n\n /** Whether the radio group is disabled. */\n readonly disabled = input(false, {transform: booleanAttribute});\n\n /** Whether the radio group is readonly. */\n readonly readonly = input(false, {transform: booleanAttribute});\n\n /** The value of the currently selected radio button. */\n readonly 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 readonly _pattern: RadioGroupPattern<V>;\n\n /** Whether the radio group has received focus yet. */\n private _hasFocused = signal(false);\n\n constructor() {\n const inputs: RadioGroupInputs<V> | ToolbarRadioGroupInputs<V> = {\n ...this,\n items: this.items,\n value: this._value,\n activeItem: signal(undefined),\n textDirection: this.textDirection,\n element: () => this._elementRef.nativeElement,\n getItem: e => {\n if (!(e.target instanceof HTMLElement)) {\n return undefined;\n }\n const element = e.target.closest('[role=\"radio\"]');\n return this.items().find(i => i.element() === element);\n },\n toolbar: this._toolbarWidgetGroup.toolbar,\n };\n\n this._pattern = this._hasToolbar()\n ? new ToolbarRadioGroupPattern<V>(inputs as ToolbarRadioGroupInputs<V>)\n : new RadioGroupPattern<V>(inputs as RadioGroupInputs<V>);\n\n if (this._hasToolbar()) {\n this._toolbarWidgetGroup.controls.set(this._pattern as ToolbarRadioGroupPattern<V>);\n }\n\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._hasToolbar()) {\n this._pattern.setDefaultState();\n }\n });\n }\n\n onFocus() {\n this._hasFocused.set(true);\n }\n}\n\n/** A selectable radio button in a RadioGroup. */\n@Directive({\n selector: '[ngRadioButton]',\n exportAs: 'ngRadioButton',\n host: {\n 'role': 'radio',\n 'class': 'ng-radio-button',\n '[attr.data-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 RadioButton<V> {\n /** A reference to the radio button element. */\n private readonly _elementRef = inject(ElementRef);\n\n /** The parent RadioGroup. */\n private readonly _radioGroup = inject(RadioGroup);\n\n /** A unique identifier for the radio button. */\n private readonly _generatedId = inject(_IdGenerator).getId('ng-radio-button-');\n\n /** A unique identifier for the radio button. */\n readonly 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 readonly group = computed(() => this._radioGroup._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 /** Whether the radio button is selected. */\n readonly selected = computed(() => this._pattern.selected());\n\n /** The RadioButton UIPattern. */\n readonly _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"],"names":["update","updateFn","updateMappedSignal","oldValue","operations","reverse","transform","mappedSignal","_hasToolbar","computed","_toolbarWidgetGroup","toolbar","ngDevMode","debugName","_radioButtons","contentChildren","RadioButton","descendants","items","map","radio","_pattern","orientation","input","skipDisabled","booleanAttribute","focusMode","readonly","value","model","_value","mapSignal","values","length","signal","constructor","inputs","activeItem","undefined","textDirection","getItem","e","target","HTMLElement","element","find","i","ToolbarRadioGroupPattern","RadioGroupPattern","controls","set","violations","validate","violation","_hasFocused","setDefaultState","onFocus","i0","ɵɵngDeclareFactory","minVersion","version","ngImport","type","RadioGroup","deps","ɵɵFactoryTarget","Directive","ɵɵngDeclareDirective","isStandalone","selector","classPropertyName","publicName","isSignal","isRequired","transformFunction","disabled","outputs","host","attributes","listeners","properties","classAttribute","queries","propertyName","predicate","exportAs","hostDirectives","directive","i1","ToolbarWidgetGroup","ctorParameters","inject"],"mappings":";;;;;;;;;;;;;;;;cAgHwD,CAAAA,MAAA,GAAAC,QAAA,IAAA;AACrCC,IAAAA,kBAAA,CAAAC,QAAuB,IAAAF,QAAgC,CAAAE,QAAA,CAAA,CAAA;kBAEhB,CAAAH,MAAA,CAAAG,QAAA,IAAAC,UAAA,CAAAC,OAAA,CAAAJ,QAAA,CAAAG,UAAA,CAAAE,SAAA,CAAAH,QAAA,CAAA,CAAA,CAAA,CAAA;;SAI9CI;;;;;AAqCNC,EAAAA,WAAA,GAAAC,QAAA,CAAA,MAAA,CAAA,CAAA,IAAA,CAAAC,mBAAA,CAAAC,OAAA,QAAAC,SAAA,GAAA,CAAA;IAAAC,SAAA,EAAA;AAAA,GAAA,CAAA,GAAA,EAAA,CAAA,CAAA;AA2BEC,EAAAA,aAAA,GAAAC,eAAA,CAAAC,WAAA,MAAwBJ,SAAA,GAAA,CAAA;IAAAC,SAAA,EAAA,eAAA;IAAAI,WAAA,EAAA;AAAA,GAAA,CAAA,GAAA,CAAA;IAAAA,WAAA,EAAA;AAAA,GAAA,CAAA,CAAA,CAAA;;AAO1BC,EAAAA,KAAA,GAAAT,QAAA,CAAAK,MAAAA,IAAAA,CAAAA,aAAA,EAAAK,CAAAA,GAAA,CAAAC,KAAA,IAA4CA,KAAA,CAAAC,QAAA,OAAAT,SAAA,GAAA,CAAA;IAAAC,SAAA,EAAA;AAAA,GAAA,CAAA,GAAA,EAAA,CAAA,CAAA;EAG9CS,WAAA,GAAAC,KAAA,CAAA,UAAA,EAAA,IAAAX,SAAA,GAAA,CAAA;IAAAC,SAAE,EAAA;AAAA,GAAA,C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