@vonage/vivid 3.37.0 → 3.39.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/accordion/index.js +2 -2
- package/accordion-item/index.js +2 -2
- package/alert/index.js +4 -4
- package/avatar/index.js +1 -1
- package/badge/index.js +1 -1
- package/banner/index.js +3 -3
- package/breadcrumb-item/index.js +2 -2
- package/button/index.js +3 -3
- package/card/index.js +2 -2
- package/checkbox/index.js +2 -2
- package/combobox/index.js +6 -6
- package/custom-elements.json +4199 -3875
- package/data-grid/index.js +1 -1
- package/date-picker/index.js +9 -7
- package/date-range-picker/index.js +36 -0
- package/dialog/index.js +5 -5
- package/divider/index.js +1 -1
- package/elevation/index.js +1 -1
- package/empty-state/index.js +2 -2
- package/fab/index.js +3 -3
- package/file-picker/index.js +5 -4
- package/focus/index.js +1 -1
- package/header/index.js +2 -2
- package/icon/index.js +1 -1
- package/index.js +43 -40
- package/layout/index.js +1 -1
- package/lib/components.d.ts +1 -0
- package/lib/date-picker/date-picker.d.ts +4 -14
- package/lib/date-range-picker/date-range-picker.d.ts +15 -0
- package/lib/date-range-picker/definition.d.ts +3 -0
- package/lib/file-picker/file-picker.d.ts +8 -5
- package/lib/file-picker/file-picker.form-associated.d.ts +10 -0
- package/lib/file-picker/locale.d.ts +6 -0
- package/lib/menu-item/menu-item.d.ts +6 -0
- package/lib/tag-group/tag-group.d.ts +1 -0
- package/listbox/index.js +4 -4
- package/locales/en-GB.js +27 -3
- package/locales/en-US.js +27 -3
- package/locales/ja-JP.js +25 -1
- package/locales/zh-CN.js +25 -1
- package/menu/index.js +7 -7
- package/menu-item/index.js +3 -3
- package/nav/index.js +1 -1
- package/nav-disclosure/index.js +3 -3
- package/nav-item/index.js +3 -3
- package/note/index.js +2 -2
- package/number-field/index.js +5 -5
- package/option/index.js +3 -3
- package/package.json +1 -1
- package/pagination/index.js +4 -4
- package/popup/index.js +5 -5
- package/progress/index.js +1 -1
- package/progress-ring/index.js +1 -1
- package/radio/index.js +2 -2
- package/radio-group/index.js +1 -1
- package/select/index.js +7 -7
- package/shared/date-picker/calendar/dateRange.d.ts +5 -0
- package/shared/date-picker/calendar/presentationDateRange.d.ts +5 -0
- package/shared/date-picker/date-picker-base.d.ts +19 -0
- package/shared/date-picker/date-picker-base.form-associated.d.ts +10 -0
- package/shared/date-picker/date-picker-base.template.d.ts +4 -0
- package/{lib → shared}/date-picker/locale.d.ts +6 -0
- package/shared/definition.js +4 -4
- package/shared/definition10.js +9 -14
- package/shared/definition11.js +1 -1
- package/shared/definition12.js +1 -1
- package/shared/definition13.js +3 -3
- package/shared/definition14.js +3 -3
- package/shared/definition15.js +5 -5
- package/shared/definition16.js +3 -3
- package/shared/definition17.js +44 -6055
- package/shared/definition18.js +353 -213
- package/shared/definition19.js +251 -67
- package/shared/definition2.js +1 -1
- package/shared/definition20.js +66 -58
- package/shared/definition21.js +43 -84
- package/shared/definition22.js +75 -2298
- package/shared/definition23.js +2361 -45
- package/shared/definition24.js +63 -27
- package/shared/definition25.js +24 -51
- package/shared/definition26.js +36 -805
- package/shared/definition27.js +828 -49
- package/shared/definition28.js +52 -89
- package/shared/definition29.js +88 -24
- package/shared/definition3.js +1 -1
- package/shared/definition30.js +25 -12
- package/shared/definition31.js +12 -53
- package/shared/definition32.js +28 -487
- package/shared/definition33.js +427 -197
- package/shared/definition34.js +260 -174
- package/shared/definition35.js +187 -69
- package/shared/definition36.js +68 -55
- package/shared/definition37.js +61 -421
- package/shared/definition38.js +435 -35
- package/shared/definition39.js +30 -679
- package/shared/definition4.js +3 -3
- package/shared/definition40.js +661 -77
- package/shared/definition41.js +77 -557
- package/shared/definition42.js +559 -106
- package/shared/definition43.js +105 -136
- package/shared/definition44.js +153 -17
- package/shared/definition45.js +16 -79
- package/shared/definition46.js +53 -475
- package/shared/definition47.js +506 -20
- package/shared/definition48.js +22 -121
- package/shared/definition49.js +115 -262
- package/shared/definition5.js +2 -2
- package/shared/definition50.js +248 -120
- package/shared/definition51.js +139 -123
- package/shared/definition52.js +84 -74
- package/shared/definition53.js +114 -69
- package/shared/definition54.js +81 -292
- package/shared/definition55.js +302 -13
- package/shared/definition56.js +11 -41
- package/shared/definition57.js +20 -154
- package/shared/definition58.js +181 -0
- package/shared/definition6.js +2 -2
- package/shared/definition7.js +2 -2
- package/shared/definition8.js +3 -3
- package/shared/index2.js +1 -1
- package/shared/listbox.js +1 -1
- package/shared/localization/Locale.d.ts +3 -1
- package/shared/localized.js +9 -0
- package/shared/presentationDate.js +6133 -0
- package/shared/text-anchor.template.js +4 -4
- package/shared/text-field.js +1 -1
- package/side-drawer/index.js +1 -1
- package/slider/index.js +2 -2
- package/split-button/index.js +3 -3
- package/style.css +246 -183
- 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/styles/tokens/vivid-2-compat.css +1 -1
- package/switch/index.js +3 -3
- package/tab/index.js +3 -3
- package/tab-panel/index.js +1 -1
- package/tabs/index.js +5 -5
- package/tag/index.js +3 -3
- package/tag-group/index.js +1 -1
- package/text-area/index.js +3 -3
- package/text-field/index.js +3 -3
- package/toggletip/index.js +6 -6
- package/tooltip/index.js +6 -6
- package/tree-item/index.js +3 -3
- package/tree-view/index.js +1 -1
- package/vivid.api.json +105 -0
- package/lib/date-picker/date-picker.form-associated.d.ts +0 -11
- package/lib/date-picker/date-picker.template.d.ts +0 -4
- /package/{lib → shared}/date-picker/calendar/calendarGrid.d.ts +0 -0
- /package/{lib → shared}/date-picker/calendar/dateStr.d.ts +0 -0
- /package/{lib → shared}/date-picker/calendar/month.d.ts +0 -0
- /package/{lib → shared}/date-picker/calendar/monthPickerGrid.d.ts +0 -0
- /package/{lib → shared}/date-picker/calendar/presentationDate.d.ts +0 -0
- /package/{lib → shared}/date-picker/calendar/year.d.ts +0 -0
package/shared/definition26.js
CHANGED
|
@@ -1,639 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as iconRegistries } from './definition24.js';
|
|
3
|
-
import { f as focusRegistries } from './definition55.js';
|
|
4
|
-
import { A as AffixIcon, a as affixIconTemplateFactory } from './affix.js';
|
|
5
|
-
import { a as applyMixins } from './apply-mixins.js';
|
|
6
|
-
import { S as StartEnd } from './start-end.js';
|
|
7
|
-
import { D as Direction, g as getDirection } from './direction.js';
|
|
8
|
-
import { i as keyArrowLeft, h as keyArrowRight, a as keySpace, k as keyEnter, c as keyHome, b as keyEnd, e as keyArrowUp, d as keyArrowDown } from './key-codes.js';
|
|
9
|
-
import { I as Icon } from './icon.js';
|
|
10
|
-
import { i as isHTMLElement } from './dom.js';
|
|
11
|
-
import { f as focusTemplateFactory } from './focus2.js';
|
|
12
|
-
import { s as slotted, e as elements } from './slotted.js';
|
|
13
|
-
import { w as when } from './when.js';
|
|
1
|
+
import { a as attr, F as FoundationElement, h as html, r as registerFactory } from './index.js';
|
|
14
2
|
import { c as classNames } from './class-names.js';
|
|
15
3
|
|
|
16
|
-
/**
|
|
17
|
-
* Menu items roles.
|
|
18
|
-
* @public
|
|
19
|
-
*/
|
|
20
|
-
const MenuItemRole$1 = {
|
|
21
|
-
/**
|
|
22
|
-
* The menu item has a "menuitem" role
|
|
23
|
-
*/
|
|
24
|
-
menuitem: "menuitem",
|
|
25
|
-
/**
|
|
26
|
-
* The menu item has a "menuitemcheckbox" role
|
|
27
|
-
*/
|
|
28
|
-
menuitemcheckbox: "menuitemcheckbox",
|
|
29
|
-
/**
|
|
30
|
-
* The menu item has a "menuitemradio" role
|
|
31
|
-
*/
|
|
32
|
-
menuitemradio: "menuitemradio",
|
|
33
|
-
};
|
|
34
|
-
/**
|
|
35
|
-
* @internal
|
|
36
|
-
*/
|
|
37
|
-
const roleForMenuItem = {
|
|
38
|
-
[MenuItemRole$1.menuitem]: "menuitem",
|
|
39
|
-
[MenuItemRole$1.menuitemcheckbox]: "menuitemcheckbox",
|
|
40
|
-
[MenuItemRole$1.menuitemradio]: "menuitemradio",
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* A Switch Custom HTML Element.
|
|
45
|
-
* Implements {@link https://www.w3.org/TR/wai-aria-1.1/#menuitem | ARIA menuitem }, {@link https://www.w3.org/TR/wai-aria-1.1/#menuitemcheckbox | ARIA menuitemcheckbox}, or {@link https://www.w3.org/TR/wai-aria-1.1/#menuitemradio | ARIA menuitemradio }.
|
|
46
|
-
*
|
|
47
|
-
* @slot checked-indicator - The checked indicator
|
|
48
|
-
* @slot radio-indicator - The radio indicator
|
|
49
|
-
* @slot start - Content which can be provided before the menu item content
|
|
50
|
-
* @slot end - Content which can be provided after the menu item content
|
|
51
|
-
* @slot - The default slot for menu item content
|
|
52
|
-
* @slot expand-collapse-indicator - The expand/collapse indicator
|
|
53
|
-
* @slot submenu - Used to nest menu's within menu items
|
|
54
|
-
* @csspart input-container - The element representing the visual checked or radio indicator
|
|
55
|
-
* @csspart checkbox - The element wrapping the `menuitemcheckbox` indicator
|
|
56
|
-
* @csspart radio - The element wrapping the `menuitemradio` indicator
|
|
57
|
-
* @csspart content - The element wrapping the menu item content
|
|
58
|
-
* @csspart expand-collapse-glyph-container - The element wrapping the expand collapse element
|
|
59
|
-
* @csspart expand-collapse - The expand/collapse element
|
|
60
|
-
* @csspart submenu-region - The container for the submenu, used for positioning
|
|
61
|
-
* @fires expanded-change - Fires a custom 'expanded-change' event when the expanded state changes
|
|
62
|
-
* @fires change - Fires a custom 'change' event when a non-submenu item with a role of `menuitemcheckbox`, `menuitemradio`, or `menuitem` is invoked
|
|
63
|
-
*
|
|
64
|
-
* @public
|
|
65
|
-
*/
|
|
66
|
-
let MenuItem$1 = class MenuItem extends FoundationElement {
|
|
67
|
-
constructor() {
|
|
68
|
-
super(...arguments);
|
|
69
|
-
/**
|
|
70
|
-
* The role of the element.
|
|
71
|
-
*
|
|
72
|
-
* @public
|
|
73
|
-
* @remarks
|
|
74
|
-
* HTML Attribute: role
|
|
75
|
-
*/
|
|
76
|
-
this.role = MenuItemRole$1.menuitem;
|
|
77
|
-
/**
|
|
78
|
-
* @internal
|
|
79
|
-
*/
|
|
80
|
-
this.hasSubmenu = false;
|
|
81
|
-
/**
|
|
82
|
-
* Track current direction to pass to the anchored region
|
|
83
|
-
*
|
|
84
|
-
* @internal
|
|
85
|
-
*/
|
|
86
|
-
this.currentDirection = Direction.ltr;
|
|
87
|
-
this.focusSubmenuOnLoad = false;
|
|
88
|
-
/**
|
|
89
|
-
* @internal
|
|
90
|
-
*/
|
|
91
|
-
this.handleMenuItemKeyDown = (e) => {
|
|
92
|
-
if (e.defaultPrevented) {
|
|
93
|
-
return false;
|
|
94
|
-
}
|
|
95
|
-
switch (e.key) {
|
|
96
|
-
case keyEnter:
|
|
97
|
-
case keySpace:
|
|
98
|
-
this.invoke();
|
|
99
|
-
return false;
|
|
100
|
-
case keyArrowRight:
|
|
101
|
-
//open/focus on submenu
|
|
102
|
-
this.expandAndFocus();
|
|
103
|
-
return false;
|
|
104
|
-
case keyArrowLeft:
|
|
105
|
-
//close submenu
|
|
106
|
-
if (this.expanded) {
|
|
107
|
-
this.expanded = false;
|
|
108
|
-
this.focus();
|
|
109
|
-
return false;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
return true;
|
|
113
|
-
};
|
|
114
|
-
/**
|
|
115
|
-
* @internal
|
|
116
|
-
*/
|
|
117
|
-
this.handleMenuItemClick = (e) => {
|
|
118
|
-
if (e.defaultPrevented || this.disabled) {
|
|
119
|
-
return false;
|
|
120
|
-
}
|
|
121
|
-
this.invoke();
|
|
122
|
-
return false;
|
|
123
|
-
};
|
|
124
|
-
/**
|
|
125
|
-
* @internal
|
|
126
|
-
*/
|
|
127
|
-
this.submenuLoaded = () => {
|
|
128
|
-
if (!this.focusSubmenuOnLoad) {
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
this.focusSubmenuOnLoad = false;
|
|
132
|
-
if (this.hasSubmenu) {
|
|
133
|
-
this.submenu.focus();
|
|
134
|
-
this.setAttribute("tabindex", "-1");
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
/**
|
|
138
|
-
* @internal
|
|
139
|
-
*/
|
|
140
|
-
this.handleMouseOver = (e) => {
|
|
141
|
-
if (this.disabled || !this.hasSubmenu || this.expanded) {
|
|
142
|
-
return false;
|
|
143
|
-
}
|
|
144
|
-
this.expanded = true;
|
|
145
|
-
return false;
|
|
146
|
-
};
|
|
147
|
-
/**
|
|
148
|
-
* @internal
|
|
149
|
-
*/
|
|
150
|
-
this.handleMouseOut = (e) => {
|
|
151
|
-
if (!this.expanded || this.contains(document.activeElement)) {
|
|
152
|
-
return false;
|
|
153
|
-
}
|
|
154
|
-
this.expanded = false;
|
|
155
|
-
return false;
|
|
156
|
-
};
|
|
157
|
-
/**
|
|
158
|
-
* @internal
|
|
159
|
-
*/
|
|
160
|
-
this.expandAndFocus = () => {
|
|
161
|
-
if (!this.hasSubmenu) {
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
this.focusSubmenuOnLoad = true;
|
|
165
|
-
this.expanded = true;
|
|
166
|
-
};
|
|
167
|
-
/**
|
|
168
|
-
* @internal
|
|
169
|
-
*/
|
|
170
|
-
this.invoke = () => {
|
|
171
|
-
if (this.disabled) {
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
switch (this.role) {
|
|
175
|
-
case MenuItemRole$1.menuitemcheckbox:
|
|
176
|
-
this.checked = !this.checked;
|
|
177
|
-
break;
|
|
178
|
-
case MenuItemRole$1.menuitem:
|
|
179
|
-
// update submenu
|
|
180
|
-
this.updateSubmenu();
|
|
181
|
-
if (this.hasSubmenu) {
|
|
182
|
-
this.expandAndFocus();
|
|
183
|
-
}
|
|
184
|
-
else {
|
|
185
|
-
this.$emit("change");
|
|
186
|
-
}
|
|
187
|
-
break;
|
|
188
|
-
case MenuItemRole$1.menuitemradio:
|
|
189
|
-
if (!this.checked) {
|
|
190
|
-
this.checked = true;
|
|
191
|
-
}
|
|
192
|
-
break;
|
|
193
|
-
}
|
|
194
|
-
};
|
|
195
|
-
/**
|
|
196
|
-
* Gets the submenu element if any
|
|
197
|
-
*
|
|
198
|
-
* @internal
|
|
199
|
-
*/
|
|
200
|
-
this.updateSubmenu = () => {
|
|
201
|
-
this.submenu = this.domChildren().find((element) => {
|
|
202
|
-
return element.getAttribute("role") === "menu";
|
|
203
|
-
});
|
|
204
|
-
this.hasSubmenu = this.submenu === undefined ? false : true;
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
expandedChanged(oldValue) {
|
|
208
|
-
if (this.$fastController.isConnected) {
|
|
209
|
-
if (this.submenu === undefined) {
|
|
210
|
-
return;
|
|
211
|
-
}
|
|
212
|
-
if (this.expanded === false) {
|
|
213
|
-
this.submenu.collapseExpandedItem();
|
|
214
|
-
}
|
|
215
|
-
else {
|
|
216
|
-
this.currentDirection = getDirection(this);
|
|
217
|
-
}
|
|
218
|
-
this.$emit("expanded-change", this, { bubbles: false });
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
checkedChanged(oldValue, newValue) {
|
|
222
|
-
if (this.$fastController.isConnected) {
|
|
223
|
-
this.$emit("change");
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* @internal
|
|
228
|
-
*/
|
|
229
|
-
connectedCallback() {
|
|
230
|
-
super.connectedCallback();
|
|
231
|
-
DOM.queueUpdate(() => {
|
|
232
|
-
this.updateSubmenu();
|
|
233
|
-
});
|
|
234
|
-
if (!this.startColumnCount) {
|
|
235
|
-
this.startColumnCount = 1;
|
|
236
|
-
}
|
|
237
|
-
this.observer = new MutationObserver(this.updateSubmenu);
|
|
238
|
-
}
|
|
239
|
-
/**
|
|
240
|
-
* @internal
|
|
241
|
-
*/
|
|
242
|
-
disconnectedCallback() {
|
|
243
|
-
super.disconnectedCallback();
|
|
244
|
-
this.submenu = undefined;
|
|
245
|
-
if (this.observer !== undefined) {
|
|
246
|
-
this.observer.disconnect();
|
|
247
|
-
this.observer = undefined;
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
/**
|
|
251
|
-
* get an array of valid DOM children
|
|
252
|
-
*/
|
|
253
|
-
domChildren() {
|
|
254
|
-
return Array.from(this.children).filter(child => !child.hasAttribute("hidden"));
|
|
255
|
-
}
|
|
256
|
-
};
|
|
257
|
-
__decorate([
|
|
258
|
-
attr({ mode: "boolean" })
|
|
259
|
-
], MenuItem$1.prototype, "disabled", void 0);
|
|
260
|
-
__decorate([
|
|
261
|
-
attr({ mode: "boolean" })
|
|
262
|
-
], MenuItem$1.prototype, "expanded", void 0);
|
|
263
|
-
__decorate([
|
|
264
|
-
observable
|
|
265
|
-
], MenuItem$1.prototype, "startColumnCount", void 0);
|
|
266
|
-
__decorate([
|
|
267
|
-
attr
|
|
268
|
-
], MenuItem$1.prototype, "role", void 0);
|
|
269
|
-
__decorate([
|
|
270
|
-
attr({ mode: "boolean" })
|
|
271
|
-
], MenuItem$1.prototype, "checked", void 0);
|
|
272
|
-
__decorate([
|
|
273
|
-
observable
|
|
274
|
-
], MenuItem$1.prototype, "submenuRegion", void 0);
|
|
275
|
-
__decorate([
|
|
276
|
-
observable
|
|
277
|
-
], MenuItem$1.prototype, "hasSubmenu", void 0);
|
|
278
|
-
__decorate([
|
|
279
|
-
observable
|
|
280
|
-
], MenuItem$1.prototype, "currentDirection", void 0);
|
|
281
|
-
__decorate([
|
|
282
|
-
observable
|
|
283
|
-
], MenuItem$1.prototype, "submenu", void 0);
|
|
284
|
-
applyMixins(MenuItem$1, StartEnd);
|
|
285
|
-
|
|
286
|
-
/**
|
|
287
|
-
* A Menu Custom HTML Element.
|
|
288
|
-
* Implements the {@link https://www.w3.org/TR/wai-aria-1.1/#menu | ARIA menu }.
|
|
289
|
-
*
|
|
290
|
-
* @slot - The default slot for the menu items
|
|
291
|
-
*
|
|
292
|
-
* @public
|
|
293
|
-
*/
|
|
294
|
-
let Menu$1 = class Menu extends FoundationElement {
|
|
295
|
-
constructor() {
|
|
296
|
-
super(...arguments);
|
|
297
|
-
this.expandedItem = null;
|
|
298
|
-
/**
|
|
299
|
-
* The index of the focusable element in the items array
|
|
300
|
-
* defaults to -1
|
|
301
|
-
*/
|
|
302
|
-
this.focusIndex = -1;
|
|
303
|
-
/**
|
|
304
|
-
* @internal
|
|
305
|
-
*/
|
|
306
|
-
this.isNestedMenu = () => {
|
|
307
|
-
return (this.parentElement !== null &&
|
|
308
|
-
isHTMLElement(this.parentElement) &&
|
|
309
|
-
this.parentElement.getAttribute("role") === "menuitem");
|
|
310
|
-
};
|
|
311
|
-
/**
|
|
312
|
-
* if focus is moving out of the menu, reset to a stable initial state
|
|
313
|
-
* @internal
|
|
314
|
-
*/
|
|
315
|
-
this.handleFocusOut = (e) => {
|
|
316
|
-
if (!this.contains(e.relatedTarget) && this.menuItems !== undefined) {
|
|
317
|
-
this.collapseExpandedItem();
|
|
318
|
-
// find our first focusable element
|
|
319
|
-
const focusIndex = this.menuItems.findIndex(this.isFocusableElement);
|
|
320
|
-
// set the current focus index's tabindex to -1
|
|
321
|
-
this.menuItems[this.focusIndex].setAttribute("tabindex", "-1");
|
|
322
|
-
// set the first focusable element tabindex to 0
|
|
323
|
-
this.menuItems[focusIndex].setAttribute("tabindex", "0");
|
|
324
|
-
// set the focus index
|
|
325
|
-
this.focusIndex = focusIndex;
|
|
326
|
-
}
|
|
327
|
-
};
|
|
328
|
-
this.handleItemFocus = (e) => {
|
|
329
|
-
const targetItem = e.target;
|
|
330
|
-
if (this.menuItems !== undefined &&
|
|
331
|
-
targetItem !== this.menuItems[this.focusIndex]) {
|
|
332
|
-
this.menuItems[this.focusIndex].setAttribute("tabindex", "-1");
|
|
333
|
-
this.focusIndex = this.menuItems.indexOf(targetItem);
|
|
334
|
-
targetItem.setAttribute("tabindex", "0");
|
|
335
|
-
}
|
|
336
|
-
};
|
|
337
|
-
this.handleExpandedChanged = (e) => {
|
|
338
|
-
if (e.defaultPrevented ||
|
|
339
|
-
e.target === null ||
|
|
340
|
-
this.menuItems === undefined ||
|
|
341
|
-
this.menuItems.indexOf(e.target) < 0) {
|
|
342
|
-
return;
|
|
343
|
-
}
|
|
344
|
-
e.preventDefault();
|
|
345
|
-
const changedItem = e.target;
|
|
346
|
-
// closing an expanded item without opening another
|
|
347
|
-
if (this.expandedItem !== null &&
|
|
348
|
-
changedItem === this.expandedItem &&
|
|
349
|
-
changedItem.expanded === false) {
|
|
350
|
-
this.expandedItem = null;
|
|
351
|
-
return;
|
|
352
|
-
}
|
|
353
|
-
if (changedItem.expanded) {
|
|
354
|
-
if (this.expandedItem !== null && this.expandedItem !== changedItem) {
|
|
355
|
-
this.expandedItem.expanded = false;
|
|
356
|
-
}
|
|
357
|
-
this.menuItems[this.focusIndex].setAttribute("tabindex", "-1");
|
|
358
|
-
this.expandedItem = changedItem;
|
|
359
|
-
this.focusIndex = this.menuItems.indexOf(changedItem);
|
|
360
|
-
changedItem.setAttribute("tabindex", "0");
|
|
361
|
-
}
|
|
362
|
-
};
|
|
363
|
-
this.removeItemListeners = () => {
|
|
364
|
-
if (this.menuItems !== undefined) {
|
|
365
|
-
this.menuItems.forEach((item) => {
|
|
366
|
-
item.removeEventListener("expanded-change", this.handleExpandedChanged);
|
|
367
|
-
item.removeEventListener("focus", this.handleItemFocus);
|
|
368
|
-
});
|
|
369
|
-
}
|
|
370
|
-
};
|
|
371
|
-
this.setItems = () => {
|
|
372
|
-
const newItems = this.domChildren();
|
|
373
|
-
this.removeItemListeners();
|
|
374
|
-
this.menuItems = newItems;
|
|
375
|
-
const menuItems = this.menuItems.filter(this.isMenuItemElement);
|
|
376
|
-
// if our focus index is not -1 we have items
|
|
377
|
-
if (menuItems.length) {
|
|
378
|
-
this.focusIndex = 0;
|
|
379
|
-
}
|
|
380
|
-
function elementIndent(el) {
|
|
381
|
-
const role = el.getAttribute("role");
|
|
382
|
-
const startSlot = el.querySelector("[slot=start]");
|
|
383
|
-
if (role !== MenuItemRole$1.menuitem && startSlot === null) {
|
|
384
|
-
return 1;
|
|
385
|
-
}
|
|
386
|
-
else if (role === MenuItemRole$1.menuitem && startSlot !== null) {
|
|
387
|
-
return 1;
|
|
388
|
-
}
|
|
389
|
-
else if (role !== MenuItemRole$1.menuitem && startSlot !== null) {
|
|
390
|
-
return 2;
|
|
391
|
-
}
|
|
392
|
-
else {
|
|
393
|
-
return 0;
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
const indent = menuItems.reduce((accum, current) => {
|
|
397
|
-
const elementValue = elementIndent(current);
|
|
398
|
-
return accum > elementValue ? accum : elementValue;
|
|
399
|
-
}, 0);
|
|
400
|
-
menuItems.forEach((item, index) => {
|
|
401
|
-
item.setAttribute("tabindex", index === 0 ? "0" : "-1");
|
|
402
|
-
item.addEventListener("expanded-change", this.handleExpandedChanged);
|
|
403
|
-
item.addEventListener("focus", this.handleItemFocus);
|
|
404
|
-
if (item instanceof MenuItem$1) {
|
|
405
|
-
item.startColumnCount = indent;
|
|
406
|
-
}
|
|
407
|
-
});
|
|
408
|
-
};
|
|
409
|
-
/**
|
|
410
|
-
* handle change from child element
|
|
411
|
-
*/
|
|
412
|
-
this.changeHandler = (e) => {
|
|
413
|
-
if (this.menuItems === undefined) {
|
|
414
|
-
return;
|
|
415
|
-
}
|
|
416
|
-
const changedMenuItem = e.target;
|
|
417
|
-
const changeItemIndex = this.menuItems.indexOf(changedMenuItem);
|
|
418
|
-
if (changeItemIndex === -1) {
|
|
419
|
-
return;
|
|
420
|
-
}
|
|
421
|
-
if (changedMenuItem.role === "menuitemradio" &&
|
|
422
|
-
changedMenuItem.checked === true) {
|
|
423
|
-
for (let i = changeItemIndex - 1; i >= 0; --i) {
|
|
424
|
-
const item = this.menuItems[i];
|
|
425
|
-
const role = item.getAttribute("role");
|
|
426
|
-
if (role === MenuItemRole$1.menuitemradio) {
|
|
427
|
-
item.checked = false;
|
|
428
|
-
}
|
|
429
|
-
if (role === "separator") {
|
|
430
|
-
break;
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
const maxIndex = this.menuItems.length - 1;
|
|
434
|
-
for (let i = changeItemIndex + 1; i <= maxIndex; ++i) {
|
|
435
|
-
const item = this.menuItems[i];
|
|
436
|
-
const role = item.getAttribute("role");
|
|
437
|
-
if (role === MenuItemRole$1.menuitemradio) {
|
|
438
|
-
item.checked = false;
|
|
439
|
-
}
|
|
440
|
-
if (role === "separator") {
|
|
441
|
-
break;
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
};
|
|
446
|
-
/**
|
|
447
|
-
* check if the item is a menu item
|
|
448
|
-
*/
|
|
449
|
-
this.isMenuItemElement = (el) => {
|
|
450
|
-
return (isHTMLElement(el) &&
|
|
451
|
-
Menu.focusableElementRoles.hasOwnProperty(el.getAttribute("role")));
|
|
452
|
-
};
|
|
453
|
-
/**
|
|
454
|
-
* check if the item is focusable
|
|
455
|
-
*/
|
|
456
|
-
this.isFocusableElement = (el) => {
|
|
457
|
-
return this.isMenuItemElement(el);
|
|
458
|
-
};
|
|
459
|
-
}
|
|
460
|
-
itemsChanged(oldValue, newValue) {
|
|
461
|
-
// only update children after the component is connected and
|
|
462
|
-
// the setItems has run on connectedCallback
|
|
463
|
-
// (menuItems is undefined until then)
|
|
464
|
-
if (this.$fastController.isConnected && this.menuItems !== undefined) {
|
|
465
|
-
this.setItems();
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
/**
|
|
469
|
-
* @internal
|
|
470
|
-
*/
|
|
471
|
-
connectedCallback() {
|
|
472
|
-
super.connectedCallback();
|
|
473
|
-
DOM.queueUpdate(() => {
|
|
474
|
-
// wait until children have had a chance to
|
|
475
|
-
// connect before setting/checking their props/attributes
|
|
476
|
-
this.setItems();
|
|
477
|
-
});
|
|
478
|
-
this.addEventListener("change", this.changeHandler);
|
|
479
|
-
}
|
|
480
|
-
/**
|
|
481
|
-
* @internal
|
|
482
|
-
*/
|
|
483
|
-
disconnectedCallback() {
|
|
484
|
-
super.disconnectedCallback();
|
|
485
|
-
this.removeItemListeners();
|
|
486
|
-
this.menuItems = undefined;
|
|
487
|
-
this.removeEventListener("change", this.changeHandler);
|
|
488
|
-
}
|
|
489
|
-
/**
|
|
490
|
-
* Focuses the first item in the menu.
|
|
491
|
-
*
|
|
492
|
-
* @public
|
|
493
|
-
*/
|
|
494
|
-
focus() {
|
|
495
|
-
this.setFocus(0, 1);
|
|
496
|
-
}
|
|
497
|
-
/**
|
|
498
|
-
* Collapses any expanded menu items.
|
|
499
|
-
*
|
|
500
|
-
* @public
|
|
501
|
-
*/
|
|
502
|
-
collapseExpandedItem() {
|
|
503
|
-
if (this.expandedItem !== null) {
|
|
504
|
-
this.expandedItem.expanded = false;
|
|
505
|
-
this.expandedItem = null;
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
/**
|
|
509
|
-
* @internal
|
|
510
|
-
*/
|
|
511
|
-
handleMenuKeyDown(e) {
|
|
512
|
-
if (e.defaultPrevented || this.menuItems === undefined) {
|
|
513
|
-
return;
|
|
514
|
-
}
|
|
515
|
-
switch (e.key) {
|
|
516
|
-
case keyArrowDown:
|
|
517
|
-
// go forward one index
|
|
518
|
-
this.setFocus(this.focusIndex + 1, 1);
|
|
519
|
-
return;
|
|
520
|
-
case keyArrowUp:
|
|
521
|
-
// go back one index
|
|
522
|
-
this.setFocus(this.focusIndex - 1, -1);
|
|
523
|
-
return;
|
|
524
|
-
case keyEnd:
|
|
525
|
-
// set focus on last item
|
|
526
|
-
this.setFocus(this.menuItems.length - 1, -1);
|
|
527
|
-
return;
|
|
528
|
-
case keyHome:
|
|
529
|
-
// set focus on first item
|
|
530
|
-
this.setFocus(0, 1);
|
|
531
|
-
return;
|
|
532
|
-
default:
|
|
533
|
-
// if we are not handling the event, do not prevent default
|
|
534
|
-
return true;
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
|
-
/**
|
|
538
|
-
* get an array of valid DOM children
|
|
539
|
-
*/
|
|
540
|
-
domChildren() {
|
|
541
|
-
return Array.from(this.children).filter(child => !child.hasAttribute("hidden"));
|
|
542
|
-
}
|
|
543
|
-
setFocus(focusIndex, adjustment) {
|
|
544
|
-
if (this.menuItems === undefined) {
|
|
545
|
-
return;
|
|
546
|
-
}
|
|
547
|
-
while (focusIndex >= 0 && focusIndex < this.menuItems.length) {
|
|
548
|
-
const child = this.menuItems[focusIndex];
|
|
549
|
-
if (this.isFocusableElement(child)) {
|
|
550
|
-
// change the previous index to -1
|
|
551
|
-
if (this.focusIndex > -1 &&
|
|
552
|
-
this.menuItems.length >= this.focusIndex - 1) {
|
|
553
|
-
this.menuItems[this.focusIndex].setAttribute("tabindex", "-1");
|
|
554
|
-
}
|
|
555
|
-
// update the focus index
|
|
556
|
-
this.focusIndex = focusIndex;
|
|
557
|
-
// update the tabindex of next focusable element
|
|
558
|
-
child.setAttribute("tabindex", "0");
|
|
559
|
-
// focus the element
|
|
560
|
-
child.focus();
|
|
561
|
-
break;
|
|
562
|
-
}
|
|
563
|
-
focusIndex += adjustment;
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
};
|
|
567
|
-
Menu$1.focusableElementRoles = roleForMenuItem;
|
|
568
|
-
__decorate([
|
|
569
|
-
observable
|
|
570
|
-
], Menu$1.prototype, "items", void 0);
|
|
571
|
-
|
|
572
|
-
const styles = "/**\n * Do not edit directly\n * Generated on Tue, 26 Sep 2023 13:00:58 GMT\n */\n@supports selector(:focus-visible) {\n :host(:focus-visible) {\n outline: none;\n }\n}\n.base {\n position: relative;\n display: flex;\n box-sizing: border-box;\n align-items: center;\n background-color: var(--_appearance-color-fill);\n box-shadow: inset 0 0 0 1px var(--_appearance-color-outline);\n gap: 12px;\n inline-size: 100%;\n padding-block: 2px;\n padding-inline: 16px;\n}\n.base {\n --_appearance-color-text: var(--_connotation-color-primary);\n --_appearance-color-fill: transparent;\n --_appearance-color-outline: transparent;\n}\n.base: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.base:where(:disabled, .disabled) {\n --_appearance-color-text: var(--vvd-color-neutral-300);\n --_appearance-color-fill: transparent;\n --_appearance-color-outline: transparent;\n}\n.base: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.base:where(.selected, [aria-current]):where(:not(:disabled, .disabled, :hover, .hover)) {\n --_appearance-color-text: var(--_connotation-color-primary);\n --_appearance-color-fill: var(--_connotation-color-dim);\n --_appearance-color-outline: transparent;\n}\n.base:where(.selected, [aria-current]):where(:hover, .hover) {\n --_appearance-color-text: var(--_connotation-color-primary);\n --_appearance-color-fill: var(--_connotation-color-pale);\n --_appearance-color-outline: transparent;\n}\n.base {\n /* @cssprop [--vvd-menu-item-accent-primary=var(--vvd-color-canvas-text)] */\n --_connotation-color-primary: var(--vvd-menu-item-accent-primary, var(--vvd-color-canvas-text));\n /* @cssprop [--vvd-menu-item-accent-primary-text=var(--vvd-color-canvas)] */\n --_connotation-color-primary-text: var(--vvd-menu-item-accent-primary-text, var(--vvd-color-canvas));\n /* @cssprop [--vvd-menu-item-accent-primary-increment=var(--vvd-color-neutral-800)] */\n --_connotation-color-primary-increment: var(--vvd-menu-item-accent-primary-increment, var(--vvd-color-neutral-800));\n /* @cssprop [--vvd-menu-item-accent-faint=var(--vvd-color-neutral-50)] */\n --_connotation-color-faint: var(--vvd-menu-item-accent-faint, var(--vvd-color-neutral-50));\n /* @cssprop [--vvd-menu-item-accent-soft=var(--vvd-color-neutral-100)] */\n --_connotation-color-soft: var(--vvd-menu-item-accent-soft, var(--vvd-color-neutral-100));\n /* @cssprop [--vvd-menu-item-accent-pale=var(--vvd-color-neutral-300)] */\n --_connotation-color-pale: var(--vvd-menu-item-accent-pale, var(--vvd-color-neutral-300));\n /* @cssprop [--vvd-menu-item-accent-dim=var(--vvd-color-neutral-200)] */\n --_connotation-color-dim: var(--vvd-menu-item-accent-dim, var(--vvd-color-neutral-200));\n}\n.base:not(.two-lines) {\n min-block-size: calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2)));\n}\n.base.two-lines {\n min-block-size: calc(calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2))) + calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) - 16)));\n}\n@supports (user-select: none) {\n .base {\n user-select: none;\n }\n}\n.base:not(.disabled) {\n cursor: pointer;\n}\n.base.disabled {\n cursor: not-allowed;\n pointer-events: none;\n}\n\n.focus-indicator {\n border-radius: 6px;\n}\n:host(:not(:focus-visible)) .focus-indicator {\n display: none;\n}\n\n.icon {\n flex-shrink: 0;\n font-size: calc(calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2))) / 2);\n line-height: 1;\n}\n\n.action,\n.decorative {\n display: flex;\n place-content: center;\n}\n\n.action {\n color: var(--_appearance-color-text);\n}\n.base.trailing .action {\n order: 1;\n margin-inline-start: auto;\n}\n.base.has-meta .action {\n order: 1;\n margin-inline-start: auto;\n}\n\n.base:not(.disabled) .decorative {\n color: var(--vvd-color-neutral-600);\n}\n.base.disabled .decorative {\n color: var(--vvd-color-neutral-200);\n}\n.base.has-meta .decorative {\n order: 1;\n margin-inline-start: auto;\n}\n\n.chevron {\n margin-inline-start: auto;\n}\n\n.text {\n display: flex;\n overflow: hidden;\n flex-direction: column;\n}\n\n.text-primary,\n.text-secondary {\n /* stylelint-disable value-no-vendor-prefix */\n display: -webkit-box;\n /* stylelint-enable value-no-vendor-prefix */\n overflow: hidden;\n -webkit-box-orient: vertical;\n color: var(--_appearance-color-text);\n font: var(--vvd-typography-base);\n}\n\n.text-primary {\n -webkit-line-clamp: var(--text-primary-line-clamp, 1);\n}\n.base.two-lines .text-primary {\n font: var(--vvd-typography-base-bold);\n}\n\n.text-secondary {\n -webkit-line-clamp: var(--text-secondary-line-clamp, 1);\n}\n.base.two-lines .text-secondary {\n color: var(--vvd-color-neutral-600);\n}";
|
|
573
|
-
|
|
574
|
-
var __defProp$1 = Object.defineProperty;
|
|
575
|
-
var __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor;
|
|
576
|
-
var __decorateClass$1 = (decorators, target, key, kind) => {
|
|
577
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target;
|
|
578
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
579
|
-
if (decorator = decorators[i])
|
|
580
|
-
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
581
|
-
if (kind && result)
|
|
582
|
-
__defProp$1(target, key, result);
|
|
583
|
-
return result;
|
|
584
|
-
};
|
|
585
|
-
const MenuItemRole = {
|
|
586
|
-
...MenuItemRole$1,
|
|
587
|
-
presentation: "presentation"
|
|
588
|
-
};
|
|
589
|
-
class MenuItem extends MenuItem$1 {
|
|
590
|
-
constructor() {
|
|
591
|
-
super();
|
|
592
|
-
this.#submenuArray = [];
|
|
593
|
-
this.updateSubmenu = () => this.#updateSubmenu();
|
|
594
|
-
this.addEventListener("expanded-change", this.#expandedChange);
|
|
595
|
-
}
|
|
596
|
-
#submenuArray;
|
|
597
|
-
/**
|
|
598
|
-
*
|
|
599
|
-
*
|
|
600
|
-
* @internal
|
|
601
|
-
*/
|
|
602
|
-
slottedSubmenuChanged(_oldValue, newValue) {
|
|
603
|
-
this.#submenuArray = newValue;
|
|
604
|
-
}
|
|
605
|
-
#updateSubmenu() {
|
|
606
|
-
for (const submenu of this.#submenuArray) {
|
|
607
|
-
this.submenu = submenu;
|
|
608
|
-
this.submenu.anchor = this;
|
|
609
|
-
this.submenu.placement = "right-start";
|
|
610
|
-
this.submenu.collapseExpandedItem = () => this.#collapseExpandedItem();
|
|
611
|
-
}
|
|
612
|
-
this.hasSubmenu = this.submenu === void 0 ? false : true;
|
|
613
|
-
}
|
|
614
|
-
#collapseExpandedItem() {
|
|
615
|
-
this.expanded = false;
|
|
616
|
-
}
|
|
617
|
-
#expandedChange() {
|
|
618
|
-
if (this.hasSubmenu) {
|
|
619
|
-
this.submenu.open = this.expanded;
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
|
-
__decorateClass$1([
|
|
624
|
-
attr
|
|
625
|
-
], MenuItem.prototype, "text", 2);
|
|
626
|
-
__decorateClass$1([
|
|
627
|
-
attr({ attribute: "text-secondary" })
|
|
628
|
-
], MenuItem.prototype, "textSecondary", 2);
|
|
629
|
-
__decorateClass$1([
|
|
630
|
-
observable
|
|
631
|
-
], MenuItem.prototype, "metaSlottedContent", 2);
|
|
632
|
-
__decorateClass$1([
|
|
633
|
-
observable
|
|
634
|
-
], MenuItem.prototype, "slottedSubmenu", 2);
|
|
635
|
-
applyMixins(MenuItem, AffixIcon);
|
|
636
|
-
|
|
637
4
|
var __defProp = Object.defineProperty;
|
|
638
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
639
6
|
var __decorateClass = (decorators, target, key, kind) => {
|
|
@@ -645,187 +12,51 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
645
12
|
__defProp(target, key, result);
|
|
646
13
|
return result;
|
|
647
14
|
};
|
|
648
|
-
class
|
|
649
|
-
constructor() {
|
|
650
|
-
super(...arguments);
|
|
651
|
-
this.#anchorEl = null;
|
|
652
|
-
this.#observeMissingAnchor = (anchorId) => {
|
|
653
|
-
this.#observer = new MutationObserver(() => {
|
|
654
|
-
const anchor = document.getElementById(anchorId);
|
|
655
|
-
if (anchor) {
|
|
656
|
-
this.#anchorEl = anchor;
|
|
657
|
-
this.#setupAnchor(this.#anchorEl);
|
|
658
|
-
this.#observer.disconnect();
|
|
659
|
-
this.#observer = void 0;
|
|
660
|
-
}
|
|
661
|
-
});
|
|
662
|
-
this.#observer.observe(document.body, { childList: true, subtree: true });
|
|
663
|
-
};
|
|
664
|
-
this.placement = "bottom";
|
|
665
|
-
this.anchor = "";
|
|
666
|
-
this.autoDismiss = false;
|
|
667
|
-
this.open = false;
|
|
668
|
-
this.#openIfClosed = () => {
|
|
669
|
-
if (!this.open)
|
|
670
|
-
DOM.queueUpdate(() => this.open = true);
|
|
671
|
-
};
|
|
672
|
-
this.#closeOnClickOutside = (e) => {
|
|
673
|
-
if (!this.contains(e.target))
|
|
674
|
-
this.open = false;
|
|
675
|
-
};
|
|
676
|
-
}
|
|
677
|
-
#observer;
|
|
678
|
-
#anchorEl;
|
|
679
|
-
#observeMissingAnchor;
|
|
680
|
-
anchorChanged(_, newValue) {
|
|
681
|
-
if (this.#anchorEl)
|
|
682
|
-
this.#cleanupAnchor(this.#anchorEl);
|
|
683
|
-
this.#observer?.disconnect();
|
|
684
|
-
this.#anchorEl = newValue instanceof HTMLElement ? newValue : document.getElementById(newValue);
|
|
685
|
-
if (this.#anchorEl) {
|
|
686
|
-
this.#setupAnchor(this.#anchorEl);
|
|
687
|
-
} else {
|
|
688
|
-
this.#observeMissingAnchor(newValue);
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
autoDismissChanged(oldValue, newValue) {
|
|
692
|
-
if (oldValue === void 0)
|
|
693
|
-
return;
|
|
694
|
-
if (newValue) {
|
|
695
|
-
document.addEventListener("click", this.#closeOnClickOutside);
|
|
696
|
-
} else {
|
|
697
|
-
document.removeEventListener("click", this.#closeOnClickOutside);
|
|
698
|
-
}
|
|
699
|
-
}
|
|
700
|
-
openChanged(_, newValue) {
|
|
701
|
-
newValue ? this.$emit("open", void 0, { bubbles: false }) : this.$emit("close", void 0, { bubbles: false });
|
|
702
|
-
if (this.#anchorEl) {
|
|
703
|
-
this.#anchorEl.ariaExpanded = this.open.toString();
|
|
704
|
-
}
|
|
705
|
-
}
|
|
706
|
-
disconnectedCallback() {
|
|
707
|
-
super.disconnectedCallback();
|
|
708
|
-
if (this.#anchorEl)
|
|
709
|
-
this.#cleanupAnchor(this.#anchorEl);
|
|
710
|
-
this.#observer?.disconnect();
|
|
711
|
-
document.removeEventListener("click", this.#closeOnClickOutside);
|
|
712
|
-
}
|
|
713
|
-
#setupAnchor(a) {
|
|
714
|
-
a.addEventListener("click", this.#openIfClosed, true);
|
|
715
|
-
a.setAttribute("aria-haspopup", "menu");
|
|
716
|
-
}
|
|
717
|
-
#cleanupAnchor(a) {
|
|
718
|
-
a.removeEventListener("click", this.#openIfClosed, true);
|
|
719
|
-
a.removeAttribute("aria-hasPopup");
|
|
720
|
-
}
|
|
721
|
-
#openIfClosed;
|
|
722
|
-
#closeOnClickOutside;
|
|
15
|
+
class Layout extends FoundationElement {
|
|
723
16
|
}
|
|
724
17
|
__decorateClass([
|
|
725
|
-
attr
|
|
726
|
-
],
|
|
727
|
-
__decorateClass([
|
|
728
|
-
attr({ mode: "fromView" })
|
|
729
|
-
], Menu.prototype, "anchor", 2);
|
|
18
|
+
attr
|
|
19
|
+
], Layout.prototype, "gutters", 2);
|
|
730
20
|
__decorateClass([
|
|
731
|
-
attr({
|
|
732
|
-
],
|
|
21
|
+
attr({ attribute: "column-basis" })
|
|
22
|
+
], Layout.prototype, "columnBasis", 2);
|
|
733
23
|
__decorateClass([
|
|
734
|
-
attr({
|
|
735
|
-
],
|
|
24
|
+
attr({ attribute: "column-spacing" })
|
|
25
|
+
], Layout.prototype, "columnSpacing", 2);
|
|
736
26
|
__decorateClass([
|
|
737
|
-
|
|
738
|
-
],
|
|
27
|
+
attr({ attribute: "row-spacing" })
|
|
28
|
+
], Layout.prototype, "rowSpacing", 2);
|
|
739
29
|
__decorateClass([
|
|
740
|
-
|
|
741
|
-
],
|
|
30
|
+
attr({ attribute: "auto-sizing" })
|
|
31
|
+
], Layout.prototype, "autoSizing", 2);
|
|
32
|
+
|
|
33
|
+
const styles = "/* #region SIZEs */\n/* #region BASES */\n/* #region SPACES */\n.control {\n display: grid;\n grid-auto-rows: var(--layout-grid-template-rows, min-content);\n}\n.control.column-basis-small {\n grid-template-columns: var(--layout-grid-template-columns, repeat(var(--_auto-sizing), minmax(160px, 1fr)));\n}\n.control:not(.column-basis-small):not(.column-basis-medium):not(.column-basis-large):not(.column-basis-block), .control.column-basis-medium {\n grid-template-columns: var(--layout-grid-template-columns, repeat(var(--_auto-sizing), minmax(320px, 1fr)));\n}\n.control.column-basis-large {\n grid-template-columns: var(--layout-grid-template-columns, repeat(var(--_auto-sizing), minmax(380px, 1fr)));\n}\n.control.column-basis-block {\n grid-template-columns: var(--layout-grid-template-columns, repeat(var(--_auto-sizing), minmax(1fr, 1fr)));\n}\n.control.column-spacing-small {\n column-gap: var(--layout-column-gap, calc(calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2))) - calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) - 16))));\n}\n.control.column-spacing-small-inline {\n column-gap: var(--layout-column-gap, 0 calc(calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2))) - calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) - 16))));\n}\n.control.column-spacing-small-block {\n column-gap: var(--layout-column-gap, calc(calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2))) - calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) - 16))) 0);\n}\n.control:not(.column-spacing-small):not(.column-spacing-small-inline):not(.column-spacing-small-block):not(.column-spacing-medium):not(.column-spacing-medium-inline):not(.column-spacing-medium-block):not(.column-spacing-large):not(.column-spacing-large-inline):not(.column-spacing-large-block), .control.column-spacing-medium {\n column-gap: var(--layout-column-gap, calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) - 16)));\n}\n.control.column-spacing-medium-inline {\n column-gap: var(--layout-column-gap, 0 calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) - 16)));\n}\n.control.column-spacing-medium-block {\n column-gap: var(--layout-column-gap, calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) - 16)) 0);\n}\n.control.column-spacing-large {\n column-gap: var(--layout-column-gap, calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) - 8)));\n}\n.control.column-spacing-large-inline {\n column-gap: var(--layout-column-gap, 0 calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) - 8)));\n}\n.control.column-spacing-large-block {\n column-gap: var(--layout-column-gap, calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) - 8)) 0);\n}\n.control.row-spacing-small {\n row-gap: var(--layout-row-gap, calc(calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2))) - calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) - 16))));\n}\n.control.row-spacing-small-inline {\n row-gap: var(--layout-row-gap, 0 calc(calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2))) - calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) - 16))));\n}\n.control.row-spacing-small-block {\n row-gap: var(--layout-row-gap, calc(calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2))) - calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) - 16))) 0);\n}\n.control:not(.row-spacing-small):not(.row-spacing-small-inline):not(.row-spacing-small-block):not(.row-spacing-medium):not(.row-spacing-medium-inline):not(.row-spacing-medium-block):not(.row-spacing-large):not(.row-spacing-large-inline):not(.row-spacing-large-block), .control.row-spacing-medium {\n row-gap: var(--layout-row-gap, calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) - 16)));\n}\n.control.row-spacing-medium-inline {\n row-gap: var(--layout-row-gap, 0 calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) - 16)));\n}\n.control.row-spacing-medium-block {\n row-gap: var(--layout-row-gap, calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) - 16)) 0);\n}\n.control.row-spacing-large {\n row-gap: var(--layout-row-gap, calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) - 8)));\n}\n.control.row-spacing-large-inline {\n row-gap: var(--layout-row-gap, 0 calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) - 8)));\n}\n.control.row-spacing-large-block {\n row-gap: var(--layout-row-gap, calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) - 8)) 0);\n}\n.control.gutters-small {\n margin: calc(calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2))) - calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) - 16)));\n}\n.control.gutters-small-inline {\n margin: 0 calc(calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2))) - calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) - 16)));\n}\n.control.gutters-small-block {\n margin: calc(calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2))) - calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) - 16))) 0;\n}\n.control.gutters-medium {\n margin: calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) - 16));\n}\n.control.gutters-medium-inline {\n margin: 0 calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) - 16));\n}\n.control.gutters-medium-block {\n margin: calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) - 16)) 0;\n}\n.control.gutters-large {\n margin: calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) - 8));\n}\n.control.gutters-large-inline {\n margin: 0 calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) - 8));\n}\n.control.gutters-large-block {\n margin: calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) - 8)) 0;\n}\n.control.auto-sizing-fill {\n --_auto-sizing: auto-fill;\n}\n.control:not(.auto-sizing-fill):not(.auto-sizing-fit), .control.auto-sizing-fit {\n --_auto-sizing: auto-fit;\n}";
|
|
742
34
|
|
|
743
|
-
const getCheckIcon = (affixIconTemplate, x, iconType) => {
|
|
744
|
-
const iconStatus = x.checked ? "checked" : "unchecked";
|
|
745
|
-
const icon = `${iconType}-${iconStatus}-line`;
|
|
746
|
-
return affixIconTemplate(icon);
|
|
747
|
-
};
|
|
748
35
|
const getClasses = ({
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
icon,
|
|
755
|
-
metaSlottedContent
|
|
36
|
+
columnBasis,
|
|
37
|
+
gutters,
|
|
38
|
+
columnSpacing,
|
|
39
|
+
autoSizing,
|
|
40
|
+
rowSpacing
|
|
756
41
|
}) => classNames(
|
|
757
|
-
"
|
|
758
|
-
[
|
|
759
|
-
[
|
|
760
|
-
[
|
|
761
|
-
[
|
|
762
|
-
[
|
|
763
|
-
["two-lines", Boolean(text2?.length) && Boolean(textSecondary?.length)],
|
|
764
|
-
["has-meta", Boolean(metaSlottedContent?.length)]
|
|
42
|
+
"control",
|
|
43
|
+
[`column-basis-${columnBasis}`, Boolean(columnBasis)],
|
|
44
|
+
[`gutters-${gutters}`, Boolean(gutters)],
|
|
45
|
+
[`column-spacing-${columnSpacing}`, Boolean(columnSpacing)],
|
|
46
|
+
[`row-spacing-${rowSpacing ? rowSpacing : columnSpacing}`, Boolean(rowSpacing) || Boolean(columnSpacing)],
|
|
47
|
+
[`auto-sizing-${autoSizing}`, Boolean(autoSizing)]
|
|
765
48
|
);
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
html`<span class="action">${(x) => getCheckIcon(affixIconTemplate, x, "checkbox")}</span>`
|
|
775
|
-
)}`;
|
|
776
|
-
}
|
|
777
|
-
function radio(context) {
|
|
778
|
-
const affixIconTemplate = affixIconTemplateFactory(context);
|
|
779
|
-
return html`${when(
|
|
780
|
-
(x) => x.role === MenuItemRole.menuitemradio,
|
|
781
|
-
html`<span class="action">${(x) => getCheckIcon(affixIconTemplate, x, "radio")}</span>`
|
|
782
|
-
)}`;
|
|
783
|
-
}
|
|
784
|
-
function text() {
|
|
785
|
-
return html`${when(
|
|
786
|
-
(x) => x.text || x.textSecondary,
|
|
787
|
-
html`<span class="text">
|
|
788
|
-
${when((x) => x.text, html`<span class="text-primary">${(x) => x.text}</span>`)}
|
|
789
|
-
${when((x) => x.textSecondary, html`<span class="text-secondary">${(x) => x.textSecondary}</span>`)}
|
|
790
|
-
</span>`
|
|
791
|
-
)}`;
|
|
792
|
-
}
|
|
793
|
-
const MenuItemTemplate = (context) => {
|
|
794
|
-
const affixIconTemplate = affixIconTemplateFactory(context);
|
|
795
|
-
const focusTemplate = focusTemplateFactory(context);
|
|
796
|
-
const iconTag = context.tagFor(Icon);
|
|
797
|
-
return html`
|
|
798
|
-
<template
|
|
799
|
-
role="${(x) => x.role ? x.role : MenuItemRole.menuitem}"
|
|
800
|
-
aria-haspopup="${(x) => x.hasSubmenu ? "menu" : void 0}"
|
|
801
|
-
aria-checked="${(x) => x.role !== MenuItemRole.menuitem ? x.checked : void 0}"
|
|
802
|
-
aria-disabled="${(x) => x.disabled}"
|
|
803
|
-
aria-expanded="${(x) => x.expanded}"
|
|
804
|
-
@keydown="${(x, c) => x.handleMenuItemKeyDown(c.event)}"
|
|
805
|
-
@click="${handleClick}"
|
|
806
|
-
@mouseover="${(x, c) => x.handleMouseOver(c.event)}"
|
|
807
|
-
@mouseout="${(x, c) => x.handleMouseOut(c.event)}"
|
|
808
|
-
>
|
|
809
|
-
<div class="${getClasses}">
|
|
810
|
-
${() => focusTemplate}
|
|
811
|
-
<slot name="meta" ${slotted("metaSlottedContent")}></slot>
|
|
812
|
-
${checkbox(context)}
|
|
813
|
-
${radio(context)}
|
|
814
|
-
${when((x) => x.icon, html`<span class="decorative">${(x) => affixIconTemplate(x.icon)}</span>`)}
|
|
815
|
-
${text()}
|
|
816
|
-
${when((x) => x.hasSubmenu, html`<${iconTag} class="chevron" name="chevron-right-line"></${iconTag}>`)}
|
|
817
|
-
</div>
|
|
818
|
-
<slot name="submenu" ${slotted({ property: "slottedSubmenu", filter: elements(context.tagFor(Menu)) })}></slot>
|
|
819
|
-
</template>
|
|
820
|
-
`;
|
|
821
|
-
};
|
|
822
|
-
|
|
823
|
-
const menuItemDefinition = MenuItem.compose({
|
|
824
|
-
baseName: "menu-item",
|
|
825
|
-
template: MenuItemTemplate,
|
|
49
|
+
const layoutTemplate = () => html`
|
|
50
|
+
<div class="${getClasses}">
|
|
51
|
+
<slot></slot>
|
|
52
|
+
</div>`;
|
|
53
|
+
|
|
54
|
+
const layoutDefinition = Layout.compose({
|
|
55
|
+
baseName: "layout",
|
|
56
|
+
template: layoutTemplate,
|
|
826
57
|
styles
|
|
827
58
|
});
|
|
828
|
-
const
|
|
829
|
-
const
|
|
59
|
+
const layoutRegistries = [layoutDefinition()];
|
|
60
|
+
const registerLayout = registerFactory(layoutRegistries);
|
|
830
61
|
|
|
831
|
-
export {
|
|
62
|
+
export { layoutRegistries as a, layoutDefinition as l, registerLayout as r };
|