@vonage/vivid 3.0.0-next.119 → 3.0.0-next.120
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/README.md +11 -6
- package/accordion/index.js +4 -51
- package/accordion-item/index.js +11 -109
- package/action-group/index.js +4 -36
- package/avatar/index.js +8 -64
- package/badge/index.js +9 -48
- package/banner/index.js +15 -117
- package/breadcrumb/index.js +5 -97
- package/breadcrumb-item/index.js +14 -53
- package/button/index.js +14 -92
- package/calendar/index.js +5 -1520
- package/calendar-event/index.js +7 -107
- package/card/index.js +10 -117
- package/checkbox/index.js +13 -175
- package/custom-elements.json +1827 -8
- package/dialog/index.js +14 -227
- package/divider/index.js +4 -25
- package/elevation/index.js +4 -24
- package/fab/index.js +13 -89
- package/focus/index.js +4 -17
- package/header/index.js +7 -12
- package/icon/index.js +7 -28
- package/index.js +49 -55
- package/layout/index.js +4 -42
- package/lib/accordion/definition.d.ts +3 -0
- package/lib/accordion/index.d.ts +1 -2
- package/lib/accordion-item/definition.d.ts +3 -0
- package/lib/accordion-item/index.d.ts +1 -2
- package/lib/action-group/definition.d.ts +3 -0
- package/lib/action-group/index.d.ts +1 -2
- package/lib/avatar/definition.d.ts +3 -0
- package/lib/avatar/index.d.ts +1 -2
- package/lib/badge/definition.d.ts +3 -0
- package/lib/badge/index.d.ts +1 -2
- package/lib/banner/definition.d.ts +3 -0
- package/lib/banner/index.d.ts +1 -2
- package/lib/breadcrumb/definition.d.ts +3 -0
- package/lib/breadcrumb/index.d.ts +1 -2
- package/lib/breadcrumb-item/definition.d.ts +3 -0
- package/lib/breadcrumb-item/index.d.ts +1 -2
- package/lib/button/definition.d.ts +3 -0
- package/lib/calendar/definition.d.ts +3 -0
- package/lib/calendar/index.d.ts +1 -2
- package/lib/calendar-event/definition.d.ts +3 -0
- package/lib/calendar-event/index.d.ts +1 -2
- package/lib/card/definition.d.ts +3 -0
- package/lib/card/index.d.ts +1 -2
- package/lib/checkbox/definition.d.ts +3 -0
- package/lib/checkbox/index.d.ts +1 -2
- package/lib/components.d.ts +38 -38
- package/lib/dialog/definition.d.ts +3 -0
- package/lib/dialog/index.d.ts +1 -2
- package/lib/divider/definition.d.ts +3 -0
- package/lib/divider/index.d.ts +1 -2
- package/lib/elevation/definition.d.ts +3 -0
- package/lib/elevation/index.d.ts +1 -2
- package/lib/fab/definition.d.ts +3 -0
- package/lib/fab/index.d.ts +1 -2
- package/lib/focus/definition.d.ts +3 -0
- package/lib/focus/index.d.ts +1 -2
- package/lib/header/definition.d.ts +3 -0
- package/lib/header/index.d.ts +1 -2
- package/lib/icon/definition.d.ts +3 -0
- package/lib/icon/index.d.ts +1 -2
- package/lib/layout/definition.d.ts +3 -0
- package/lib/layout/index.d.ts +1 -2
- package/lib/listbox/definition.d.ts +3 -0
- package/lib/menu/definition.d.ts +7 -0
- package/lib/menu/index.d.ts +1 -10
- package/lib/menu-item/definition.d.ts +3 -0
- package/lib/menu-item/index.d.ts +1 -2
- package/lib/nav/definition.d.ts +3 -0
- package/lib/nav/index.d.ts +1 -2
- package/lib/nav-disclosure/definition.d.ts +3 -0
- package/lib/nav-disclosure/index.d.ts +1 -2
- package/lib/nav-item/definition.d.ts +3 -0
- package/lib/nav-item/index.d.ts +1 -2
- package/lib/note/definition.d.ts +3 -0
- package/lib/note/index.d.ts +1 -2
- package/lib/number-field/definition.d.ts +3 -0
- package/lib/number-field/index.d.ts +1 -2
- package/lib/option/definition.d.ts +3 -0
- package/lib/option/index.d.ts +1 -2
- package/lib/popup/definition.d.ts +4 -0
- package/lib/popup/index.d.ts +1 -2
- package/lib/progress/definition.d.ts +3 -0
- package/lib/progress/index.d.ts +1 -2
- package/lib/progress-ring/definition.d.ts +3 -0
- package/lib/progress-ring/index.d.ts +1 -2
- package/lib/radio/definition.d.ts +3 -0
- package/lib/radio/index.d.ts +1 -2
- package/lib/radio-group/definition.d.ts +7 -0
- package/lib/radio-group/index.d.ts +1 -10
- package/lib/side-drawer/definition.d.ts +3 -0
- package/lib/side-drawer/index.d.ts +1 -2
- package/lib/slider/definition.d.ts +3 -0
- package/lib/slider/index.d.ts +1 -2
- package/lib/switch/definition.d.ts +3 -0
- package/lib/switch/index.d.ts +1 -2
- package/lib/text-anchor/definition.d.ts +3 -0
- package/lib/text-anchor/index.d.ts +1 -2
- package/lib/text-area/definition.d.ts +3 -0
- package/lib/text-area/index.d.ts +1 -2
- package/lib/text-field/definition.d.ts +3 -0
- package/lib/text-field/index.d.ts +1 -2
- package/lib/tooltip/definition.d.ts +3 -0
- package/lib/tooltip/index.d.ts +1 -2
- package/listbox/index.js +18 -1080
- package/menu/index.js +27 -354
- package/menu-item/index.js +11 -81
- package/nav/index.js +3 -16
- package/nav-disclosure/index.js +13 -77
- package/nav-item/index.js +13 -35
- package/note/index.js +13 -60
- package/number-field/index.js +14 -16
- package/option/index.js +13 -68
- package/package.json +2 -2
- package/popup/index.js +17 -55
- package/progress/index.js +6 -92
- package/progress-ring/index.js +6 -75
- package/radio/index.js +8 -48
- package/radio-group/index.js +9 -433
- package/shared/anchor.js +1 -1
- package/shared/apply-mixins.js +1 -1
- package/shared/base-progress.js +1 -1
- package/shared/breadcrumb-item.js +1 -1
- package/shared/button.js +195 -18
- package/shared/calendar-event.js +1 -1
- package/shared/definition.js +53 -0
- package/shared/definition10.js +99 -0
- package/shared/definition11.js +48 -0
- package/shared/definition12.js +1523 -0
- package/shared/definition13.js +111 -0
- package/shared/definition14.js +114 -0
- package/shared/definition15.js +32 -0
- package/shared/definition16.js +172 -0
- package/shared/definition17.js +223 -0
- package/shared/{divider.js → definition18.js} +25 -2
- package/shared/definition19.js +87 -0
- package/shared/definition2.js +106 -0
- package/shared/definition20.js +44 -0
- package/shared/definition21.js +1078 -0
- package/shared/{listbox-option.js → definition22.js} +71 -11
- package/shared/definition23.js +348 -0
- package/shared/{popup.js → definition24.js} +46 -3
- package/shared/{menu-item.js → definition25.js} +87 -13
- package/shared/definition26.js +18 -0
- package/shared/definition27.js +75 -0
- package/shared/definition28.js +31 -0
- package/shared/definition29.js +56 -0
- package/shared/definition3.js +29 -0
- package/shared/definition30.js +94 -0
- package/shared/definition31.js +77 -0
- package/shared/definition32.js +45 -0
- package/shared/definition33.js +435 -0
- package/shared/definition34.js +86 -0
- package/shared/definition35.js +592 -0
- package/shared/definition36.js +147 -0
- package/shared/definition37.js +279 -0
- package/shared/definition38.js +119 -0
- package/shared/definition39.js +77 -0
- package/shared/definition4.js +19 -0
- package/shared/definition5.js +38 -0
- package/shared/definition6.js +60 -0
- package/shared/definition7.js +45 -0
- package/shared/definition8.js +113 -0
- package/shared/definition9.js +107 -0
- package/shared/design-system/index.d.ts +1 -2
- package/shared/es.object.assign.js +58 -1
- package/shared/es.regexp.to-string.js +2 -1
- package/shared/focus.js +3 -9
- package/shared/focus2.js +9 -3
- package/shared/form-associated.js +1 -1
- package/shared/form-elements.js +2 -2
- package/shared/icon.js +1096 -9
- package/shared/index.js +385 -2501
- package/shared/patterns/form-elements/form-elements.d.ts +2 -2
- package/shared/radio.js +1 -1
- package/shared/ref.js +1 -1
- package/shared/slotted.js +1 -1
- package/shared/string-trim.js +2 -1
- package/shared/text-anchor.template.js +1 -1
- package/shared/to-string.js +51 -0
- package/side-drawer/index.js +5 -84
- package/slider/index.js +14 -593
- package/styles/core/all.css +1 -1
- package/styles/core/theme.css +1 -1
- package/styles/core/typography.css +1 -1
- package/styles/tokens/theme-dark.css +4 -4
- package/styles/tokens/theme-light.css +4 -4
- package/switch/index.js +13 -149
- package/text-anchor/index.js +8 -7
- package/text-area/index.js +16 -282
- package/text-field/index.js +14 -121
- package/tooltip/index.js +24 -82
- package/vivid.api.json +1640 -850
- package/shared/button2.js +0 -200
- package/shared/elevation.js +0 -10
- package/shared/es.promise.resolve.js +0 -944
- package/shared/index2.js +0 -9
- package/shared/utils/index.d.ts +0 -1
|
@@ -0,0 +1,435 @@
|
|
|
1
|
+
import { F as FoundationElement, _ as __decorate, a as attr, N as observable, b as __metadata, h as html, r as registerFactorial } from './index.js';
|
|
2
|
+
import { D as Direction, g as getDirection } from './direction.js';
|
|
3
|
+
import { i as keyArrowRight, h as keyArrowLeft, A as ArrowKeys, e as keyArrowUp, f as keyArrowDown, k as keyEnter } from './key-codes.js';
|
|
4
|
+
import { O as Orientation } from './aria.js';
|
|
5
|
+
import { R as Radio } from './radio.js';
|
|
6
|
+
import { s as slotted, e as elements } from './slotted.js';
|
|
7
|
+
import { w as when } from './when.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* An Radio Group Custom HTML Element.
|
|
11
|
+
* Implements the {@link https://www.w3.org/TR/wai-aria-1.1/#radiogroup | ARIA radiogroup }.
|
|
12
|
+
*
|
|
13
|
+
* @slot label - The slot for the label
|
|
14
|
+
* @slot - The default slot for radio buttons
|
|
15
|
+
* @csspart positioning-region - The positioning region for laying out the radios
|
|
16
|
+
* @fires change - Fires a custom 'change' event when the value changes
|
|
17
|
+
*
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
class RadioGroup$1 extends FoundationElement {
|
|
21
|
+
constructor() {
|
|
22
|
+
super(...arguments);
|
|
23
|
+
/**
|
|
24
|
+
* The orientation of the group
|
|
25
|
+
*
|
|
26
|
+
* @public
|
|
27
|
+
* @remarks
|
|
28
|
+
* HTML Attribute: orientation
|
|
29
|
+
*/
|
|
30
|
+
this.orientation = Orientation.horizontal;
|
|
31
|
+
this.radioChangeHandler = (e) => {
|
|
32
|
+
const changedRadio = e.target;
|
|
33
|
+
if (changedRadio.checked) {
|
|
34
|
+
this.slottedRadioButtons.forEach((radio) => {
|
|
35
|
+
if (radio !== changedRadio) {
|
|
36
|
+
radio.checked = false;
|
|
37
|
+
if (!this.isInsideFoundationToolbar) {
|
|
38
|
+
radio.setAttribute("tabindex", "-1");
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
this.selectedRadio = changedRadio;
|
|
43
|
+
this.value = changedRadio.value;
|
|
44
|
+
changedRadio.setAttribute("tabindex", "0");
|
|
45
|
+
this.focusedRadio = changedRadio;
|
|
46
|
+
}
|
|
47
|
+
e.stopPropagation();
|
|
48
|
+
};
|
|
49
|
+
this.moveToRadioByIndex = (group, index) => {
|
|
50
|
+
const radio = group[index];
|
|
51
|
+
if (!this.isInsideToolbar) {
|
|
52
|
+
radio.setAttribute("tabindex", "0");
|
|
53
|
+
if (radio.readOnly) {
|
|
54
|
+
this.slottedRadioButtons.forEach((nextRadio) => {
|
|
55
|
+
if (nextRadio !== radio) {
|
|
56
|
+
nextRadio.setAttribute("tabindex", "-1");
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
radio.checked = true;
|
|
62
|
+
this.selectedRadio = radio;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
this.focusedRadio = radio;
|
|
66
|
+
radio.focus();
|
|
67
|
+
};
|
|
68
|
+
this.moveRightOffGroup = () => {
|
|
69
|
+
var _a;
|
|
70
|
+
(_a = this.nextElementSibling) === null || _a === void 0 ? void 0 : _a.focus();
|
|
71
|
+
};
|
|
72
|
+
this.moveLeftOffGroup = () => {
|
|
73
|
+
var _a;
|
|
74
|
+
(_a = this.previousElementSibling) === null || _a === void 0 ? void 0 : _a.focus();
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* @internal
|
|
78
|
+
*/
|
|
79
|
+
this.focusOutHandler = (e) => {
|
|
80
|
+
const group = this.slottedRadioButtons;
|
|
81
|
+
const radio = e.target;
|
|
82
|
+
const index = radio !== null ? group.indexOf(radio) : 0;
|
|
83
|
+
const focusedIndex = this.focusedRadio
|
|
84
|
+
? group.indexOf(this.focusedRadio)
|
|
85
|
+
: -1;
|
|
86
|
+
if ((focusedIndex === 0 && index === focusedIndex) ||
|
|
87
|
+
(focusedIndex === group.length - 1 && focusedIndex === index)) {
|
|
88
|
+
if (!this.selectedRadio) {
|
|
89
|
+
this.focusedRadio = group[0];
|
|
90
|
+
this.focusedRadio.setAttribute("tabindex", "0");
|
|
91
|
+
group.forEach((nextRadio) => {
|
|
92
|
+
if (nextRadio !== this.focusedRadio) {
|
|
93
|
+
nextRadio.setAttribute("tabindex", "-1");
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
this.focusedRadio = this.selectedRadio;
|
|
99
|
+
if (!this.isInsideFoundationToolbar) {
|
|
100
|
+
this.selectedRadio.setAttribute("tabindex", "0");
|
|
101
|
+
group.forEach((nextRadio) => {
|
|
102
|
+
if (nextRadio !== this.selectedRadio) {
|
|
103
|
+
nextRadio.setAttribute("tabindex", "-1");
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return true;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* @internal
|
|
113
|
+
*/
|
|
114
|
+
this.clickHandler = (e) => {
|
|
115
|
+
const radio = e.target;
|
|
116
|
+
if (radio) {
|
|
117
|
+
const group = this.slottedRadioButtons;
|
|
118
|
+
if (radio.checked || group.indexOf(radio) === 0) {
|
|
119
|
+
radio.setAttribute("tabindex", "0");
|
|
120
|
+
this.selectedRadio = radio;
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
radio.setAttribute("tabindex", "-1");
|
|
124
|
+
this.selectedRadio = null;
|
|
125
|
+
}
|
|
126
|
+
this.focusedRadio = radio;
|
|
127
|
+
}
|
|
128
|
+
e.preventDefault();
|
|
129
|
+
};
|
|
130
|
+
this.shouldMoveOffGroupToTheRight = (index, group, key) => {
|
|
131
|
+
return index === group.length && this.isInsideToolbar && key === keyArrowRight;
|
|
132
|
+
};
|
|
133
|
+
this.shouldMoveOffGroupToTheLeft = (group, key) => {
|
|
134
|
+
const index = this.focusedRadio ? group.indexOf(this.focusedRadio) - 1 : 0;
|
|
135
|
+
return index < 0 && this.isInsideToolbar && key === keyArrowLeft;
|
|
136
|
+
};
|
|
137
|
+
this.checkFocusedRadio = () => {
|
|
138
|
+
if (this.focusedRadio !== null &&
|
|
139
|
+
!this.focusedRadio.readOnly &&
|
|
140
|
+
!this.focusedRadio.checked) {
|
|
141
|
+
this.focusedRadio.checked = true;
|
|
142
|
+
this.focusedRadio.setAttribute("tabindex", "0");
|
|
143
|
+
this.focusedRadio.focus();
|
|
144
|
+
this.selectedRadio = this.focusedRadio;
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
this.moveRight = (e) => {
|
|
148
|
+
const group = this.slottedRadioButtons;
|
|
149
|
+
let index = 0;
|
|
150
|
+
index = this.focusedRadio ? group.indexOf(this.focusedRadio) + 1 : 1;
|
|
151
|
+
if (this.shouldMoveOffGroupToTheRight(index, group, e.key)) {
|
|
152
|
+
this.moveRightOffGroup();
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
else if (index === group.length) {
|
|
156
|
+
index = 0;
|
|
157
|
+
}
|
|
158
|
+
/* looping to get to next radio that is not disabled */
|
|
159
|
+
/* matching native radio/radiogroup which does not select an item if there is only 1 in the group */
|
|
160
|
+
while (index < group.length && group.length > 1) {
|
|
161
|
+
if (!group[index].disabled) {
|
|
162
|
+
this.moveToRadioByIndex(group, index);
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
else if (this.focusedRadio && index === group.indexOf(this.focusedRadio)) {
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
else if (index + 1 >= group.length) {
|
|
169
|
+
if (this.isInsideToolbar) {
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
index = 0;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
index += 1;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
this.moveLeft = (e) => {
|
|
182
|
+
const group = this.slottedRadioButtons;
|
|
183
|
+
let index = 0;
|
|
184
|
+
index = this.focusedRadio ? group.indexOf(this.focusedRadio) - 1 : 0;
|
|
185
|
+
index = index < 0 ? group.length - 1 : index;
|
|
186
|
+
if (this.shouldMoveOffGroupToTheLeft(group, e.key)) {
|
|
187
|
+
this.moveLeftOffGroup();
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
/* looping to get to next radio that is not disabled */
|
|
191
|
+
while (index >= 0 && group.length > 1) {
|
|
192
|
+
if (!group[index].disabled) {
|
|
193
|
+
this.moveToRadioByIndex(group, index);
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
else if (this.focusedRadio && index === group.indexOf(this.focusedRadio)) {
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
else if (index - 1 < 0) {
|
|
200
|
+
index = group.length - 1;
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
index -= 1;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
/**
|
|
208
|
+
* keyboard handling per https://w3c.github.io/aria-practices/#for-radio-groups-not-contained-in-a-toolbar
|
|
209
|
+
* navigation is different when there is an ancestor with role='toolbar'
|
|
210
|
+
*
|
|
211
|
+
* @internal
|
|
212
|
+
*/
|
|
213
|
+
this.keydownHandler = (e) => {
|
|
214
|
+
const key = e.key;
|
|
215
|
+
if (key in ArrowKeys && this.isInsideFoundationToolbar) {
|
|
216
|
+
return true;
|
|
217
|
+
}
|
|
218
|
+
switch (key) {
|
|
219
|
+
case keyEnter: {
|
|
220
|
+
this.checkFocusedRadio();
|
|
221
|
+
break;
|
|
222
|
+
}
|
|
223
|
+
case keyArrowRight:
|
|
224
|
+
case keyArrowDown: {
|
|
225
|
+
if (this.direction === Direction.ltr) {
|
|
226
|
+
this.moveRight(e);
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
this.moveLeft(e);
|
|
230
|
+
}
|
|
231
|
+
break;
|
|
232
|
+
}
|
|
233
|
+
case keyArrowLeft:
|
|
234
|
+
case keyArrowUp: {
|
|
235
|
+
if (this.direction === Direction.ltr) {
|
|
236
|
+
this.moveLeft(e);
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
this.moveRight(e);
|
|
240
|
+
}
|
|
241
|
+
break;
|
|
242
|
+
}
|
|
243
|
+
default: {
|
|
244
|
+
return true;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
readOnlyChanged() {
|
|
250
|
+
if (this.slottedRadioButtons !== undefined) {
|
|
251
|
+
this.slottedRadioButtons.forEach((radio) => {
|
|
252
|
+
if (this.readOnly) {
|
|
253
|
+
radio.readOnly = true;
|
|
254
|
+
}
|
|
255
|
+
else {
|
|
256
|
+
radio.readOnly = false;
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
disabledChanged() {
|
|
262
|
+
if (this.slottedRadioButtons !== undefined) {
|
|
263
|
+
this.slottedRadioButtons.forEach((radio) => {
|
|
264
|
+
if (this.disabled) {
|
|
265
|
+
radio.disabled = true;
|
|
266
|
+
}
|
|
267
|
+
else {
|
|
268
|
+
radio.disabled = false;
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
nameChanged() {
|
|
274
|
+
if (this.slottedRadioButtons) {
|
|
275
|
+
this.slottedRadioButtons.forEach((radio) => {
|
|
276
|
+
radio.setAttribute("name", this.name);
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
valueChanged() {
|
|
281
|
+
if (this.slottedRadioButtons) {
|
|
282
|
+
this.slottedRadioButtons.forEach((radio) => {
|
|
283
|
+
if (radio.value === this.value) {
|
|
284
|
+
radio.checked = true;
|
|
285
|
+
this.selectedRadio = radio;
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
this.$emit("change");
|
|
290
|
+
}
|
|
291
|
+
slottedRadioButtonsChanged(oldValue, newValue) {
|
|
292
|
+
if (this.slottedRadioButtons && this.slottedRadioButtons.length > 0) {
|
|
293
|
+
this.setupRadioButtons();
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
get parentToolbar() {
|
|
297
|
+
return this.closest('[role="toolbar"]');
|
|
298
|
+
}
|
|
299
|
+
get isInsideToolbar() {
|
|
300
|
+
var _a;
|
|
301
|
+
return ((_a = this.parentToolbar) !== null && _a !== void 0 ? _a : false);
|
|
302
|
+
}
|
|
303
|
+
get isInsideFoundationToolbar() {
|
|
304
|
+
var _a;
|
|
305
|
+
return !!((_a = this.parentToolbar) === null || _a === void 0 ? void 0 : _a["$fastController"]);
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* @internal
|
|
309
|
+
*/
|
|
310
|
+
connectedCallback() {
|
|
311
|
+
super.connectedCallback();
|
|
312
|
+
this.direction = getDirection(this);
|
|
313
|
+
this.setupRadioButtons();
|
|
314
|
+
}
|
|
315
|
+
disconnectedCallback() {
|
|
316
|
+
this.slottedRadioButtons.forEach((radio) => {
|
|
317
|
+
radio.removeEventListener("change", this.radioChangeHandler);
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
setupRadioButtons() {
|
|
321
|
+
const checkedRadios = this.slottedRadioButtons.filter((radio) => {
|
|
322
|
+
return radio.hasAttribute("checked");
|
|
323
|
+
});
|
|
324
|
+
const numberOfCheckedRadios = checkedRadios ? checkedRadios.length : 0;
|
|
325
|
+
if (numberOfCheckedRadios > 1) {
|
|
326
|
+
const lastCheckedRadio = checkedRadios[numberOfCheckedRadios - 1];
|
|
327
|
+
lastCheckedRadio.checked = true;
|
|
328
|
+
}
|
|
329
|
+
let foundMatchingVal = false;
|
|
330
|
+
this.slottedRadioButtons.forEach((radio) => {
|
|
331
|
+
if (this.name !== undefined) {
|
|
332
|
+
radio.setAttribute("name", this.name);
|
|
333
|
+
}
|
|
334
|
+
if (this.disabled) {
|
|
335
|
+
radio.disabled = true;
|
|
336
|
+
}
|
|
337
|
+
if (this.readOnly) {
|
|
338
|
+
radio.readOnly = true;
|
|
339
|
+
}
|
|
340
|
+
if (this.value && this.value === radio.value) {
|
|
341
|
+
this.selectedRadio = radio;
|
|
342
|
+
this.focusedRadio = radio;
|
|
343
|
+
radio.checked = true;
|
|
344
|
+
radio.setAttribute("tabindex", "0");
|
|
345
|
+
foundMatchingVal = true;
|
|
346
|
+
}
|
|
347
|
+
else {
|
|
348
|
+
if (!this.isInsideFoundationToolbar) {
|
|
349
|
+
radio.setAttribute("tabindex", "-1");
|
|
350
|
+
}
|
|
351
|
+
radio.checked = false;
|
|
352
|
+
}
|
|
353
|
+
radio.addEventListener("change", this.radioChangeHandler);
|
|
354
|
+
});
|
|
355
|
+
if (this.value === undefined && this.slottedRadioButtons.length > 0) {
|
|
356
|
+
const checkedRadios = this.slottedRadioButtons.filter((radio) => {
|
|
357
|
+
return radio.hasAttribute("checked");
|
|
358
|
+
});
|
|
359
|
+
const numberOfCheckedRadios = checkedRadios !== null ? checkedRadios.length : 0;
|
|
360
|
+
if (numberOfCheckedRadios > 0 && !foundMatchingVal) {
|
|
361
|
+
const lastCheckedRadio = checkedRadios[numberOfCheckedRadios - 1];
|
|
362
|
+
lastCheckedRadio.checked = true;
|
|
363
|
+
this.focusedRadio = lastCheckedRadio;
|
|
364
|
+
lastCheckedRadio.setAttribute("tabindex", "0");
|
|
365
|
+
}
|
|
366
|
+
else {
|
|
367
|
+
this.slottedRadioButtons[0].setAttribute("tabindex", "0");
|
|
368
|
+
this.focusedRadio = this.slottedRadioButtons[0];
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
__decorate([
|
|
374
|
+
attr({ attribute: "readonly", mode: "boolean" })
|
|
375
|
+
], RadioGroup$1.prototype, "readOnly", void 0);
|
|
376
|
+
__decorate([
|
|
377
|
+
attr({ attribute: "disabled", mode: "boolean" })
|
|
378
|
+
], RadioGroup$1.prototype, "disabled", void 0);
|
|
379
|
+
__decorate([
|
|
380
|
+
attr
|
|
381
|
+
], RadioGroup$1.prototype, "name", void 0);
|
|
382
|
+
__decorate([
|
|
383
|
+
attr
|
|
384
|
+
], RadioGroup$1.prototype, "value", void 0);
|
|
385
|
+
__decorate([
|
|
386
|
+
attr
|
|
387
|
+
], RadioGroup$1.prototype, "orientation", void 0);
|
|
388
|
+
__decorate([
|
|
389
|
+
observable
|
|
390
|
+
], RadioGroup$1.prototype, "childItems", void 0);
|
|
391
|
+
__decorate([
|
|
392
|
+
observable
|
|
393
|
+
], RadioGroup$1.prototype, "slottedRadioButtons", void 0);
|
|
394
|
+
|
|
395
|
+
var css_248z = "/**\n * Do not edit directly\n * Generated on Wed, 14 Dec 2022 16:38:57 GMT\n */\n.positioning-region {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n}\n.positioning-region.vertical {\n flex-direction: column;\n}\nlabel + .positioning-region {\n margin-block-start: 8px;\n}\n\nlabel {\n color: var(--vvd-color-canvas-text);\n font: var(--vvd-typography-base);\n}";
|
|
396
|
+
|
|
397
|
+
class RadioGroup extends RadioGroup$1 {}
|
|
398
|
+
__decorate([attr, __metadata("design:type", String)], RadioGroup.prototype, "label", void 0);
|
|
399
|
+
|
|
400
|
+
let _ = t => t,
|
|
401
|
+
_t,
|
|
402
|
+
_t2;
|
|
403
|
+
const RadioGroupTemplate = context => {
|
|
404
|
+
return html(_t || (_t = _`
|
|
405
|
+
<template
|
|
406
|
+
role="radiogroup"
|
|
407
|
+
aria-disabled="${0}"
|
|
408
|
+
aria-readonly="${0}"
|
|
409
|
+
aria-orientation="${0}"
|
|
410
|
+
@click="${0}"
|
|
411
|
+
@keydown="${0}"
|
|
412
|
+
@focusout="${0}"
|
|
413
|
+
>
|
|
414
|
+
|
|
415
|
+
${0}
|
|
416
|
+
|
|
417
|
+
<div class="positioning-region ${0}">
|
|
418
|
+
<slot ${0}></slot>
|
|
419
|
+
</div>
|
|
420
|
+
</template>
|
|
421
|
+
`), x => x.disabled, x => x.readOnly, x => x.orientation, (x, c) => x.clickHandler(c.event), (x, c) => x.keydownHandler(c.event), (x, c) => x.focusOutHandler(c.event), when(x => x.label, html(_t2 || (_t2 = _`<label>${0}</label>`), x => x.label)), x => x.orientation === Orientation.horizontal ? 'horizontal' : 'vertical', slotted({
|
|
422
|
+
property: 'slottedRadioButtons',
|
|
423
|
+
filter: elements(context.tagFor(Radio))
|
|
424
|
+
}));
|
|
425
|
+
};
|
|
426
|
+
|
|
427
|
+
const radioGroup = RadioGroup.compose({
|
|
428
|
+
baseName: 'radio-group',
|
|
429
|
+
template: RadioGroupTemplate,
|
|
430
|
+
styles: css_248z
|
|
431
|
+
})();
|
|
432
|
+
const radioGroupElements = [radioGroup];
|
|
433
|
+
const registerRadioGroup = registerFactorial(radioGroupElements);
|
|
434
|
+
|
|
435
|
+
export { radioGroup as a, radioGroupElements as b, registerRadioGroup as r };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { F as FoundationElement, Q as __classPrivateFieldGet, _ as __decorate, a as attr, b as __metadata, h as html, r as registerFactorial } from './index.js';
|
|
2
|
+
import { w as when } from './when.js';
|
|
3
|
+
import { c as classNames } from './class-names.js';
|
|
4
|
+
|
|
5
|
+
var _SideDrawer_instances, _SideDrawer_close, _SideDrawer_open;
|
|
6
|
+
class SideDrawer extends FoundationElement {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
_SideDrawer_instances.add(this);
|
|
10
|
+
this.alternate = false;
|
|
11
|
+
this.modal = false;
|
|
12
|
+
this.open = false;
|
|
13
|
+
this.trailing = false;
|
|
14
|
+
}
|
|
15
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
16
|
+
super.attributeChangedCallback(name, oldValue, newValue);
|
|
17
|
+
switch (name) {
|
|
18
|
+
case 'open':
|
|
19
|
+
{
|
|
20
|
+
this.open ? __classPrivateFieldGet(this, _SideDrawer_instances, "m", _SideDrawer_open).call(this) : __classPrivateFieldGet(this, _SideDrawer_instances, "m", _SideDrawer_close).call(this);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
_SideDrawer_instances = new WeakSet(), _SideDrawer_close = function _SideDrawer_close() {
|
|
26
|
+
this.$emit('close');
|
|
27
|
+
}, _SideDrawer_open = function _SideDrawer_open() {
|
|
28
|
+
this.$emit('open');
|
|
29
|
+
};
|
|
30
|
+
__decorate([attr({
|
|
31
|
+
mode: 'boolean'
|
|
32
|
+
}), __metadata("design:type", Object)], SideDrawer.prototype, "alternate", void 0);
|
|
33
|
+
__decorate([attr({
|
|
34
|
+
mode: 'boolean'
|
|
35
|
+
}), __metadata("design:type", Object)], SideDrawer.prototype, "modal", void 0);
|
|
36
|
+
__decorate([attr({
|
|
37
|
+
mode: 'boolean'
|
|
38
|
+
}), __metadata("design:type", Object)], SideDrawer.prototype, "open", void 0);
|
|
39
|
+
__decorate([attr({
|
|
40
|
+
mode: 'boolean'
|
|
41
|
+
}), __metadata("design:type", Object)], SideDrawer.prototype, "trailing", void 0);
|
|
42
|
+
|
|
43
|
+
var css_248z = "/**\n * Do not edit directly\n * Generated on Wed, 14 Dec 2022 16:38:57 GMT\n */\n.control {\n position: fixed;\n z-index: 1;\n background-color: var(--vvd-color-canvas);\n color: var(--vvd-color-canvas-text);\n inline-size: 280px;\n inset-block: 0;\n overflow-y: auto;\n}\n.control[part~=vvd-theme-alternate] {\n background-color: var(--vvd-color-canvas);\n color: var(--vvd-color-canvas-text);\n color-scheme: var(--vvd-color-scheme);\n}\n.control.trailing {\n inset-inline-end: 0;\n}\n.control:not(.open).trailing {\n transform: translateX(100%);\n}\n.control:not(.open):not(.trailing) {\n transform: translateX(-100%);\n}\n.control.open:not(.modal).trailing + .side-drawer-app-content {\n margin-inline-end: var(--side-drawer-app-content-offset, 280px);\n}\n.control.open:not(.modal):not(.trailing) + .side-drawer-app-content {\n margin-inline-start: var(--side-drawer-app-content-offset, 280px);\n}\n@media (prefers-reduced-motion: no-preference) {\n .control {\n transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);\n }\n}\n\n.scrim {\n background-color: var(--vvd-color-canvas-text);\n opacity: 0.5;\n position: fixed;\n inset: 0;\n}\n.scrim:not(.open) {\n display: none;\n}";
|
|
44
|
+
|
|
45
|
+
let _ = t => t,
|
|
46
|
+
_t,
|
|
47
|
+
_t2;
|
|
48
|
+
const getClasses = ({
|
|
49
|
+
modal,
|
|
50
|
+
open,
|
|
51
|
+
trailing
|
|
52
|
+
}) => classNames('control', ['modal', modal], ['open', open], ['trailing', trailing]);
|
|
53
|
+
const getScrimClasses = ({
|
|
54
|
+
open
|
|
55
|
+
}) => classNames('scrim', ['open', open]);
|
|
56
|
+
const sideDrawerTemplate = () => html(_t || (_t = _`
|
|
57
|
+
<aside class="${0}" part="base ${0}"
|
|
58
|
+
@keydown="${0}">
|
|
59
|
+
<slot></slot>
|
|
60
|
+
</aside>
|
|
61
|
+
|
|
62
|
+
<div class="side-drawer-app-content" ?inert="${0}">
|
|
63
|
+
<slot name="app-content"></slot>
|
|
64
|
+
</div>
|
|
65
|
+
|
|
66
|
+
${0}
|
|
67
|
+
`), getClasses, x => x.alternate ? 'vvd-theme-alternate' : '', (x, c) => handleKeydown(x, c.event), x => x.open && x.modal, when(x => x.modal, html(_t2 || (_t2 = _`<div class="${0}" @click="${0}"></div>`), getScrimClasses, x => x.open = false)));
|
|
68
|
+
const handleKeydown = (x, {
|
|
69
|
+
key
|
|
70
|
+
}) => {
|
|
71
|
+
if (key === 'Escape') {
|
|
72
|
+
x.open = false;
|
|
73
|
+
} else {
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const sideDrawer = SideDrawer.compose({
|
|
79
|
+
baseName: 'side-drawer',
|
|
80
|
+
template: sideDrawerTemplate,
|
|
81
|
+
styles: css_248z
|
|
82
|
+
})();
|
|
83
|
+
const sideDrawerElements = [sideDrawer];
|
|
84
|
+
const registerSideDrawer = registerFactorial(sideDrawerElements);
|
|
85
|
+
|
|
86
|
+
export { sideDrawerElements as a, registerSideDrawer as r, sideDrawer as s };
|