@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
package/menu/index.js
CHANGED
|
@@ -1,357 +1,30 @@
|
|
|
1
|
-
import '../shared/
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import '../shared/
|
|
11
|
-
import '../shared/
|
|
1
|
+
import { r as registerMenu } from '../shared/definition23.js';
|
|
2
|
+
import '../shared/index.js';
|
|
3
|
+
import '../shared/definition24.js';
|
|
4
|
+
import '../shared/definition9.js';
|
|
5
|
+
import '../shared/definition3.js';
|
|
6
|
+
import '../shared/icon.js';
|
|
7
|
+
import '../shared/to-string.js';
|
|
8
|
+
import '../shared/string-trim.js';
|
|
9
|
+
import '../shared/_has.js';
|
|
10
|
+
import '../shared/when.js';
|
|
11
|
+
import '../shared/class-names.js';
|
|
12
|
+
import '../shared/definition4.js';
|
|
13
|
+
import '../shared/focus.js';
|
|
14
|
+
import '../shared/affix.js';
|
|
15
|
+
import '../shared/button.js';
|
|
12
16
|
import '../shared/apply-mixins.js';
|
|
17
|
+
import '../shared/form-associated.js';
|
|
18
|
+
import '../shared/key-codes.js';
|
|
19
|
+
import '../shared/aria-global.js';
|
|
20
|
+
import '../shared/start-end.js';
|
|
21
|
+
import '../shared/ref.js';
|
|
22
|
+
import '../shared/focus2.js';
|
|
23
|
+
import '../shared/definition15.js';
|
|
13
24
|
import '../shared/es.object.assign.js';
|
|
25
|
+
import '../shared/definition25.js';
|
|
26
|
+
import '../shared/direction.js';
|
|
27
|
+
import '../shared/dom.js';
|
|
28
|
+
import '../shared/slotted.js';
|
|
14
29
|
|
|
15
|
-
|
|
16
|
-
* A Menu Custom HTML Element.
|
|
17
|
-
* Implements the {@link https://www.w3.org/TR/wai-aria-1.1/#menu | ARIA menu }.
|
|
18
|
-
*
|
|
19
|
-
* @slot - The default slot for the menu items
|
|
20
|
-
*
|
|
21
|
-
* @public
|
|
22
|
-
*/
|
|
23
|
-
class Menu$1 extends FoundationElement {
|
|
24
|
-
constructor() {
|
|
25
|
-
super(...arguments);
|
|
26
|
-
this.expandedItem = null;
|
|
27
|
-
/**
|
|
28
|
-
* The index of the focusable element in the items array
|
|
29
|
-
* defaults to -1
|
|
30
|
-
*/
|
|
31
|
-
this.focusIndex = -1;
|
|
32
|
-
/**
|
|
33
|
-
* @internal
|
|
34
|
-
*/
|
|
35
|
-
this.isNestedMenu = () => {
|
|
36
|
-
return (this.parentElement !== null &&
|
|
37
|
-
isHTMLElement(this.parentElement) &&
|
|
38
|
-
this.parentElement.getAttribute("role") === "menuitem");
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* if focus is moving out of the menu, reset to a stable initial state
|
|
42
|
-
* @internal
|
|
43
|
-
*/
|
|
44
|
-
this.handleFocusOut = (e) => {
|
|
45
|
-
if (!this.contains(e.relatedTarget) && this.menuItems !== undefined) {
|
|
46
|
-
this.collapseExpandedItem();
|
|
47
|
-
// find our first focusable element
|
|
48
|
-
const focusIndex = this.menuItems.findIndex(this.isFocusableElement);
|
|
49
|
-
// set the current focus index's tabindex to -1
|
|
50
|
-
this.menuItems[this.focusIndex].setAttribute("tabindex", "-1");
|
|
51
|
-
// set the first focusable element tabindex to 0
|
|
52
|
-
this.menuItems[focusIndex].setAttribute("tabindex", "0");
|
|
53
|
-
// set the focus index
|
|
54
|
-
this.focusIndex = focusIndex;
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
this.handleItemFocus = (e) => {
|
|
58
|
-
const targetItem = e.target;
|
|
59
|
-
if (this.menuItems !== undefined &&
|
|
60
|
-
targetItem !== this.menuItems[this.focusIndex]) {
|
|
61
|
-
this.menuItems[this.focusIndex].setAttribute("tabindex", "-1");
|
|
62
|
-
this.focusIndex = this.menuItems.indexOf(targetItem);
|
|
63
|
-
targetItem.setAttribute("tabindex", "0");
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
this.handleExpandedChanged = (e) => {
|
|
67
|
-
if (e.defaultPrevented ||
|
|
68
|
-
e.target === null ||
|
|
69
|
-
this.menuItems === undefined ||
|
|
70
|
-
this.menuItems.indexOf(e.target) < 0) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
e.preventDefault();
|
|
74
|
-
const changedItem = e.target;
|
|
75
|
-
// closing an expanded item without opening another
|
|
76
|
-
if (this.expandedItem !== null &&
|
|
77
|
-
changedItem === this.expandedItem &&
|
|
78
|
-
changedItem.expanded === false) {
|
|
79
|
-
this.expandedItem = null;
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
if (changedItem.expanded) {
|
|
83
|
-
if (this.expandedItem !== null && this.expandedItem !== changedItem) {
|
|
84
|
-
this.expandedItem.expanded = false;
|
|
85
|
-
}
|
|
86
|
-
this.menuItems[this.focusIndex].setAttribute("tabindex", "-1");
|
|
87
|
-
this.expandedItem = changedItem;
|
|
88
|
-
this.focusIndex = this.menuItems.indexOf(changedItem);
|
|
89
|
-
changedItem.setAttribute("tabindex", "0");
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
this.removeItemListeners = () => {
|
|
93
|
-
if (this.menuItems !== undefined) {
|
|
94
|
-
this.menuItems.forEach((item) => {
|
|
95
|
-
item.removeEventListener("expanded-change", this.handleExpandedChanged);
|
|
96
|
-
item.removeEventListener("focus", this.handleItemFocus);
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
this.setItems = () => {
|
|
101
|
-
const newItems = this.domChildren();
|
|
102
|
-
this.removeItemListeners();
|
|
103
|
-
this.menuItems = newItems;
|
|
104
|
-
const menuItems = this.menuItems.filter(this.isMenuItemElement);
|
|
105
|
-
// if our focus index is not -1 we have items
|
|
106
|
-
if (menuItems.length) {
|
|
107
|
-
this.focusIndex = 0;
|
|
108
|
-
}
|
|
109
|
-
function elementIndent(el) {
|
|
110
|
-
const role = el.getAttribute("role");
|
|
111
|
-
const startSlot = el.querySelector("[slot=start]");
|
|
112
|
-
if (role !== MenuItemRole.menuitem && startSlot === null) {
|
|
113
|
-
return 1;
|
|
114
|
-
}
|
|
115
|
-
else if (role === MenuItemRole.menuitem && startSlot !== null) {
|
|
116
|
-
return 1;
|
|
117
|
-
}
|
|
118
|
-
else if (role !== MenuItemRole.menuitem && startSlot !== null) {
|
|
119
|
-
return 2;
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
return 0;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
const indent = menuItems.reduce((accum, current) => {
|
|
126
|
-
const elementValue = elementIndent(current);
|
|
127
|
-
return accum > elementValue ? accum : elementValue;
|
|
128
|
-
}, 0);
|
|
129
|
-
menuItems.forEach((item, index) => {
|
|
130
|
-
item.setAttribute("tabindex", index === 0 ? "0" : "-1");
|
|
131
|
-
item.addEventListener("expanded-change", this.handleExpandedChanged);
|
|
132
|
-
item.addEventListener("focus", this.handleItemFocus);
|
|
133
|
-
if (item instanceof MenuItem) {
|
|
134
|
-
item.startColumnCount = indent;
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
};
|
|
138
|
-
/**
|
|
139
|
-
* handle change from child element
|
|
140
|
-
*/
|
|
141
|
-
this.changeHandler = (e) => {
|
|
142
|
-
if (this.menuItems === undefined) {
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
const changedMenuItem = e.target;
|
|
146
|
-
const changeItemIndex = this.menuItems.indexOf(changedMenuItem);
|
|
147
|
-
if (changeItemIndex === -1) {
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
if (changedMenuItem.role === "menuitemradio" &&
|
|
151
|
-
changedMenuItem.checked === true) {
|
|
152
|
-
for (let i = changeItemIndex - 1; i >= 0; --i) {
|
|
153
|
-
const item = this.menuItems[i];
|
|
154
|
-
const role = item.getAttribute("role");
|
|
155
|
-
if (role === MenuItemRole.menuitemradio) {
|
|
156
|
-
item.checked = false;
|
|
157
|
-
}
|
|
158
|
-
if (role === "separator") {
|
|
159
|
-
break;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
const maxIndex = this.menuItems.length - 1;
|
|
163
|
-
for (let i = changeItemIndex + 1; i <= maxIndex; ++i) {
|
|
164
|
-
const item = this.menuItems[i];
|
|
165
|
-
const role = item.getAttribute("role");
|
|
166
|
-
if (role === MenuItemRole.menuitemradio) {
|
|
167
|
-
item.checked = false;
|
|
168
|
-
}
|
|
169
|
-
if (role === "separator") {
|
|
170
|
-
break;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
};
|
|
175
|
-
/**
|
|
176
|
-
* check if the item is a menu item
|
|
177
|
-
*/
|
|
178
|
-
this.isMenuItemElement = (el) => {
|
|
179
|
-
return (isHTMLElement(el) &&
|
|
180
|
-
Menu$1.focusableElementRoles.hasOwnProperty(el.getAttribute("role")));
|
|
181
|
-
};
|
|
182
|
-
/**
|
|
183
|
-
* check if the item is focusable
|
|
184
|
-
*/
|
|
185
|
-
this.isFocusableElement = (el) => {
|
|
186
|
-
return this.isMenuItemElement(el);
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
itemsChanged(oldValue, newValue) {
|
|
190
|
-
// only update children after the component is connected and
|
|
191
|
-
// the setItems has run on connectedCallback
|
|
192
|
-
// (menuItems is undefined until then)
|
|
193
|
-
if (this.$fastController.isConnected && this.menuItems !== undefined) {
|
|
194
|
-
this.setItems();
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* @internal
|
|
199
|
-
*/
|
|
200
|
-
connectedCallback() {
|
|
201
|
-
super.connectedCallback();
|
|
202
|
-
DOM.queueUpdate(() => {
|
|
203
|
-
// wait until children have had a chance to
|
|
204
|
-
// connect before setting/checking their props/attributes
|
|
205
|
-
this.setItems();
|
|
206
|
-
});
|
|
207
|
-
this.addEventListener("change", this.changeHandler);
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* @internal
|
|
211
|
-
*/
|
|
212
|
-
disconnectedCallback() {
|
|
213
|
-
super.disconnectedCallback();
|
|
214
|
-
this.removeItemListeners();
|
|
215
|
-
this.menuItems = undefined;
|
|
216
|
-
this.removeEventListener("change", this.changeHandler);
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Focuses the first item in the menu.
|
|
220
|
-
*
|
|
221
|
-
* @public
|
|
222
|
-
*/
|
|
223
|
-
focus() {
|
|
224
|
-
this.setFocus(0, 1);
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* Collapses any expanded menu items.
|
|
228
|
-
*
|
|
229
|
-
* @public
|
|
230
|
-
*/
|
|
231
|
-
collapseExpandedItem() {
|
|
232
|
-
if (this.expandedItem !== null) {
|
|
233
|
-
this.expandedItem.expanded = false;
|
|
234
|
-
this.expandedItem = null;
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
/**
|
|
238
|
-
* @internal
|
|
239
|
-
*/
|
|
240
|
-
handleMenuKeyDown(e) {
|
|
241
|
-
if (e.defaultPrevented || this.menuItems === undefined) {
|
|
242
|
-
return;
|
|
243
|
-
}
|
|
244
|
-
switch (e.key) {
|
|
245
|
-
case keyArrowDown:
|
|
246
|
-
// go forward one index
|
|
247
|
-
this.setFocus(this.focusIndex + 1, 1);
|
|
248
|
-
return;
|
|
249
|
-
case keyArrowUp:
|
|
250
|
-
// go back one index
|
|
251
|
-
this.setFocus(this.focusIndex - 1, -1);
|
|
252
|
-
return;
|
|
253
|
-
case keyEnd:
|
|
254
|
-
// set focus on last item
|
|
255
|
-
this.setFocus(this.menuItems.length - 1, -1);
|
|
256
|
-
return;
|
|
257
|
-
case keyHome:
|
|
258
|
-
// set focus on first item
|
|
259
|
-
this.setFocus(0, 1);
|
|
260
|
-
return;
|
|
261
|
-
default:
|
|
262
|
-
// if we are not handling the event, do not prevent default
|
|
263
|
-
return true;
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
/**
|
|
267
|
-
* get an array of valid DOM children
|
|
268
|
-
*/
|
|
269
|
-
domChildren() {
|
|
270
|
-
return Array.from(this.children).filter(child => !child.hasAttribute("hidden"));
|
|
271
|
-
}
|
|
272
|
-
setFocus(focusIndex, adjustment) {
|
|
273
|
-
if (this.menuItems === undefined) {
|
|
274
|
-
return;
|
|
275
|
-
}
|
|
276
|
-
while (focusIndex >= 0 && focusIndex < this.menuItems.length) {
|
|
277
|
-
const child = this.menuItems[focusIndex];
|
|
278
|
-
if (this.isFocusableElement(child)) {
|
|
279
|
-
// change the previous index to -1
|
|
280
|
-
if (this.focusIndex > -1 &&
|
|
281
|
-
this.menuItems.length >= this.focusIndex - 1) {
|
|
282
|
-
this.menuItems[this.focusIndex].setAttribute("tabindex", "-1");
|
|
283
|
-
}
|
|
284
|
-
// update the focus index
|
|
285
|
-
this.focusIndex = focusIndex;
|
|
286
|
-
// update the tabindex of next focusable element
|
|
287
|
-
child.setAttribute("tabindex", "0");
|
|
288
|
-
// focus the element
|
|
289
|
-
child.focus();
|
|
290
|
-
break;
|
|
291
|
-
}
|
|
292
|
-
focusIndex += adjustment;
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
Menu$1.focusableElementRoles = roleForMenuItem;
|
|
297
|
-
__decorate([
|
|
298
|
-
observable
|
|
299
|
-
], Menu$1.prototype, "items", void 0);
|
|
300
|
-
|
|
301
|
-
var css_248z = ".base {\n max-inline-size: var(--menu-max-inline-size, 100%);\n min-inline-size: var(--menu-max-inline-size);\n padding-block: 8px;\n}";
|
|
302
|
-
|
|
303
|
-
class Menu extends Menu$1 {
|
|
304
|
-
constructor() {
|
|
305
|
-
super(...arguments);
|
|
306
|
-
this.open = false;
|
|
307
|
-
this.popupOpenChanged = () => {
|
|
308
|
-
this.open = this._popup.open;
|
|
309
|
-
};
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
__decorate([attr({
|
|
313
|
-
mode: 'boolean'
|
|
314
|
-
}), __metadata("design:type", Object)], Menu.prototype, "open", void 0);
|
|
315
|
-
__decorate([attr, __metadata("design:type", String)], Menu.prototype, "placement", void 0);
|
|
316
|
-
__decorate([attr, __metadata("design:type", String)], Menu.prototype, "anchor", void 0);
|
|
317
|
-
|
|
318
|
-
let _ = t => t,
|
|
319
|
-
_t;
|
|
320
|
-
const MenuTemplate = context => {
|
|
321
|
-
const popupTag = context.tagFor(Popup);
|
|
322
|
-
return html(_t || (_t = _`
|
|
323
|
-
<template
|
|
324
|
-
slot="${0}"
|
|
325
|
-
>
|
|
326
|
-
<${0}
|
|
327
|
-
:placement=${0}
|
|
328
|
-
:open=${0}
|
|
329
|
-
:anchor=${0}
|
|
330
|
-
@open="${0}"
|
|
331
|
-
@close="${0}"
|
|
332
|
-
${0}
|
|
333
|
-
>
|
|
334
|
-
<div
|
|
335
|
-
class="base"
|
|
336
|
-
role="menu"
|
|
337
|
-
@keydown="${0}"
|
|
338
|
-
@focusout="${0}"
|
|
339
|
-
>
|
|
340
|
-
<slot ${0}></slot>
|
|
341
|
-
</div>
|
|
342
|
-
</${0}>
|
|
343
|
-
</template>`), x => x.slot || x.isNestedMenu() ? 'submenu' : void 0, popupTag, x => x.placement, x => x.open, x => x.anchor, x => x.popupOpenChanged(), x => x.popupOpenChanged(), ref('_popup'), (x, c) => x.handleMenuKeyDown(c.event), (x, c) => x.handleFocusOut(c.event), slotted('items'), popupTag);
|
|
344
|
-
};
|
|
345
|
-
|
|
346
|
-
const prefix = getPrefix(import.meta.url);
|
|
347
|
-
const vividMenu = Menu.compose({
|
|
348
|
-
baseName: 'menu',
|
|
349
|
-
template: MenuTemplate,
|
|
350
|
-
styles: css_248z
|
|
351
|
-
});
|
|
352
|
-
(async () => {
|
|
353
|
-
await loadComponentsModules(['popup', 'menu-item'], prefix);
|
|
354
|
-
designSystem.withPrefix(prefix).register(vividMenu());
|
|
355
|
-
})();
|
|
356
|
-
|
|
357
|
-
export { vividMenu };
|
|
30
|
+
registerMenu();
|
package/menu-item/index.js
CHANGED
|
@@ -1,90 +1,20 @@
|
|
|
1
|
-
import '../shared/
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { b as AffixIcon, a as affixIconTemplateFactory } from '../shared/affix.js';
|
|
5
|
-
import { M as MenuItem$1, a as MenuItemRole } from '../shared/menu-item.js';
|
|
6
|
-
import { a as applyMixins } from '../shared/apply-mixins.js';
|
|
7
|
-
import { f as focusTemplateFactory } from '../shared/focus.js';
|
|
8
|
-
import { w as when } from '../shared/when.js';
|
|
9
|
-
import { c as classNames } from '../shared/class-names.js';
|
|
1
|
+
import { b as registerMenuItem } from '../shared/definition25.js';
|
|
2
|
+
import '../shared/index.js';
|
|
3
|
+
import '../shared/definition3.js';
|
|
10
4
|
import '../shared/icon.js';
|
|
5
|
+
import '../shared/to-string.js';
|
|
11
6
|
import '../shared/string-trim.js';
|
|
12
7
|
import '../shared/_has.js';
|
|
8
|
+
import '../shared/when.js';
|
|
9
|
+
import '../shared/class-names.js';
|
|
10
|
+
import '../shared/definition4.js';
|
|
11
|
+
import '../shared/focus.js';
|
|
12
|
+
import '../shared/affix.js';
|
|
13
13
|
import '../shared/start-end.js';
|
|
14
14
|
import '../shared/ref.js';
|
|
15
15
|
import '../shared/direction.js';
|
|
16
|
+
import '../shared/apply-mixins.js';
|
|
16
17
|
import '../shared/key-codes.js';
|
|
17
18
|
import '../shared/focus2.js';
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
class MenuItem extends MenuItem$1 {}
|
|
22
|
-
__decorate([attr, __metadata("design:type", String)], MenuItem.prototype, "text", void 0);
|
|
23
|
-
applyMixins(MenuItem, AffixIcon);
|
|
24
|
-
|
|
25
|
-
let _ = t => t,
|
|
26
|
-
_t,
|
|
27
|
-
_t2,
|
|
28
|
-
_t3,
|
|
29
|
-
_t4,
|
|
30
|
-
_t5;
|
|
31
|
-
const getClasses = ({
|
|
32
|
-
disabled,
|
|
33
|
-
checked,
|
|
34
|
-
expanded,
|
|
35
|
-
role
|
|
36
|
-
}) => classNames('base', ['disabled', Boolean(disabled)], ['selected', role !== MenuItemRole.menuitem && Boolean(checked)], ['expanded', Boolean(expanded)], ['item-checkbox', role === MenuItemRole.menuitemcheckbox], ['item-radio', role === MenuItemRole.menuitemradio]);
|
|
37
|
-
const MenuItemTemplate = (context, definition) => {
|
|
38
|
-
const affixIconTemplate = affixIconTemplateFactory(context);
|
|
39
|
-
const focusTemplate = focusTemplateFactory(context);
|
|
40
|
-
return html(_t || (_t = _`
|
|
41
|
-
<template
|
|
42
|
-
aria-checked="${0}"
|
|
43
|
-
aria-disabled="${0}"
|
|
44
|
-
aria-expanded="${0}"
|
|
45
|
-
@keydown="${0}"
|
|
46
|
-
@click="${0}"
|
|
47
|
-
@mouseover="${0}"
|
|
48
|
-
@mouseout="${0}"
|
|
49
|
-
>
|
|
50
|
-
<div class="${0}">
|
|
51
|
-
|
|
52
|
-
${0}
|
|
53
|
-
${0}
|
|
54
|
-
|
|
55
|
-
${0}
|
|
56
|
-
|
|
57
|
-
${0}
|
|
58
|
-
|
|
59
|
-
${0}
|
|
60
|
-
|
|
61
|
-
<span class="text">
|
|
62
|
-
${0}
|
|
63
|
-
</span>
|
|
64
|
-
</div>
|
|
65
|
-
</template>
|
|
66
|
-
`), x => x.role !== MenuItemRole.menuitem ? x.checked : void 0, x => x.disabled, x => x.expanded, (x, c) => x.handleMenuItemKeyDown(c.event), (x, c) => x.handleMenuItemClick(c.event), (x, c) => x.handleMouseOver(c.event), (x, c) => x.handleMouseOut(c.event), getClasses, when(x => x.hasSubmenu, html(_t2 || (_t2 = _`
|
|
67
|
-
<div
|
|
68
|
-
class="expand-collapse-glyph-container"
|
|
69
|
-
>
|
|
70
|
-
<span class="expand-collapse">
|
|
71
|
-
<slot name="expand-collapse-indicator">
|
|
72
|
-
${0}
|
|
73
|
-
</slot>
|
|
74
|
-
</span>
|
|
75
|
-
</div>
|
|
76
|
-
`), definition.expandCollapseGlyph || '')), () => focusTemplate, when(x => x.role === MenuItemRole.menuitemcheckbox, html(_t3 || (_t3 = _`${0}`), x => affixIconTemplate(x.checked ? 'checkbox-checked-line' : 'checkbox-unchecked-line'))), when(x => x.role === MenuItemRole.menuitemradio, html(_t4 || (_t4 = _`${0}`), x => affixIconTemplate(x.checked ? 'radio-checked-line' : 'radio-unchecked-line'))), when(x => x.role === MenuItemRole.menuitem && x.icon, html(_t5 || (_t5 = _`${0}`), x => affixIconTemplate(x.icon))), x => x.text);
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
const prefix = getPrefix(import.meta.url);
|
|
80
|
-
const vividMenuItem = MenuItem.compose({
|
|
81
|
-
baseName: 'menu-item',
|
|
82
|
-
template: MenuItemTemplate,
|
|
83
|
-
styles: css_248z
|
|
84
|
-
});
|
|
85
|
-
(async () => {
|
|
86
|
-
await loadComponentsModules(['icon', 'focus'], prefix);
|
|
87
|
-
designSystem.withPrefix(prefix).register(vividMenuItem());
|
|
88
|
-
})();
|
|
89
|
-
|
|
90
|
-
export { vividMenuItem };
|
|
20
|
+
registerMenuItem();
|
package/nav/index.js
CHANGED
|
@@ -1,17 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { r as registerNav } from '../shared/definition26.js';
|
|
2
|
+
import '../shared/index.js';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
let _ = t => t,
|
|
6
|
-
_t;
|
|
7
|
-
const NavTemplate = () => html(_t || (_t = _`
|
|
8
|
-
<nav><slot></slot></nav>
|
|
9
|
-
`));
|
|
10
|
-
|
|
11
|
-
const vividNav = Nav.compose({
|
|
12
|
-
baseName: 'nav',
|
|
13
|
-
template: NavTemplate
|
|
14
|
-
});
|
|
15
|
-
designSystem.withPrefix(getPrefix(import.meta.url)).register(vividNav());
|
|
16
|
-
|
|
17
|
-
export { vividNav };
|
|
4
|
+
registerNav();
|
package/nav-disclosure/index.js
CHANGED
|
@@ -1,81 +1,17 @@
|
|
|
1
|
-
import '../shared/
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { I as Icon } from '../shared/icon.js';
|
|
7
|
-
import { f as focusTemplateFactory } from '../shared/focus.js';
|
|
8
|
-
import { w as when } from '../shared/when.js';
|
|
9
|
-
import { r as ref } from '../shared/ref.js';
|
|
1
|
+
import { r as registerNavDisclosure } from '../shared/definition27.js';
|
|
2
|
+
import '../shared/index.js';
|
|
3
|
+
import '../shared/definition3.js';
|
|
4
|
+
import '../shared/icon.js';
|
|
5
|
+
import '../shared/to-string.js';
|
|
10
6
|
import '../shared/string-trim.js';
|
|
11
7
|
import '../shared/_has.js';
|
|
8
|
+
import '../shared/when.js';
|
|
9
|
+
import '../shared/class-names.js';
|
|
10
|
+
import '../shared/definition4.js';
|
|
11
|
+
import '../shared/focus.js';
|
|
12
|
+
import '../shared/affix.js';
|
|
13
|
+
import '../shared/apply-mixins.js';
|
|
12
14
|
import '../shared/focus2.js';
|
|
15
|
+
import '../shared/ref.js';
|
|
13
16
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var _NavDisclosure_onToggle;
|
|
17
|
-
class NavDisclosure extends FoundationElement {
|
|
18
|
-
constructor() {
|
|
19
|
-
super(...arguments);
|
|
20
|
-
this.open = false;
|
|
21
|
-
_NavDisclosure_onToggle.set(this, () => {
|
|
22
|
-
this.open = this.details.open;
|
|
23
|
-
this.$emit('toggle');
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
connectedCallback() {
|
|
27
|
-
super.connectedCallback();
|
|
28
|
-
this.details.addEventListener('toggle', __classPrivateFieldGet(this, _NavDisclosure_onToggle, "f"));
|
|
29
|
-
this.details.open = this.open;
|
|
30
|
-
}
|
|
31
|
-
disconnectedCallback() {
|
|
32
|
-
super.disconnectedCallback();
|
|
33
|
-
this.details.removeEventListener('toggle', __classPrivateFieldGet(this, _NavDisclosure_onToggle, "f"));
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
_NavDisclosure_onToggle = new WeakMap();
|
|
37
|
-
__decorate([attr, __metadata("design:type", String)], NavDisclosure.prototype, "label", void 0);
|
|
38
|
-
__decorate([attr({
|
|
39
|
-
mode: 'boolean'
|
|
40
|
-
}), __metadata("design:type", Object)], NavDisclosure.prototype, "open", void 0);
|
|
41
|
-
applyMixins(NavDisclosure, AffixIcon);
|
|
42
|
-
|
|
43
|
-
let _ = t => t,
|
|
44
|
-
_t,
|
|
45
|
-
_t2,
|
|
46
|
-
_t3;
|
|
47
|
-
const NavDisclosureTemplate = context => {
|
|
48
|
-
const affixIconTemplate = affixIconTemplateFactory(context);
|
|
49
|
-
const focusTemplate = focusTemplateFactory(context);
|
|
50
|
-
const iconTag = context.tagFor(Icon);
|
|
51
|
-
return html(_t || (_t = _`<details class="base" ${0} ?open=${0}>
|
|
52
|
-
<summary class="control"
|
|
53
|
-
role="button"
|
|
54
|
-
aria-controls="disclosure-content"
|
|
55
|
-
aria-expanded="${0}"
|
|
56
|
-
>
|
|
57
|
-
${0}
|
|
58
|
-
${0}
|
|
59
|
-
${0}
|
|
60
|
-
${0}
|
|
61
|
-
${0}
|
|
62
|
-
</summary>
|
|
63
|
-
<div class="content" id="disclosure-content">
|
|
64
|
-
<slot></slot>
|
|
65
|
-
</div>
|
|
66
|
-
</details>
|
|
67
|
-
`), ref('details'), x => x.open, x => x.open, x => affixIconTemplate(x.icon), x => x.label, when(x => x.open, html(_t2 || (_t2 = _`<${0} class="toggleIcon" name='chevron-up-solid'></${0}>`), iconTag, iconTag)), when(x => !x.open, html(_t3 || (_t3 = _`<${0} class="toggleIcon" name='chevron-down-solid'></${0}>`), iconTag, iconTag)), () => focusTemplate);
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const prefix = getPrefix(import.meta.url);
|
|
71
|
-
const vividNavDisclosure = NavDisclosure.compose({
|
|
72
|
-
baseName: 'nav-disclosure',
|
|
73
|
-
template: NavDisclosureTemplate,
|
|
74
|
-
styles: css_248z
|
|
75
|
-
});
|
|
76
|
-
(async () => {
|
|
77
|
-
await loadComponentsModules(['icon', 'focus'], prefix);
|
|
78
|
-
designSystem.withPrefix(prefix).register(vividNavDisclosure());
|
|
79
|
-
})();
|
|
80
|
-
|
|
81
|
-
export { vividNavDisclosure };
|
|
17
|
+
registerNavDisclosure();
|
package/nav-item/index.js
CHANGED
|
@@ -1,44 +1,22 @@
|
|
|
1
|
-
import '../shared/
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { b as AffixIcon } from '../shared/affix.js';
|
|
5
|
-
import { T as TextAnchor } from '../shared/text-anchor.js';
|
|
6
|
-
import { a as applyMixins } from '../shared/apply-mixins.js';
|
|
7
|
-
import { t as textAnchorTemplate } from '../shared/text-anchor.template.js';
|
|
1
|
+
import { r as registerNavItem } from '../shared/definition28.js';
|
|
2
|
+
import '../shared/index.js';
|
|
3
|
+
import '../shared/definition3.js';
|
|
8
4
|
import '../shared/icon.js';
|
|
5
|
+
import '../shared/to-string.js';
|
|
9
6
|
import '../shared/string-trim.js';
|
|
10
7
|
import '../shared/_has.js';
|
|
8
|
+
import '../shared/when.js';
|
|
9
|
+
import '../shared/class-names.js';
|
|
10
|
+
import '../shared/definition4.js';
|
|
11
|
+
import '../shared/focus.js';
|
|
12
|
+
import '../shared/affix.js';
|
|
13
|
+
import '../shared/text-anchor.js';
|
|
11
14
|
import '../shared/anchor.js';
|
|
15
|
+
import '../shared/apply-mixins.js';
|
|
12
16
|
import '../shared/aria-global.js';
|
|
13
17
|
import '../shared/start-end.js';
|
|
14
18
|
import '../shared/ref.js';
|
|
15
|
-
import '../shared/
|
|
19
|
+
import '../shared/text-anchor.template.js';
|
|
16
20
|
import '../shared/focus2.js';
|
|
17
|
-
import '../shared/class-names.js';
|
|
18
|
-
|
|
19
|
-
var css_248z = "/**\n * Do not edit directly\n * Generated on Wed, 14 Dec 2022 14:20:57 GMT\n */\n.control {\n position: relative;\n display: inline-flex;\n box-sizing: border-box;\n align-items: center;\n background-color: var(--_appearance-color-fill);\n border-radius: 6px;\n box-shadow: inset 0 0 0 1px var(--_appearance-color-outline);\n color: var(--_appearance-color-text);\n font: var(--vvd-typography-base);\n gap: 12px;\n hyphens: auto;\n inline-size: 100%;\n min-block-size: calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2)));\n text-decoration: none;\n vertical-align: middle;\n word-break: break-word;\n}\n.control {\n --_appearance-color-text: var(--_connotation-color-primary);\n --_appearance-color-fill: transparent;\n --_appearance-color-outline: transparent;\n}\n.control:where(:hover, .hover):where(:not(:disabled, .disabled, .readonly)) {\n --_appearance-color-text: var(--_connotation-color-primary);\n --_appearance-color-fill: var(--_connotation-color-faint);\n --_appearance-color-outline: transparent;\n}\n.control:where(:active, .active):where(:not(:disabled, .disabled)) {\n --_appearance-color-text: var(--_connotation-color-primary);\n --_appearance-color-fill: var(--_connotation-color-soft);\n --_appearance-color-outline: transparent;\n}\n.control:where(.selected, [aria-current]):where(:not(:disabled, .disabled, :hover, .hover)) {\n --_appearance-color-text: var(--_connotation-color-primary-text);\n --_appearance-color-fill: var(--_connotation-color-primary);\n --_appearance-color-outline: transparent;\n}\n.control:where(.selected, [aria-current]):where(:hover, .hover) {\n --_appearance-color-text: var(--_connotation-color-primary-text);\n --_appearance-color-fill: var(--_connotation-color-primary-increment);\n --_appearance-color-outline: transparent;\n}\n.control {\n --_connotation-color-primary: var(--vvd-color-canvas-text);\n --_connotation-color-primary-text: var(--vvd-color-canvas);\n --_connotation-color-primary-increment: var(--vvd-color-neutral-800);\n --_connotation-color-faint: var(--vvd-color-neutral-50);\n --_connotation-color-soft: var(--vvd-color-neutral-100);\n}\n@supports selector(:focus-visible) {\n .control:focus {\n outline: none;\n }\n}\n.control.icon-only {\n display: flex;\n block-size: calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2)));\n inline-size: calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2)));\n place-content: center;\n}\n.control:not(.icon-only) {\n padding-inline: 16px;\n}\n\n.control:not(:focus-visible) .focus-indicator {\n display: none;\n}\n\n.icon {\n font-size: 20px;\n}\n.control:not(.icon-only) .icon {\n color: var(--vvd-color-neutral-600);\n}";
|
|
20
|
-
|
|
21
|
-
class NavItem extends TextAnchor {}
|
|
22
|
-
applyMixins(NavItem, AffixIcon);
|
|
23
|
-
|
|
24
|
-
let _ = t => t,
|
|
25
|
-
_t;
|
|
26
|
-
const NavItemTemplate = (context, definition) => html(_t || (_t = _`
|
|
27
|
-
${0}
|
|
28
|
-
`), textAnchorTemplate(context));
|
|
29
|
-
|
|
30
|
-
const prefix = getPrefix(import.meta.url);
|
|
31
|
-
const vividNavItem = NavItem.compose({
|
|
32
|
-
baseName: 'nav-item',
|
|
33
|
-
template: NavItemTemplate,
|
|
34
|
-
styles: css_248z,
|
|
35
|
-
shadowOptions: {
|
|
36
|
-
delegatesFocus: true
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
(async () => {
|
|
40
|
-
await loadComponentsModules(['icon', 'focus'], prefix);
|
|
41
|
-
designSystem.withPrefix(prefix).register(vividNavItem());
|
|
42
|
-
})();
|
|
43
21
|
|
|
44
|
-
|
|
22
|
+
registerNavItem();
|