@vonage/vivid 3.0.0-next.9 → 3.0.0-next.90
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 +141 -4
- package/accordion/index.js +3 -12
- package/accordion-item/index.js +30 -38
- package/action-group/index.js +41 -0
- package/avatar/index.js +60 -0
- package/badge/index.js +16 -30
- package/banner/index.js +25 -111
- package/breadcrumb/index.js +21 -18
- package/breadcrumb-item/index.js +23 -20
- package/button/index.js +19 -757
- package/calendar/index.js +72 -67
- package/calendar-event/index.js +112 -0
- package/card/index.js +113 -0
- package/checkbox/index.js +176 -0
- package/dialog/index.js +229 -0
- package/divider/index.js +4 -0
- package/elevation/index.js +3 -31
- package/fab/index.js +99 -0
- package/focus/index.js +18 -3
- package/header/index.js +61 -0
- package/icon/index.js +10 -9
- package/index.js +57 -20
- package/layout/index.js +5 -15
- package/lib/accordion-item/accordion-item.d.ts +2 -2
- package/lib/accordion-item/index.d.ts +2 -1
- package/lib/action-group/action-group.d.ts +10 -0
- package/lib/{sidenav-item/sidenav-item.template.d.ts → action-group/action-group.template.d.ts} +2 -2
- package/lib/{sidenav-item → action-group}/index.d.ts +1 -2
- package/lib/avatar/avatar.d.ts +15 -0
- package/lib/avatar/avatar.template.d.ts +4 -0
- package/lib/avatar/index.d.ts +3 -0
- package/lib/badge/badge.d.ts +3 -5
- package/lib/badge/index.d.ts +1 -1
- package/lib/banner/banner.d.ts +1 -1
- package/lib/banner/banner.template.d.ts +0 -2
- package/lib/banner/index.d.ts +1 -0
- package/lib/breadcrumb/breadcrumb.template.d.ts +4 -0
- package/lib/breadcrumb-item/breadcrumb-item.d.ts +1 -1
- package/lib/breadcrumb-item/index.d.ts +1 -0
- package/lib/button/button.d.ts +6 -5
- package/lib/button/index.d.ts +2 -19
- package/lib/calendar/calendar.d.ts +3 -1
- package/lib/calendar/index.d.ts +0 -1
- package/lib/calendar-event/calendar-event.d.ts +14 -0
- package/lib/calendar-event/calendar-event.template.d.ts +4 -0
- package/lib/calendar-event/index.d.ts +2 -0
- package/lib/card/card.d.ts +10 -0
- package/lib/{text/text.template.d.ts → card/card.template.d.ts} +2 -2
- package/lib/card/index.d.ts +4 -0
- package/lib/checkbox/checkbox.d.ts +5 -0
- package/lib/checkbox/checkbox.template.d.ts +4 -0
- package/lib/checkbox/index.d.ts +4 -0
- package/lib/components.d.ts +29 -10
- package/lib/dialog/dialog.d.ts +20 -0
- package/lib/dialog/dialog.template.d.ts +4 -0
- package/lib/dialog/index.d.ts +5 -0
- package/lib/divider/divider.d.ts +3 -0
- package/lib/divider/divider.template.d.ts +4 -0
- package/lib/divider/index.d.ts +2 -0
- package/lib/elevation/elevation.d.ts +1 -0
- package/lib/elevation/index.d.ts +1 -1
- package/lib/enums.d.ts +11 -6
- package/lib/fab/fab.d.ts +13 -0
- package/lib/fab/fab.template.d.ts +4 -0
- package/lib/fab/index.d.ts +4 -0
- package/lib/focus/index.d.ts +1 -1
- package/lib/header/header.d.ts +5 -0
- package/lib/header/header.template.d.ts +4 -0
- package/lib/header/index.d.ts +3 -0
- package/lib/icon/icon.d.ts +4 -3
- package/lib/layout/index.d.ts +1 -1
- package/lib/layout/layout.d.ts +3 -3
- package/lib/listbox-option/index.d.ts +4 -0
- package/lib/listbox-option/listbox-option.d.ts +7 -0
- package/lib/listbox-option/listbox-option.template.d.ts +4 -0
- package/lib/menu/index.d.ts +12 -0
- package/lib/menu/menu.d.ts +10 -0
- package/lib/menu/menu.template.d.ts +3 -0
- package/lib/menu-item/index.d.ts +3 -0
- package/lib/menu-item/menu-item.d.ts +7 -0
- package/lib/menu-item/menu-item.template.d.ts +5 -0
- package/lib/nav/index.d.ts +2 -0
- package/lib/nav/nav.d.ts +3 -0
- package/lib/nav/nav.template.d.ts +4 -0
- package/lib/nav-disclosure/index.d.ts +4 -0
- package/lib/nav-disclosure/nav-disclosure.d.ts +10 -0
- package/lib/nav-disclosure/nav-disclosure.template.d.ts +4 -0
- package/lib/nav-item/index.d.ts +4 -0
- package/lib/{sidenav-item/sidenav-item.d.ts → nav-item/nav-item.d.ts} +2 -2
- package/lib/nav-item/nav-item.template.d.ts +4 -0
- package/lib/{text → note}/index.d.ts +1 -1
- package/lib/note/note.d.ts +10 -0
- package/lib/note/note.template.d.ts +5 -0
- package/lib/number-field/index.d.ts +4 -0
- package/lib/number-field/number-field.d.ts +14 -0
- package/lib/number-field/number-field.template.d.ts +4 -0
- package/lib/popup/index.d.ts +1 -1
- package/lib/popup/popup.d.ts +2 -1
- package/lib/progress/progress.d.ts +1 -1
- package/lib/progress-ring/progress-ring.d.ts +2 -1
- package/lib/radio/index.d.ts +3 -0
- package/lib/radio/radio.d.ts +4 -0
- package/lib/radio/radio.template.d.ts +4 -0
- package/lib/radio-group/index.d.ts +10 -0
- package/lib/radio-group/radio-group.d.ts +4 -0
- package/lib/radio-group/radio-group.template.d.ts +4 -0
- package/lib/side-drawer/index.d.ts +1 -1
- package/lib/side-drawer/side-drawer.d.ts +3 -2
- package/lib/text-anchor/text-anchor.d.ts +1 -1
- package/lib/text-area/index.d.ts +4 -0
- package/lib/text-area/text-area.d.ts +9 -0
- package/lib/text-area/text-area.template.d.ts +4 -0
- package/lib/text-field/index.d.ts +4 -0
- package/lib/text-field/text-field.d.ts +14 -0
- package/lib/text-field/text-field.template.d.ts +5 -0
- package/lib/tooltip/tooltip.d.ts +2 -2
- package/listbox-option/index.js +248 -0
- package/menu/index.js +376 -0
- package/menu-item/index.js +20 -0
- package/nav/index.js +17 -0
- package/nav-disclosure/index.js +81 -0
- package/nav-item/index.js +45 -0
- package/note/index.js +58 -0
- package/number-field/index.js +516 -0
- package/package.json +58 -10
- package/popup/index.js +22 -2061
- package/progress/index.js +35 -36
- package/progress-ring/index.js +11 -11
- package/radio/index.js +50 -0
- package/radio-group/index.js +435 -0
- package/shared/affix.js +1 -6
- package/shared/anchor.js +10 -2
- package/shared/apply-mixins.js +5 -4
- package/shared/aria-global.js +2 -86
- package/shared/aria.js +9 -0
- package/shared/base-progress.js +5 -0
- package/shared/breadcrumb-item.js +1 -1
- package/shared/button.js +200 -0
- package/shared/calendar-event.js +19 -0
- package/shared/dialog-polyfill.esm.js +858 -0
- package/shared/direction.js +20 -0
- package/shared/enums.js +62 -0
- package/shared/es.object.assign.js +3 -2
- package/shared/export.js +1017 -0
- package/shared/focus.js +5 -0
- package/shared/focus2.js +11 -0
- package/shared/form-associated.js +466 -0
- package/shared/form-elements.js +331 -0
- package/shared/icon.js +534 -531
- package/shared/index.js +108 -79
- package/shared/index2.js +100 -14
- package/shared/index3.js +31 -0
- package/shared/index4.js +77 -0
- package/shared/index5.js +1525 -0
- package/shared/index6.js +349 -0
- package/shared/iterators.js +61 -0
- package/shared/key-codes.js +96 -0
- package/shared/object-keys.js +13 -0
- package/shared/patterns/focus.d.ts +3 -0
- package/shared/patterns/form-elements/form-elements.d.ts +28 -0
- package/shared/patterns/form-elements/index.d.ts +1 -0
- package/shared/patterns/index.d.ts +2 -0
- package/shared/radio.js +127 -0
- package/shared/ref.js +41 -0
- package/shared/slotted.js +1 -1
- package/shared/start-end.js +50 -0
- package/shared/text-anchor.js +2 -13
- package/shared/text-anchor.template.js +6 -5
- package/shared/to-string.js +51 -0
- package/shared/web.dom-collections.iterator.js +74 -1081
- package/side-drawer/index.js +41 -33
- package/styles/core/all.css +75 -0
- package/styles/core/theme.css +11 -0
- package/styles/core/typography.css +69 -0
- package/styles/fonts/SpeziaCompleteVariableItalicWeb.woff2 +0 -0
- package/styles/fonts/SpeziaCompleteVariableUprightWeb.woff2 +0 -0
- package/styles/fonts/SpeziaMonoCompleteVariableWeb.woff2 +0 -0
- package/styles/fonts/spezia.css +9 -12
- package/styles/tokens/theme-dark.css +230 -0
- package/styles/tokens/theme-light.css +230 -0
- package/text-anchor/index.js +9 -1
- package/text-area/index.js +288 -0
- package/text-field/index.js +129 -0
- package/tooltip/index.js +23 -24
- package/lib/text/text.d.ts +0 -10
- package/shared/style-inject.es.js +0 -28
- package/sidenav-item/index.js +0 -38
- package/styles/themes/dark.css +0 -205
- package/styles/themes/light.css +0 -205
- package/text/index.js +0 -45
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import '../icon/index.js';
|
|
2
|
+
import '../focus/index.js';
|
|
3
|
+
import { F as FoundationElement, O as Observable, _ as __decorate, o as observable, a as attr, b as __metadata, h as html, d as designSystem } from '../shared/index.js';
|
|
4
|
+
import { A as AffixIconWithTrailing, a as affixIconTemplateFactory } from '../shared/affix.js';
|
|
5
|
+
import { A as ARIAGlobalStatesAndProperties } from '../shared/aria-global.js';
|
|
6
|
+
import { S as StartEnd } from '../shared/start-end.js';
|
|
7
|
+
import { a as applyMixins } from '../shared/apply-mixins.js';
|
|
8
|
+
import { f as focusTemplateFactory } from '../shared/focus2.js';
|
|
9
|
+
import '../shared/web.dom-collections.iterator.js';
|
|
10
|
+
import '../shared/icon.js';
|
|
11
|
+
import { w as when } from '../shared/when.js';
|
|
12
|
+
import { c as classNames } from '../shared/class-names.js';
|
|
13
|
+
import '../shared/export.js';
|
|
14
|
+
import '../shared/iterators.js';
|
|
15
|
+
import '../shared/to-string.js';
|
|
16
|
+
import '../shared/_has.js';
|
|
17
|
+
import '../shared/focus.js';
|
|
18
|
+
import '../shared/ref.js';
|
|
19
|
+
import '../shared/object-keys.js';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* An Option Custom HTML Element.
|
|
23
|
+
* Implements {@link https://www.w3.org/TR/wai-aria-1.1/#option | ARIA option }.
|
|
24
|
+
*
|
|
25
|
+
* @slot start - Content which can be provided before the listbox option content
|
|
26
|
+
* @slot end - Content which can be provided after the listbox option content
|
|
27
|
+
* @slot - The default slot for listbox option content
|
|
28
|
+
* @csspart content - Wraps the listbox option content
|
|
29
|
+
*
|
|
30
|
+
* @public
|
|
31
|
+
*/
|
|
32
|
+
class ListboxOption$1 extends FoundationElement {
|
|
33
|
+
constructor(text, value, defaultSelected, selected) {
|
|
34
|
+
super();
|
|
35
|
+
/**
|
|
36
|
+
* The defaultSelected state of the option.
|
|
37
|
+
* @public
|
|
38
|
+
*/
|
|
39
|
+
this.defaultSelected = false;
|
|
40
|
+
/**
|
|
41
|
+
* Tracks whether the "selected" property has been changed.
|
|
42
|
+
* @internal
|
|
43
|
+
*/
|
|
44
|
+
this.dirtySelected = false;
|
|
45
|
+
/**
|
|
46
|
+
* The checked state of the control.
|
|
47
|
+
*
|
|
48
|
+
* @public
|
|
49
|
+
*/
|
|
50
|
+
this.selected = this.defaultSelected;
|
|
51
|
+
/**
|
|
52
|
+
* Track whether the value has been changed from the initial value
|
|
53
|
+
*/
|
|
54
|
+
this.dirtyValue = false;
|
|
55
|
+
if (text) {
|
|
56
|
+
this.textContent = text;
|
|
57
|
+
}
|
|
58
|
+
if (value) {
|
|
59
|
+
this.initialValue = value;
|
|
60
|
+
}
|
|
61
|
+
if (defaultSelected) {
|
|
62
|
+
this.defaultSelected = defaultSelected;
|
|
63
|
+
}
|
|
64
|
+
if (selected) {
|
|
65
|
+
this.selected = selected;
|
|
66
|
+
}
|
|
67
|
+
this.proxy = new Option(`${this.textContent}`, this.initialValue, this.defaultSelected, this.selected);
|
|
68
|
+
this.proxy.disabled = this.disabled;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Updates the ariaChecked property when the checked property changes.
|
|
72
|
+
*
|
|
73
|
+
* @param prev - the previous checked value
|
|
74
|
+
* @param next - the current checked value
|
|
75
|
+
*
|
|
76
|
+
* @public
|
|
77
|
+
*/
|
|
78
|
+
checkedChanged(prev, next) {
|
|
79
|
+
if (typeof next === "boolean") {
|
|
80
|
+
this.ariaChecked = next ? "true" : "false";
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
this.ariaChecked = null;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Updates the proxy's text content when the default slot changes.
|
|
87
|
+
* @param prev - the previous content value
|
|
88
|
+
* @param next - the current content value
|
|
89
|
+
*
|
|
90
|
+
* @internal
|
|
91
|
+
*/
|
|
92
|
+
contentChanged(prev, next) {
|
|
93
|
+
if (this.proxy instanceof HTMLOptionElement) {
|
|
94
|
+
this.proxy.textContent = this.textContent;
|
|
95
|
+
}
|
|
96
|
+
this.$emit("contentchange", null, { bubbles: true });
|
|
97
|
+
}
|
|
98
|
+
defaultSelectedChanged() {
|
|
99
|
+
if (!this.dirtySelected) {
|
|
100
|
+
this.selected = this.defaultSelected;
|
|
101
|
+
if (this.proxy instanceof HTMLOptionElement) {
|
|
102
|
+
this.proxy.selected = this.defaultSelected;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
disabledChanged(prev, next) {
|
|
107
|
+
this.ariaDisabled = this.disabled ? "true" : "false";
|
|
108
|
+
if (this.proxy instanceof HTMLOptionElement) {
|
|
109
|
+
this.proxy.disabled = this.disabled;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
selectedAttributeChanged() {
|
|
113
|
+
this.defaultSelected = this.selectedAttribute;
|
|
114
|
+
if (this.proxy instanceof HTMLOptionElement) {
|
|
115
|
+
this.proxy.defaultSelected = this.defaultSelected;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
selectedChanged() {
|
|
119
|
+
this.ariaSelected = this.selected ? "true" : "false";
|
|
120
|
+
if (!this.dirtySelected) {
|
|
121
|
+
this.dirtySelected = true;
|
|
122
|
+
}
|
|
123
|
+
if (this.proxy instanceof HTMLOptionElement) {
|
|
124
|
+
this.proxy.selected = this.selected;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
initialValueChanged(previous, next) {
|
|
128
|
+
// If the value is clean and the component is connected to the DOM
|
|
129
|
+
// then set value equal to the attribute value.
|
|
130
|
+
if (!this.dirtyValue) {
|
|
131
|
+
this.value = this.initialValue;
|
|
132
|
+
this.dirtyValue = false;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
get label() {
|
|
136
|
+
var _a;
|
|
137
|
+
return (_a = this.value) !== null && _a !== void 0 ? _a : this.text;
|
|
138
|
+
}
|
|
139
|
+
get text() {
|
|
140
|
+
var _a, _b;
|
|
141
|
+
return (_b = (_a = this.textContent) === null || _a === void 0 ? void 0 : _a.replace(/\s+/g, " ").trim()) !== null && _b !== void 0 ? _b : "";
|
|
142
|
+
}
|
|
143
|
+
set value(next) {
|
|
144
|
+
const newValue = `${next !== null && next !== void 0 ? next : ""}`;
|
|
145
|
+
this._value = newValue;
|
|
146
|
+
this.dirtyValue = true;
|
|
147
|
+
if (this.proxy instanceof HTMLOptionElement) {
|
|
148
|
+
this.proxy.value = newValue;
|
|
149
|
+
}
|
|
150
|
+
Observable.notify(this, "value");
|
|
151
|
+
}
|
|
152
|
+
get value() {
|
|
153
|
+
var _a;
|
|
154
|
+
Observable.track(this, "value");
|
|
155
|
+
return (_a = this._value) !== null && _a !== void 0 ? _a : this.text;
|
|
156
|
+
}
|
|
157
|
+
get form() {
|
|
158
|
+
return this.proxy ? this.proxy.form : null;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
__decorate([
|
|
162
|
+
observable
|
|
163
|
+
], ListboxOption$1.prototype, "checked", void 0);
|
|
164
|
+
__decorate([
|
|
165
|
+
observable
|
|
166
|
+
], ListboxOption$1.prototype, "content", void 0);
|
|
167
|
+
__decorate([
|
|
168
|
+
observable
|
|
169
|
+
], ListboxOption$1.prototype, "defaultSelected", void 0);
|
|
170
|
+
__decorate([
|
|
171
|
+
attr({ mode: "boolean" })
|
|
172
|
+
], ListboxOption$1.prototype, "disabled", void 0);
|
|
173
|
+
__decorate([
|
|
174
|
+
attr({ attribute: "selected", mode: "boolean" })
|
|
175
|
+
], ListboxOption$1.prototype, "selectedAttribute", void 0);
|
|
176
|
+
__decorate([
|
|
177
|
+
observable
|
|
178
|
+
], ListboxOption$1.prototype, "selected", void 0);
|
|
179
|
+
__decorate([
|
|
180
|
+
attr({ attribute: "value", mode: "fromView" })
|
|
181
|
+
], ListboxOption$1.prototype, "initialValue", void 0);
|
|
182
|
+
/**
|
|
183
|
+
* States and properties relating to the ARIA `option` role.
|
|
184
|
+
*
|
|
185
|
+
* @public
|
|
186
|
+
*/
|
|
187
|
+
class DelegatesARIAListboxOption {
|
|
188
|
+
}
|
|
189
|
+
__decorate([
|
|
190
|
+
observable
|
|
191
|
+
], DelegatesARIAListboxOption.prototype, "ariaChecked", void 0);
|
|
192
|
+
__decorate([
|
|
193
|
+
observable
|
|
194
|
+
], DelegatesARIAListboxOption.prototype, "ariaPosInSet", void 0);
|
|
195
|
+
__decorate([
|
|
196
|
+
observable
|
|
197
|
+
], DelegatesARIAListboxOption.prototype, "ariaSelected", void 0);
|
|
198
|
+
__decorate([
|
|
199
|
+
observable
|
|
200
|
+
], DelegatesARIAListboxOption.prototype, "ariaSetSize", void 0);
|
|
201
|
+
applyMixins(DelegatesARIAListboxOption, ARIAGlobalStatesAndProperties);
|
|
202
|
+
applyMixins(ListboxOption$1, StartEnd, DelegatesARIAListboxOption);
|
|
203
|
+
|
|
204
|
+
class ListboxOption extends ListboxOption$1 {}
|
|
205
|
+
__decorate([attr({
|
|
206
|
+
attribute: 'text'
|
|
207
|
+
}), __metadata("design:type", String)], ListboxOption.prototype, "optionText", void 0);
|
|
208
|
+
applyMixins(ListboxOption, AffixIconWithTrailing);
|
|
209
|
+
|
|
210
|
+
let _ = t => t,
|
|
211
|
+
_t,
|
|
212
|
+
_t2;
|
|
213
|
+
const getClasses = ({
|
|
214
|
+
icon,
|
|
215
|
+
disabled,
|
|
216
|
+
selected,
|
|
217
|
+
checked
|
|
218
|
+
}) => classNames('base', ['disabled', disabled], ['selected', Boolean(selected)], ['active', Boolean(checked)], ['icon', Boolean(icon)]);
|
|
219
|
+
const ListboxOptionTemplate = context => {
|
|
220
|
+
const affixIconTemplate = affixIconTemplateFactory(context);
|
|
221
|
+
const focusTemplate = focusTemplateFactory(context);
|
|
222
|
+
return html(_t || (_t = _`
|
|
223
|
+
<template
|
|
224
|
+
aria-checked="${0}"
|
|
225
|
+
aria-disabled="${0}"
|
|
226
|
+
aria-posinset="${0}"
|
|
227
|
+
aria-selected="${0}"
|
|
228
|
+
aria-setsize="${0}"
|
|
229
|
+
role="option">
|
|
230
|
+
<div class="${0}">
|
|
231
|
+
${0}
|
|
232
|
+
${0}
|
|
233
|
+
${0}
|
|
234
|
+
</div>
|
|
235
|
+
</template>
|
|
236
|
+
`), x => x.ariaChecked, x => x.ariaDisabled, x => x.ariaPosInSet, x => x.ariaSelected, x => x.ariaSetSize, getClasses, () => focusTemplate, x => affixIconTemplate(x.icon), when(x => x.optionText, html(_t2 || (_t2 = _`<div class="text">${0}</div>`), x => x.optionText)));
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
var css_248z = "/**\n * Do not edit directly\n * Generated on Thu, 03 Nov 2022 17:18:46 GMT\n */\n.base {\n display: 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: 8px;\n hyphens: auto;\n inline-size: 100%;\n min-block-size: calc(1px * (40 + 8 * clamp(-1, var(--vvd-size-density, 0), 1)));\n padding-block: 10px;\n padding-inline: 8px;\n vertical-align: middle;\n word-break: break-word;\n}\n.base {\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.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)) {\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-400);\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-text);\n --_appearance-color-fill: var(--_connotation-color-primary);\n --_appearance-color-outline: transparent;\n}\n.base: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@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}\n.base .text {\n font: var(--vvd-typography-base);\n}\n\n.icon {\n font-size: 20px;\n}\n\n.focus-indicator {\n --focus-stroke-color: var(--vvd-color-neutral-500);\n}\n:host(:not([aria-checked=true])) .focus-indicator {\n display: none;\n}";
|
|
240
|
+
|
|
241
|
+
const vividListboxOption = ListboxOption.compose({
|
|
242
|
+
baseName: 'option',
|
|
243
|
+
template: ListboxOptionTemplate,
|
|
244
|
+
styles: css_248z
|
|
245
|
+
});
|
|
246
|
+
designSystem.register(vividListboxOption());
|
|
247
|
+
|
|
248
|
+
export { vividListboxOption };
|
package/menu/index.js
ADDED
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
import { P as Popup } from '../shared/index5.js';
|
|
2
|
+
import { M as MenuItem, a as MenuItemRole, r as roleForMenuItem } from '../shared/index6.js';
|
|
3
|
+
import { F as FoundationElement, D as DOM, _ as __decorate, o as observable, a as attr, b as __metadata, h as html, d as designSystem } from '../shared/index.js';
|
|
4
|
+
import '../shared/web.dom-collections.iterator.js';
|
|
5
|
+
import { b as keyHome, c as keyEnd, d as keyArrowUp, e as keyArrowDown } from '../shared/key-codes.js';
|
|
6
|
+
import { s as slotted } from '../shared/slotted.js';
|
|
7
|
+
import { r as ref } from '../shared/ref.js';
|
|
8
|
+
import '../shared/index3.js';
|
|
9
|
+
import '../shared/class-names.js';
|
|
10
|
+
import '../shared/index2.js';
|
|
11
|
+
import '../icon/index.js';
|
|
12
|
+
import '../shared/icon.js';
|
|
13
|
+
import '../shared/export.js';
|
|
14
|
+
import '../shared/iterators.js';
|
|
15
|
+
import '../shared/to-string.js';
|
|
16
|
+
import '../shared/_has.js';
|
|
17
|
+
import '../shared/when.js';
|
|
18
|
+
import '../focus/index.js';
|
|
19
|
+
import '../shared/focus.js';
|
|
20
|
+
import '../shared/affix.js';
|
|
21
|
+
import '../shared/button.js';
|
|
22
|
+
import '../shared/apply-mixins.js';
|
|
23
|
+
import '../shared/form-associated.js';
|
|
24
|
+
import '../shared/aria-global.js';
|
|
25
|
+
import '../shared/start-end.js';
|
|
26
|
+
import '../shared/focus2.js';
|
|
27
|
+
import '../shared/es.object.assign.js';
|
|
28
|
+
import '../shared/object-keys.js';
|
|
29
|
+
import '../shared/direction.js';
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* A test that ensures that all arguments are HTML Elements
|
|
33
|
+
*/
|
|
34
|
+
function isHTMLElement(...args) {
|
|
35
|
+
return args.every((arg) => arg instanceof HTMLElement);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* A Menu Custom HTML Element.
|
|
40
|
+
* Implements the {@link https://www.w3.org/TR/wai-aria-1.1/#menu | ARIA menu }.
|
|
41
|
+
*
|
|
42
|
+
* @slot - The default slot for the menu items
|
|
43
|
+
*
|
|
44
|
+
* @public
|
|
45
|
+
*/
|
|
46
|
+
class Menu$1 extends FoundationElement {
|
|
47
|
+
constructor() {
|
|
48
|
+
super(...arguments);
|
|
49
|
+
this.expandedItem = null;
|
|
50
|
+
/**
|
|
51
|
+
* The index of the focusable element in the items array
|
|
52
|
+
* defaults to -1
|
|
53
|
+
*/
|
|
54
|
+
this.focusIndex = -1;
|
|
55
|
+
/**
|
|
56
|
+
* @internal
|
|
57
|
+
*/
|
|
58
|
+
this.isNestedMenu = () => {
|
|
59
|
+
return (this.parentElement !== null &&
|
|
60
|
+
isHTMLElement(this.parentElement) &&
|
|
61
|
+
this.parentElement.getAttribute("role") === "menuitem");
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* if focus is moving out of the menu, reset to a stable initial state
|
|
65
|
+
* @internal
|
|
66
|
+
*/
|
|
67
|
+
this.handleFocusOut = (e) => {
|
|
68
|
+
if (!this.contains(e.relatedTarget) && this.menuItems !== undefined) {
|
|
69
|
+
this.collapseExpandedItem();
|
|
70
|
+
// find our first focusable element
|
|
71
|
+
const focusIndex = this.menuItems.findIndex(this.isFocusableElement);
|
|
72
|
+
// set the current focus index's tabindex to -1
|
|
73
|
+
this.menuItems[this.focusIndex].setAttribute("tabindex", "-1");
|
|
74
|
+
// set the first focusable element tabindex to 0
|
|
75
|
+
this.menuItems[focusIndex].setAttribute("tabindex", "0");
|
|
76
|
+
// set the focus index
|
|
77
|
+
this.focusIndex = focusIndex;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
this.handleItemFocus = (e) => {
|
|
81
|
+
const targetItem = e.target;
|
|
82
|
+
if (this.menuItems !== undefined &&
|
|
83
|
+
targetItem !== this.menuItems[this.focusIndex]) {
|
|
84
|
+
this.menuItems[this.focusIndex].setAttribute("tabindex", "-1");
|
|
85
|
+
this.focusIndex = this.menuItems.indexOf(targetItem);
|
|
86
|
+
targetItem.setAttribute("tabindex", "0");
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
this.handleExpandedChanged = (e) => {
|
|
90
|
+
if (e.defaultPrevented ||
|
|
91
|
+
e.target === null ||
|
|
92
|
+
this.menuItems === undefined ||
|
|
93
|
+
this.menuItems.indexOf(e.target) < 0) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
e.preventDefault();
|
|
97
|
+
const changedItem = e.target;
|
|
98
|
+
// closing an expanded item without opening another
|
|
99
|
+
if (this.expandedItem !== null &&
|
|
100
|
+
changedItem === this.expandedItem &&
|
|
101
|
+
changedItem.expanded === false) {
|
|
102
|
+
this.expandedItem = null;
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
if (changedItem.expanded) {
|
|
106
|
+
if (this.expandedItem !== null && this.expandedItem !== changedItem) {
|
|
107
|
+
this.expandedItem.expanded = false;
|
|
108
|
+
}
|
|
109
|
+
this.menuItems[this.focusIndex].setAttribute("tabindex", "-1");
|
|
110
|
+
this.expandedItem = changedItem;
|
|
111
|
+
this.focusIndex = this.menuItems.indexOf(changedItem);
|
|
112
|
+
changedItem.setAttribute("tabindex", "0");
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
this.removeItemListeners = () => {
|
|
116
|
+
if (this.menuItems !== undefined) {
|
|
117
|
+
this.menuItems.forEach((item) => {
|
|
118
|
+
item.removeEventListener("expanded-change", this.handleExpandedChanged);
|
|
119
|
+
item.removeEventListener("focus", this.handleItemFocus);
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
this.setItems = () => {
|
|
124
|
+
const newItems = this.domChildren();
|
|
125
|
+
this.removeItemListeners();
|
|
126
|
+
this.menuItems = newItems;
|
|
127
|
+
const menuItems = this.menuItems.filter(this.isMenuItemElement);
|
|
128
|
+
// if our focus index is not -1 we have items
|
|
129
|
+
if (menuItems.length) {
|
|
130
|
+
this.focusIndex = 0;
|
|
131
|
+
}
|
|
132
|
+
function elementIndent(el) {
|
|
133
|
+
const role = el.getAttribute("role");
|
|
134
|
+
const startSlot = el.querySelector("[slot=start]");
|
|
135
|
+
if (role !== MenuItemRole.menuitem && startSlot === null) {
|
|
136
|
+
return 1;
|
|
137
|
+
}
|
|
138
|
+
else if (role === MenuItemRole.menuitem && startSlot !== null) {
|
|
139
|
+
return 1;
|
|
140
|
+
}
|
|
141
|
+
else if (role !== MenuItemRole.menuitem && startSlot !== null) {
|
|
142
|
+
return 2;
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
return 0;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
const indent = menuItems.reduce((accum, current) => {
|
|
149
|
+
const elementValue = elementIndent(current);
|
|
150
|
+
return accum > elementValue ? accum : elementValue;
|
|
151
|
+
}, 0);
|
|
152
|
+
menuItems.forEach((item, index) => {
|
|
153
|
+
item.setAttribute("tabindex", index === 0 ? "0" : "-1");
|
|
154
|
+
item.addEventListener("expanded-change", this.handleExpandedChanged);
|
|
155
|
+
item.addEventListener("focus", this.handleItemFocus);
|
|
156
|
+
if (item instanceof MenuItem) {
|
|
157
|
+
item.startColumnCount = indent;
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* handle change from child element
|
|
163
|
+
*/
|
|
164
|
+
this.changeHandler = (e) => {
|
|
165
|
+
if (this.menuItems === undefined) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
const changedMenuItem = e.target;
|
|
169
|
+
const changeItemIndex = this.menuItems.indexOf(changedMenuItem);
|
|
170
|
+
if (changeItemIndex === -1) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
if (changedMenuItem.role === "menuitemradio" &&
|
|
174
|
+
changedMenuItem.checked === true) {
|
|
175
|
+
for (let i = changeItemIndex - 1; i >= 0; --i) {
|
|
176
|
+
const item = this.menuItems[i];
|
|
177
|
+
const role = item.getAttribute("role");
|
|
178
|
+
if (role === MenuItemRole.menuitemradio) {
|
|
179
|
+
item.checked = false;
|
|
180
|
+
}
|
|
181
|
+
if (role === "separator") {
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
const maxIndex = this.menuItems.length - 1;
|
|
186
|
+
for (let i = changeItemIndex + 1; i <= maxIndex; ++i) {
|
|
187
|
+
const item = this.menuItems[i];
|
|
188
|
+
const role = item.getAttribute("role");
|
|
189
|
+
if (role === MenuItemRole.menuitemradio) {
|
|
190
|
+
item.checked = false;
|
|
191
|
+
}
|
|
192
|
+
if (role === "separator") {
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
/**
|
|
199
|
+
* check if the item is a menu item
|
|
200
|
+
*/
|
|
201
|
+
this.isMenuItemElement = (el) => {
|
|
202
|
+
return (isHTMLElement(el) &&
|
|
203
|
+
Menu$1.focusableElementRoles.hasOwnProperty(el.getAttribute("role")));
|
|
204
|
+
};
|
|
205
|
+
/**
|
|
206
|
+
* check if the item is focusable
|
|
207
|
+
*/
|
|
208
|
+
this.isFocusableElement = (el) => {
|
|
209
|
+
return this.isMenuItemElement(el);
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
itemsChanged(oldValue, newValue) {
|
|
213
|
+
// only update children after the component is connected and
|
|
214
|
+
// the setItems has run on connectedCallback
|
|
215
|
+
// (menuItems is undefined until then)
|
|
216
|
+
if (this.$fastController.isConnected && this.menuItems !== undefined) {
|
|
217
|
+
this.setItems();
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* @internal
|
|
222
|
+
*/
|
|
223
|
+
connectedCallback() {
|
|
224
|
+
super.connectedCallback();
|
|
225
|
+
DOM.queueUpdate(() => {
|
|
226
|
+
// wait until children have had a chance to
|
|
227
|
+
// connect before setting/checking their props/attributes
|
|
228
|
+
this.setItems();
|
|
229
|
+
});
|
|
230
|
+
this.addEventListener("change", this.changeHandler);
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* @internal
|
|
234
|
+
*/
|
|
235
|
+
disconnectedCallback() {
|
|
236
|
+
super.disconnectedCallback();
|
|
237
|
+
this.removeItemListeners();
|
|
238
|
+
this.menuItems = undefined;
|
|
239
|
+
this.removeEventListener("change", this.changeHandler);
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Focuses the first item in the menu.
|
|
243
|
+
*
|
|
244
|
+
* @public
|
|
245
|
+
*/
|
|
246
|
+
focus() {
|
|
247
|
+
this.setFocus(0, 1);
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Collapses any expanded menu items.
|
|
251
|
+
*
|
|
252
|
+
* @public
|
|
253
|
+
*/
|
|
254
|
+
collapseExpandedItem() {
|
|
255
|
+
if (this.expandedItem !== null) {
|
|
256
|
+
this.expandedItem.expanded = false;
|
|
257
|
+
this.expandedItem = null;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* @internal
|
|
262
|
+
*/
|
|
263
|
+
handleMenuKeyDown(e) {
|
|
264
|
+
if (e.defaultPrevented || this.menuItems === undefined) {
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
switch (e.key) {
|
|
268
|
+
case keyArrowDown:
|
|
269
|
+
// go forward one index
|
|
270
|
+
this.setFocus(this.focusIndex + 1, 1);
|
|
271
|
+
return;
|
|
272
|
+
case keyArrowUp:
|
|
273
|
+
// go back one index
|
|
274
|
+
this.setFocus(this.focusIndex - 1, -1);
|
|
275
|
+
return;
|
|
276
|
+
case keyEnd:
|
|
277
|
+
// set focus on last item
|
|
278
|
+
this.setFocus(this.menuItems.length - 1, -1);
|
|
279
|
+
return;
|
|
280
|
+
case keyHome:
|
|
281
|
+
// set focus on first item
|
|
282
|
+
this.setFocus(0, 1);
|
|
283
|
+
return;
|
|
284
|
+
default:
|
|
285
|
+
// if we are not handling the event, do not prevent default
|
|
286
|
+
return true;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* get an array of valid DOM children
|
|
291
|
+
*/
|
|
292
|
+
domChildren() {
|
|
293
|
+
return Array.from(this.children).filter(child => !child.hasAttribute("hidden"));
|
|
294
|
+
}
|
|
295
|
+
setFocus(focusIndex, adjustment) {
|
|
296
|
+
if (this.menuItems === undefined) {
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
while (focusIndex >= 0 && focusIndex < this.menuItems.length) {
|
|
300
|
+
const child = this.menuItems[focusIndex];
|
|
301
|
+
if (this.isFocusableElement(child)) {
|
|
302
|
+
// change the previous index to -1
|
|
303
|
+
if (this.focusIndex > -1 &&
|
|
304
|
+
this.menuItems.length >= this.focusIndex - 1) {
|
|
305
|
+
this.menuItems[this.focusIndex].setAttribute("tabindex", "-1");
|
|
306
|
+
}
|
|
307
|
+
// update the focus index
|
|
308
|
+
this.focusIndex = focusIndex;
|
|
309
|
+
// update the tabindex of next focusable element
|
|
310
|
+
child.setAttribute("tabindex", "0");
|
|
311
|
+
// focus the element
|
|
312
|
+
child.focus();
|
|
313
|
+
break;
|
|
314
|
+
}
|
|
315
|
+
focusIndex += adjustment;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
Menu$1.focusableElementRoles = roleForMenuItem;
|
|
320
|
+
__decorate([
|
|
321
|
+
observable
|
|
322
|
+
], Menu$1.prototype, "items", void 0);
|
|
323
|
+
|
|
324
|
+
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}";
|
|
325
|
+
|
|
326
|
+
class Menu extends Menu$1 {
|
|
327
|
+
constructor() {
|
|
328
|
+
super(...arguments);
|
|
329
|
+
this.open = false;
|
|
330
|
+
this.popupOpenChanged = () => {
|
|
331
|
+
this.open = this._popup.open;
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
__decorate([attr({
|
|
336
|
+
mode: 'boolean'
|
|
337
|
+
}), __metadata("design:type", Object)], Menu.prototype, "open", void 0);
|
|
338
|
+
__decorate([attr, __metadata("design:type", String)], Menu.prototype, "placement", void 0);
|
|
339
|
+
__decorate([attr, __metadata("design:type", String)], Menu.prototype, "anchor", void 0);
|
|
340
|
+
|
|
341
|
+
let _ = t => t,
|
|
342
|
+
_t;
|
|
343
|
+
const MenuTemplate = context => {
|
|
344
|
+
const popupTag = context.tagFor(Popup);
|
|
345
|
+
return html(_t || (_t = _`
|
|
346
|
+
<template
|
|
347
|
+
slot="${0}"
|
|
348
|
+
>
|
|
349
|
+
<${0}
|
|
350
|
+
:placement=${0}
|
|
351
|
+
:open=${0}
|
|
352
|
+
:anchor=${0}
|
|
353
|
+
@open="${0}"
|
|
354
|
+
@close="${0}"
|
|
355
|
+
${0}
|
|
356
|
+
>
|
|
357
|
+
<div
|
|
358
|
+
class="base"
|
|
359
|
+
role="menu"
|
|
360
|
+
@keydown="${0}"
|
|
361
|
+
@focusout="${0}"
|
|
362
|
+
>
|
|
363
|
+
<slot ${0}></slot>
|
|
364
|
+
</div>
|
|
365
|
+
</${0}>
|
|
366
|
+
</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);
|
|
367
|
+
};
|
|
368
|
+
|
|
369
|
+
const vividMenu = Menu.compose({
|
|
370
|
+
baseName: 'menu',
|
|
371
|
+
template: MenuTemplate,
|
|
372
|
+
styles: css_248z
|
|
373
|
+
});
|
|
374
|
+
designSystem.register(vividMenu());
|
|
375
|
+
|
|
376
|
+
export { vividMenu };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import '../icon/index.js';
|
|
2
|
+
import '../shared/index.js';
|
|
3
|
+
export { v as vividMenuItem } from '../shared/index6.js';
|
|
4
|
+
import '../shared/icon.js';
|
|
5
|
+
import '../shared/export.js';
|
|
6
|
+
import '../shared/iterators.js';
|
|
7
|
+
import '../shared/to-string.js';
|
|
8
|
+
import '../shared/_has.js';
|
|
9
|
+
import '../shared/when.js';
|
|
10
|
+
import '../shared/class-names.js';
|
|
11
|
+
import '../shared/affix.js';
|
|
12
|
+
import '../shared/web.dom-collections.iterator.js';
|
|
13
|
+
import '../shared/object-keys.js';
|
|
14
|
+
import '../shared/start-end.js';
|
|
15
|
+
import '../shared/ref.js';
|
|
16
|
+
import '../shared/direction.js';
|
|
17
|
+
import '../shared/apply-mixins.js';
|
|
18
|
+
import '../shared/key-codes.js';
|
|
19
|
+
import '../shared/focus2.js';
|
|
20
|
+
import '../shared/focus.js';
|
package/nav/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { F as FoundationElement, h as html, d as designSystem } from '../shared/index.js';
|
|
2
|
+
|
|
3
|
+
class Nav extends FoundationElement {}
|
|
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.register(vividNav());
|
|
16
|
+
|
|
17
|
+
export { vividNav };
|