@vonage/vivid 4.11.0 → 4.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/custom-elements.json +899 -442
  2. package/lib/accordion/accordion.d.ts +21 -2
  3. package/lib/accordion-item/accordion-item.d.ts +6 -2
  4. package/lib/calendar/calendar.d.ts +1 -1
  5. package/lib/date-picker/date-picker.d.ts +1 -0
  6. package/lib/fab/fab.d.ts +2 -2
  7. package/lib/radio/radio.d.ts +12 -2
  8. package/lib/radio/radio.form-associated.d.ts +10 -0
  9. package/lib/radio-group/radio-group.d.ts +20 -2
  10. package/lib/tab/tab.d.ts +3 -2
  11. package/lib/tab-panel/tab-panel.d.ts +2 -2
  12. package/lib/tabs/tabs.d.ts +30 -9
  13. package/package.json +1 -1
  14. package/shared/date-picker/date-picker-base.d.ts +1 -0
  15. package/shared/definition.cjs +29 -72
  16. package/shared/definition.js +30 -73
  17. package/shared/definition16.cjs +1 -2
  18. package/shared/definition16.js +1 -2
  19. package/shared/definition17.cjs +2 -2
  20. package/shared/definition17.js +2 -2
  21. package/shared/definition18.cjs +6 -1
  22. package/shared/definition18.js +6 -1
  23. package/shared/definition19.cjs +17 -8
  24. package/shared/definition19.js +17 -8
  25. package/shared/definition2.cjs +154 -187
  26. package/shared/definition2.js +157 -190
  27. package/shared/definition20.cjs +1 -1
  28. package/shared/definition20.js +1 -1
  29. package/shared/definition24.cjs +11 -11
  30. package/shared/definition24.js +11 -11
  31. package/shared/definition29.cjs +2 -2
  32. package/shared/definition29.js +2 -2
  33. package/shared/definition35.cjs +1 -1
  34. package/shared/definition35.js +1 -1
  35. package/shared/definition40.cjs +226 -399
  36. package/shared/definition40.js +229 -402
  37. package/shared/definition42.cjs +3 -2
  38. package/shared/definition42.js +3 -2
  39. package/shared/definition43.cjs +1 -0
  40. package/shared/definition43.js +1 -0
  41. package/shared/definition44.cjs +1 -1
  42. package/shared/definition44.js +1 -1
  43. package/shared/definition47.cjs +3 -2
  44. package/shared/definition47.js +3 -2
  45. package/shared/definition49.cjs +1 -1
  46. package/shared/definition49.js +1 -1
  47. package/shared/definition5.cjs +1 -1
  48. package/shared/definition5.js +1 -1
  49. package/shared/definition50.cjs +1 -11
  50. package/shared/definition50.js +1 -11
  51. package/shared/definition51.cjs +4 -14
  52. package/shared/definition51.js +5 -15
  53. package/shared/definition52.cjs +269 -19
  54. package/shared/definition52.js +273 -23
  55. package/shared/definition57.cjs +26 -4
  56. package/shared/definition57.js +27 -5
  57. package/shared/definition58.cjs +1 -1
  58. package/shared/definition58.js +1 -1
  59. package/shared/definition59.cjs +1 -1
  60. package/shared/definition59.js +1 -1
  61. package/shared/definition61.cjs +1 -1
  62. package/shared/definition61.js +1 -1
  63. package/shared/definition62.cjs +17 -8
  64. package/shared/definition62.js +17 -8
  65. package/shared/definition64.cjs +55 -30
  66. package/shared/definition64.js +55 -30
  67. package/shared/form-associated.cjs +1 -1
  68. package/shared/form-associated.js +1 -1
  69. package/shared/foundation/button/button.d.ts +1 -1
  70. package/shared/foundation/button/button.template.d.ts +2 -2
  71. package/shared/icon.cjs +1 -1
  72. package/shared/icon.js +1 -1
  73. package/shared/index.cjs +1 -0
  74. package/shared/index.js +1 -1
  75. package/shared/key-codes.cjs +1 -94
  76. package/shared/key-codes.js +2 -89
  77. package/shared/key-codes2.cjs +87 -1
  78. package/shared/key-codes2.js +83 -2
  79. package/shared/listbox.cjs +6 -7
  80. package/shared/listbox.js +3 -4
  81. package/shared/numbers.cjs +0 -12
  82. package/shared/numbers.js +1 -12
  83. package/shared/presentationDate.cjs +14 -0
  84. package/shared/presentationDate.js +15 -1
  85. package/shared/radio.cjs +92 -117
  86. package/shared/radio.js +93 -118
  87. package/shared/slider.template.cjs +2 -15
  88. package/shared/slider.template.js +2 -14
  89. package/shared/strings.cjs +26 -0
  90. package/shared/strings.js +25 -1
  91. package/styles/core/all.css +1 -1
  92. package/styles/core/theme.css +1 -1
  93. package/styles/core/typography.css +1 -1
  94. package/styles/tokens/theme-dark.css +4 -4
  95. package/styles/tokens/theme-light.css +4 -4
  96. package/styles/tokens/vivid-2-compat.css +1 -1
@@ -1,406 +1,11 @@
1
1
  'use strict';
2
2
 
3
3
  const index = require('./index.cjs');
4
- const direction = require('./direction.cjs');
5
4
  const keyCodes = require('./key-codes.cjs');
5
+ const aria = require('./aria.cjs');
6
6
  const radio = require('./radio.cjs');
7
7
  const slotted = require('./slotted.cjs');
8
8
  const when = require('./when.cjs');
9
- const aria = require('./aria.cjs');
10
-
11
- /**
12
- * Standard orientation values
13
- */
14
- const Orientation = {
15
- horizontal: "horizontal",
16
- vertical: "vertical",
17
- };
18
-
19
- /**
20
- * An Radio Group Custom HTML Element.
21
- * Implements the {@link https://www.w3.org/TR/wai-aria-1.1/#radiogroup | ARIA radiogroup }.
22
- *
23
- * @slot label - The slot for the label
24
- * @slot - The default slot for radio buttons
25
- * @csspart positioning-region - The positioning region for laying out the radios
26
- * @fires change - Fires a custom 'change' event when the value changes
27
- *
28
- * @public
29
- */
30
- let RadioGroup$1 = class RadioGroup extends index.FoundationElement {
31
- constructor() {
32
- super(...arguments);
33
- /**
34
- * The orientation of the group
35
- *
36
- * @public
37
- * @remarks
38
- * HTML Attribute: orientation
39
- */
40
- this.orientation = Orientation.horizontal;
41
- this.radioChangeHandler = (e) => {
42
- const changedRadio = e.target;
43
- if (changedRadio.checked) {
44
- this.slottedRadioButtons.forEach((radio) => {
45
- if (radio !== changedRadio) {
46
- radio.checked = false;
47
- if (!this.isInsideFoundationToolbar) {
48
- radio.setAttribute("tabindex", "-1");
49
- }
50
- }
51
- });
52
- this.selectedRadio = changedRadio;
53
- this.value = changedRadio.value;
54
- changedRadio.setAttribute("tabindex", "0");
55
- this.focusedRadio = changedRadio;
56
- }
57
- e.stopPropagation();
58
- };
59
- this.moveToRadioByIndex = (group, index) => {
60
- const radio = group[index];
61
- if (!this.isInsideToolbar) {
62
- radio.setAttribute("tabindex", "0");
63
- if (radio.readOnly) {
64
- this.slottedRadioButtons.forEach((nextRadio) => {
65
- if (nextRadio !== radio) {
66
- nextRadio.setAttribute("tabindex", "-1");
67
- }
68
- });
69
- }
70
- else {
71
- radio.checked = true;
72
- this.selectedRadio = radio;
73
- }
74
- }
75
- this.focusedRadio = radio;
76
- radio.focus();
77
- };
78
- this.moveRightOffGroup = () => {
79
- var _a;
80
- (_a = this.nextElementSibling) === null || _a === void 0 ? void 0 : _a.focus();
81
- };
82
- this.moveLeftOffGroup = () => {
83
- var _a;
84
- (_a = this.previousElementSibling) === null || _a === void 0 ? void 0 : _a.focus();
85
- };
86
- /**
87
- * @internal
88
- */
89
- this.focusOutHandler = (e) => {
90
- const group = this.slottedRadioButtons;
91
- const radio = e.target;
92
- const index = radio !== null ? group.indexOf(radio) : 0;
93
- const focusedIndex = this.focusedRadio
94
- ? group.indexOf(this.focusedRadio)
95
- : -1;
96
- if ((focusedIndex === 0 && index === focusedIndex) ||
97
- (focusedIndex === group.length - 1 && focusedIndex === index)) {
98
- if (!this.selectedRadio) {
99
- this.focusedRadio = group[0];
100
- this.focusedRadio.setAttribute("tabindex", "0");
101
- group.forEach((nextRadio) => {
102
- if (nextRadio !== this.focusedRadio) {
103
- nextRadio.setAttribute("tabindex", "-1");
104
- }
105
- });
106
- }
107
- else {
108
- this.focusedRadio = this.selectedRadio;
109
- if (!this.isInsideFoundationToolbar) {
110
- this.selectedRadio.setAttribute("tabindex", "0");
111
- group.forEach((nextRadio) => {
112
- if (nextRadio !== this.selectedRadio) {
113
- nextRadio.setAttribute("tabindex", "-1");
114
- }
115
- });
116
- }
117
- }
118
- }
119
- return true;
120
- };
121
- /**
122
- * @internal
123
- */
124
- this.clickHandler = (e) => {
125
- const radio = e.target;
126
- if (radio) {
127
- const group = this.slottedRadioButtons;
128
- if (radio.checked || group.indexOf(radio) === 0) {
129
- radio.setAttribute("tabindex", "0");
130
- this.selectedRadio = radio;
131
- }
132
- else {
133
- radio.setAttribute("tabindex", "-1");
134
- this.selectedRadio = null;
135
- }
136
- this.focusedRadio = radio;
137
- }
138
- e.preventDefault();
139
- };
140
- this.shouldMoveOffGroupToTheRight = (index, group, key) => {
141
- return index === group.length && this.isInsideToolbar && key === keyCodes.keyArrowRight;
142
- };
143
- this.shouldMoveOffGroupToTheLeft = (group, key) => {
144
- const index = this.focusedRadio ? group.indexOf(this.focusedRadio) - 1 : 0;
145
- return index < 0 && this.isInsideToolbar && key === keyCodes.keyArrowLeft;
146
- };
147
- this.checkFocusedRadio = () => {
148
- if (this.focusedRadio !== null &&
149
- !this.focusedRadio.readOnly &&
150
- !this.focusedRadio.checked) {
151
- this.focusedRadio.checked = true;
152
- this.focusedRadio.setAttribute("tabindex", "0");
153
- this.focusedRadio.focus();
154
- this.selectedRadio = this.focusedRadio;
155
- }
156
- };
157
- this.moveRight = (e) => {
158
- const group = this.slottedRadioButtons;
159
- let index = 0;
160
- index = this.focusedRadio ? group.indexOf(this.focusedRadio) + 1 : 1;
161
- if (this.shouldMoveOffGroupToTheRight(index, group, e.key)) {
162
- this.moveRightOffGroup();
163
- return;
164
- }
165
- else if (index === group.length) {
166
- index = 0;
167
- }
168
- /* looping to get to next radio that is not disabled */
169
- /* matching native radio/radiogroup which does not select an item if there is only 1 in the group */
170
- while (index < group.length && group.length > 1) {
171
- if (!group[index].disabled) {
172
- this.moveToRadioByIndex(group, index);
173
- break;
174
- }
175
- else if (this.focusedRadio && index === group.indexOf(this.focusedRadio)) {
176
- break;
177
- }
178
- else if (index + 1 >= group.length) {
179
- if (this.isInsideToolbar) {
180
- break;
181
- }
182
- else {
183
- index = 0;
184
- }
185
- }
186
- else {
187
- index += 1;
188
- }
189
- }
190
- };
191
- this.moveLeft = (e) => {
192
- const group = this.slottedRadioButtons;
193
- let index = 0;
194
- index = this.focusedRadio ? group.indexOf(this.focusedRadio) - 1 : 0;
195
- index = index < 0 ? group.length - 1 : index;
196
- if (this.shouldMoveOffGroupToTheLeft(group, e.key)) {
197
- this.moveLeftOffGroup();
198
- return;
199
- }
200
- /* looping to get to next radio that is not disabled */
201
- while (index >= 0 && group.length > 1) {
202
- if (!group[index].disabled) {
203
- this.moveToRadioByIndex(group, index);
204
- break;
205
- }
206
- else if (this.focusedRadio && index === group.indexOf(this.focusedRadio)) {
207
- break;
208
- }
209
- else if (index - 1 < 0) {
210
- index = group.length - 1;
211
- }
212
- else {
213
- index -= 1;
214
- }
215
- }
216
- };
217
- /**
218
- * keyboard handling per https://w3c.github.io/aria-practices/#for-radio-groups-not-contained-in-a-toolbar
219
- * navigation is different when there is an ancestor with role='toolbar'
220
- *
221
- * @internal
222
- */
223
- this.keydownHandler = (e) => {
224
- const key = e.key;
225
- if (key in keyCodes.ArrowKeys && this.isInsideFoundationToolbar) {
226
- return true;
227
- }
228
- switch (key) {
229
- case keyCodes.keyEnter: {
230
- this.checkFocusedRadio();
231
- break;
232
- }
233
- case keyCodes.keyArrowRight:
234
- case keyCodes.keyArrowDown: {
235
- if (this.direction === direction.Direction.ltr) {
236
- this.moveRight(e);
237
- }
238
- else {
239
- this.moveLeft(e);
240
- }
241
- break;
242
- }
243
- case keyCodes.keyArrowLeft:
244
- case keyCodes.keyArrowUp: {
245
- if (this.direction === direction.Direction.ltr) {
246
- this.moveLeft(e);
247
- }
248
- else {
249
- this.moveRight(e);
250
- }
251
- break;
252
- }
253
- default: {
254
- return true;
255
- }
256
- }
257
- };
258
- }
259
- readOnlyChanged() {
260
- if (this.slottedRadioButtons !== undefined) {
261
- this.slottedRadioButtons.forEach((radio) => {
262
- if (this.readOnly) {
263
- radio.readOnly = true;
264
- }
265
- else {
266
- radio.readOnly = false;
267
- }
268
- });
269
- }
270
- }
271
- disabledChanged() {
272
- if (this.slottedRadioButtons !== undefined) {
273
- this.slottedRadioButtons.forEach((radio) => {
274
- if (this.disabled) {
275
- radio.disabled = true;
276
- }
277
- else {
278
- radio.disabled = false;
279
- }
280
- });
281
- }
282
- }
283
- nameChanged() {
284
- if (this.slottedRadioButtons) {
285
- this.slottedRadioButtons.forEach((radio) => {
286
- radio.setAttribute("name", this.name);
287
- });
288
- }
289
- }
290
- valueChanged() {
291
- if (this.slottedRadioButtons) {
292
- this.slottedRadioButtons.forEach((radio) => {
293
- if (radio.value === this.value) {
294
- radio.checked = true;
295
- this.selectedRadio = radio;
296
- }
297
- });
298
- }
299
- this.$emit("change");
300
- }
301
- slottedRadioButtonsChanged(oldValue, newValue) {
302
- if (this.slottedRadioButtons && this.slottedRadioButtons.length > 0) {
303
- this.setupRadioButtons();
304
- }
305
- }
306
- get parentToolbar() {
307
- return this.closest('[role="toolbar"]');
308
- }
309
- get isInsideToolbar() {
310
- var _a;
311
- return ((_a = this.parentToolbar) !== null && _a !== void 0 ? _a : false);
312
- }
313
- get isInsideFoundationToolbar() {
314
- var _a;
315
- return !!((_a = this.parentToolbar) === null || _a === void 0 ? void 0 : _a["$fastController"]);
316
- }
317
- /**
318
- * @internal
319
- */
320
- connectedCallback() {
321
- super.connectedCallback();
322
- this.direction = direction.getDirection(this);
323
- this.setupRadioButtons();
324
- }
325
- disconnectedCallback() {
326
- this.slottedRadioButtons.forEach((radio) => {
327
- radio.removeEventListener("change", this.radioChangeHandler);
328
- });
329
- }
330
- setupRadioButtons() {
331
- const checkedRadios = this.slottedRadioButtons.filter((radio) => {
332
- return radio.hasAttribute("checked");
333
- });
334
- const numberOfCheckedRadios = checkedRadios ? checkedRadios.length : 0;
335
- if (numberOfCheckedRadios > 1) {
336
- const lastCheckedRadio = checkedRadios[numberOfCheckedRadios - 1];
337
- lastCheckedRadio.checked = true;
338
- }
339
- let foundMatchingVal = false;
340
- this.slottedRadioButtons.forEach((radio) => {
341
- if (this.name !== undefined) {
342
- radio.setAttribute("name", this.name);
343
- }
344
- if (this.disabled) {
345
- radio.disabled = true;
346
- }
347
- if (this.readOnly) {
348
- radio.readOnly = true;
349
- }
350
- if (this.value && this.value === radio.value) {
351
- this.selectedRadio = radio;
352
- this.focusedRadio = radio;
353
- radio.checked = true;
354
- radio.setAttribute("tabindex", "0");
355
- foundMatchingVal = true;
356
- }
357
- else {
358
- if (!this.isInsideFoundationToolbar) {
359
- radio.setAttribute("tabindex", "-1");
360
- }
361
- radio.checked = false;
362
- }
363
- radio.addEventListener("change", this.radioChangeHandler);
364
- });
365
- if (this.value === undefined && this.slottedRadioButtons.length > 0) {
366
- const checkedRadios = this.slottedRadioButtons.filter((radio) => {
367
- return radio.hasAttribute("checked");
368
- });
369
- const numberOfCheckedRadios = checkedRadios !== null ? checkedRadios.length : 0;
370
- if (numberOfCheckedRadios > 0 && !foundMatchingVal) {
371
- const lastCheckedRadio = checkedRadios[numberOfCheckedRadios - 1];
372
- lastCheckedRadio.checked = true;
373
- this.focusedRadio = lastCheckedRadio;
374
- lastCheckedRadio.setAttribute("tabindex", "0");
375
- }
376
- else {
377
- this.slottedRadioButtons[0].setAttribute("tabindex", "0");
378
- this.focusedRadio = this.slottedRadioButtons[0];
379
- }
380
- }
381
- }
382
- };
383
- index.__decorate([
384
- index.attr({ attribute: "readonly", mode: "boolean" })
385
- ], RadioGroup$1.prototype, "readOnly", void 0);
386
- index.__decorate([
387
- index.attr({ attribute: "disabled", mode: "boolean" })
388
- ], RadioGroup$1.prototype, "disabled", void 0);
389
- index.__decorate([
390
- index.attr
391
- ], RadioGroup$1.prototype, "name", void 0);
392
- index.__decorate([
393
- index.attr
394
- ], RadioGroup$1.prototype, "value", void 0);
395
- index.__decorate([
396
- index.attr
397
- ], RadioGroup$1.prototype, "orientation", void 0);
398
- index.__decorate([
399
- index.observable
400
- ], RadioGroup$1.prototype, "childItems", void 0);
401
- index.__decorate([
402
- index.observable
403
- ], RadioGroup$1.prototype, "slottedRadioButtons", void 0);
404
9
 
405
10
  const styles = ".positioning-region{display:flex;flex-wrap:wrap;gap:8px}.positioning-region.vertical{flex-direction:column}label+.positioning-region{margin-block-start:8px}label{color:var(--vvd-color-canvas-text);font:var(--vvd-typography-base)}";
406
11
 
@@ -413,11 +18,234 @@ var __decorateClass = (decorators, target, key, kind) => {
413
18
  if (result) __defProp(target, key, result);
414
19
  return result;
415
20
  };
416
- class RadioGroup extends RadioGroup$1 {
21
+ class RadioGroup extends index.FoundationElement {
22
+ constructor() {
23
+ super(...arguments);
24
+ this.orientation = // eslint-disable-next-line @nrwl/nx/workspace/no-attribute-default-value
25
+ aria.Orientation.horizontal;
26
+ this.slottedRadioButtons = [];
27
+ this.radioChangeHandler = (e) => {
28
+ const changedRadio = e.target;
29
+ if (changedRadio.checked) {
30
+ this.slottedRadioButtons.forEach((radio) => {
31
+ if (radio !== changedRadio) {
32
+ radio.checked = false;
33
+ }
34
+ });
35
+ this.value = changedRadio.value;
36
+ this.#setTabRovingTarget(changedRadio);
37
+ }
38
+ e.stopPropagation();
39
+ };
40
+ this.moveToRadioByIndex = (group, index) => {
41
+ const radio = group[index];
42
+ if (!this.isInsideToolbar && !radio.readOnly) {
43
+ radio.checked = true;
44
+ }
45
+ radio.focus();
46
+ };
47
+ this.moveRightOffGroup = () => {
48
+ this.nextElementSibling?.focus();
49
+ };
50
+ this.moveLeftOffGroup = () => {
51
+ this.previousElementSibling?.focus();
52
+ };
53
+ this.moveRight = (e) => {
54
+ const radio = e.target;
55
+ const group = this.#focusableRadioButtons;
56
+ let index = 0;
57
+ index = group.indexOf(radio) + 1;
58
+ if (index === group.length && this.isInsideToolbar && e.key === keyCodes.keyArrowRight) {
59
+ this.moveRightOffGroup();
60
+ return;
61
+ }
62
+ if (index === group.length) {
63
+ index = 0;
64
+ }
65
+ this.moveToRadioByIndex(group, index);
66
+ };
67
+ this.moveLeft = (e) => {
68
+ const radio = e.target;
69
+ const group = this.#focusableRadioButtons;
70
+ let index = group.indexOf(radio) - 1;
71
+ if (this.isInsideToolbar && e.key === keyCodes.keyArrowLeft && index < 0) {
72
+ this.moveLeftOffGroup();
73
+ return;
74
+ }
75
+ index = index < 0 ? group.length - 1 : index;
76
+ this.moveToRadioByIndex(group, index);
77
+ };
78
+ /**
79
+ * keyboard handling per https://w3c.github.io/aria-practices/#for-radio-groups-not-contained-in-a-toolbar
80
+ * navigation is different when there is an ancestor with role='toolbar'
81
+ *
82
+ * @internal
83
+ */
84
+ this.keydownHandler = (e) => {
85
+ switch (e.key) {
86
+ case keyCodes.keyEnter:
87
+ this.checkFocusedRadio(e.target);
88
+ break;
89
+ case keyCodes.keyArrowRight:
90
+ case keyCodes.keyArrowDown:
91
+ this.moveRight(e);
92
+ break;
93
+ case keyCodes.keyArrowLeft:
94
+ case keyCodes.keyArrowUp:
95
+ this.moveLeft(e);
96
+ break;
97
+ default:
98
+ return true;
99
+ }
100
+ };
101
+ }
102
+ /**
103
+ * @internal
104
+ */
105
+ readOnlyChanged() {
106
+ this.slottedRadioButtons.forEach((radio) => {
107
+ if (this.readOnly) {
108
+ radio.readOnly = true;
109
+ } else {
110
+ radio.readOnly = false;
111
+ }
112
+ });
113
+ }
114
+ /**
115
+ * @internal
116
+ */
117
+ disabledChanged() {
118
+ this.slottedRadioButtons.forEach((radio) => {
119
+ if (this.disabled) {
120
+ radio.disabled = true;
121
+ } else {
122
+ radio.disabled = false;
123
+ }
124
+ });
125
+ }
126
+ nameChanged() {
127
+ this.slottedRadioButtons.forEach((radio) => {
128
+ radio.setAttribute("name", this.name);
129
+ });
130
+ }
131
+ /**
132
+ * @internal
133
+ */
134
+ valueChanged() {
135
+ this.slottedRadioButtons.forEach((radio) => {
136
+ if (radio.value === this.value) {
137
+ radio.checked = true;
138
+ }
139
+ });
140
+ this.$emit("change");
141
+ }
142
+ get #focusableRadioButtons() {
143
+ return this.slottedRadioButtons.filter((radio) => !radio.disabled);
144
+ }
145
+ /**
146
+ * @internal
147
+ */
148
+ slottedRadioButtonsChanged() {
149
+ if (this.slottedRadioButtons && this.slottedRadioButtons.length > 0) {
150
+ this.setupRadioButtons();
151
+ }
152
+ }
153
+ get isInsideToolbar() {
154
+ return !!this.closest('[role="toolbar"]');
155
+ }
156
+ /**
157
+ * @internal
158
+ */
159
+ connectedCallback() {
160
+ super.connectedCallback();
161
+ this.setupRadioButtons();
162
+ }
163
+ disconnectedCallback() {
164
+ this.slottedRadioButtons.forEach((radio) => {
165
+ radio.removeEventListener(
166
+ "change",
167
+ this.radioChangeHandler
168
+ );
169
+ });
170
+ }
171
+ setupRadioButtons() {
172
+ let foundMatchingVal = false;
173
+ for (const radio of this.slottedRadioButtons) {
174
+ if (this.name !== void 0) {
175
+ radio.setAttribute("name", this.name);
176
+ }
177
+ if (this.disabled) {
178
+ radio.disabled = true;
179
+ }
180
+ if (this.readOnly) {
181
+ radio.readOnly = true;
182
+ }
183
+ if (this.value && this.value === radio.value) {
184
+ radio.checked = true;
185
+ this.#setTabRovingTarget(radio);
186
+ foundMatchingVal = true;
187
+ } else {
188
+ radio.checked = false;
189
+ }
190
+ radio.addEventListener(
191
+ "change",
192
+ this.radioChangeHandler
193
+ );
194
+ }
195
+ if (this.value === void 0 && this.slottedRadioButtons.length > 0) {
196
+ const checkedRadios = this.slottedRadioButtons.filter(
197
+ (radio) => radio.hasAttribute("checked")
198
+ );
199
+ if (checkedRadios.length > 0 && !foundMatchingVal) {
200
+ const lastCheckedRadio = checkedRadios[checkedRadios.length - 1];
201
+ lastCheckedRadio.checked = true;
202
+ this.#setTabRovingTarget(lastCheckedRadio);
203
+ } else {
204
+ this.#setTabRovingTarget(this.slottedRadioButtons[0]);
205
+ }
206
+ }
207
+ }
208
+ /**
209
+ * @internal
210
+ */
211
+ focusInHandler(e) {
212
+ this.#setTabRovingTarget(e.target);
213
+ }
214
+ #setTabRovingTarget(radio) {
215
+ radio.setAttribute("tabindex", "0");
216
+ for (const slottedRadio of this.slottedRadioButtons) {
217
+ if (slottedRadio !== radio) {
218
+ slottedRadio.setAttribute("tabindex", "-1");
219
+ }
220
+ }
221
+ }
222
+ checkFocusedRadio(target) {
223
+ if (!target.readOnly) {
224
+ target.checked = true;
225
+ }
226
+ }
417
227
  }
418
228
  __decorateClass([
419
229
  index.attr
420
230
  ], RadioGroup.prototype, "label");
231
+ __decorateClass([
232
+ index.attr({ attribute: "readonly", mode: "boolean" })
233
+ ], RadioGroup.prototype, "readOnly");
234
+ __decorateClass([
235
+ index.attr({ attribute: "disabled", mode: "boolean" })
236
+ ], RadioGroup.prototype, "disabled");
237
+ __decorateClass([
238
+ index.attr
239
+ ], RadioGroup.prototype, "name");
240
+ __decorateClass([
241
+ index.attr
242
+ ], RadioGroup.prototype, "value");
243
+ __decorateClass([
244
+ index.attr
245
+ ], RadioGroup.prototype, "orientation");
246
+ __decorateClass([
247
+ index.observable
248
+ ], RadioGroup.prototype, "slottedRadioButtons");
421
249
 
422
250
  const RadioGroupTemplate = (context) => {
423
251
  return index.html`
@@ -426,9 +254,8 @@ const RadioGroupTemplate = (context) => {
426
254
  aria-disabled="${(x) => x.disabled}"
427
255
  aria-readonly="${(x) => x.readOnly}"
428
256
  aria-orientation="${(x) => x.orientation}"
429
- @click="${(x, c) => x.clickHandler(c.event)}"
430
257
  @keydown="${(x, c) => x.keydownHandler(c.event)}"
431
- @focusout="${(x, c) => x.focusOutHandler(c.event)}"
258
+ @focusin="${(x, c) => x.focusInHandler(c.event)}"
432
259
  >
433
260
  ${when.when(
434
261
  (x) => x.label,