@vonage/vivid 4.14.1 → 4.14.3
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/custom-elements.json +393 -201
- package/index.cjs +1 -0
- package/index.js +1 -1
- package/lib/accordion/definition.d.ts +5 -1
- package/lib/combobox/combobox.d.ts +5 -1
- package/lib/divider/divider.d.ts +1 -1
- package/lib/divider/divider.template.d.ts +1 -1
- package/lib/file-picker/file-picker.d.ts +1 -0
- package/lib/menu-item/definition.d.ts +1 -1
- package/lib/menu-item/menu-item-role.d.ts +7 -0
- package/lib/menu-item/menu-item.d.ts +1 -7
- package/lib/number-field/number-field.d.ts +1 -1
- package/lib/radio/radio.d.ts +2 -2
- package/lib/searchable-select/option-tag.d.ts +2 -2
- package/lib/select/select.form-associated.d.ts +1 -1
- package/lib/switch/switch.d.ts +1 -0
- package/lib/tabs/tabs.d.ts +5 -1
- package/lib/text-anchor/text-anchor.d.ts +1 -1
- package/lib/tree-item/tree-item.d.ts +1 -1
- package/lib/tree-view/tree-view.d.ts +1 -1
- package/package.json +1 -1
- package/shared/affix.js +1 -1
- package/shared/applyMixinsWithObservables.cjs +1 -1
- package/shared/applyMixinsWithObservables.js +1 -1
- package/shared/definition.js +1 -1
- package/shared/definition11.cjs +1 -1
- package/shared/definition11.js +2 -2
- package/shared/definition16.cjs +64 -32
- package/shared/definition16.js +62 -30
- package/shared/definition17.cjs +9 -7
- package/shared/definition17.js +9 -7
- package/shared/definition2.cjs +9 -4
- package/shared/definition2.js +9 -5
- package/shared/definition22.cjs +2 -1
- package/shared/definition22.js +2 -1
- package/shared/definition24.js +1 -1
- package/shared/definition25.cjs +25 -18
- package/shared/definition25.js +26 -19
- package/shared/definition27.cjs +1 -1
- package/shared/definition27.js +1 -1
- package/shared/definition29.cjs +12 -30
- package/shared/definition29.js +13 -31
- package/shared/definition30.js +1 -1
- package/shared/definition31.js +1 -1
- package/shared/definition33.cjs +1 -1
- package/shared/definition33.js +2 -2
- package/shared/definition34.cjs +7 -228
- package/shared/definition34.js +5 -226
- package/shared/definition35.cjs +2 -201
- package/shared/definition35.js +4 -201
- package/shared/definition4.js +1 -1
- package/shared/definition41.cjs +1 -1
- package/shared/definition41.js +1 -1
- package/shared/definition42.cjs +2 -3
- package/shared/definition42.js +3 -4
- package/shared/definition43.cjs +10 -11
- package/shared/definition43.js +6 -7
- package/shared/definition46.cjs +2 -2
- package/shared/definition46.js +3 -3
- package/shared/definition47.js +1 -1
- package/shared/definition48.cjs +22 -15
- package/shared/definition48.js +22 -15
- package/shared/definition5.cjs +3 -2
- package/shared/definition5.js +3 -2
- package/shared/definition50.js +1 -1
- package/shared/definition51.cjs +14 -383
- package/shared/definition51.js +17 -386
- package/shared/definition53.js +1 -1
- package/shared/definition54.js +1 -1
- package/shared/definition56.js +1 -1
- package/shared/definition59.js +1 -1
- package/shared/definition7.js +1 -1
- package/shared/definition8.js +1 -1
- package/shared/direction.cjs +2 -16
- package/shared/direction.js +3 -17
- package/shared/foundation/utilities/direction.d.ts +2 -0
- package/shared/listbox.cjs +25 -6
- package/shared/listbox.js +22 -3
- package/shared/option.cjs +205 -0
- package/shared/option.js +202 -0
- package/shared/text-anchor.cjs +1 -1
- package/shared/text-anchor.js +2 -2
- package/shared/text-field2.js +2 -2
- package/shared/vivid-element.cjs +0 -2
- package/shared/vivid-element.js +1 -1
- 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/vivid.api.json +70 -3
- package/lib/listbox/definition.d.ts +0 -2
- package/lib/listbox/listbox.d.ts +0 -14
- package/lib/listbox/listbox.template.d.ts +0 -2
- package/listbox/index.cjs +0 -54
- package/listbox/index.js +0 -52
- package/shared/apply-mixins2.cjs +0 -25
- package/shared/apply-mixins2.js +0 -23
- package/shared/aria-global2.cjs +0 -75
- package/shared/aria-global2.js +0 -73
- package/shared/form-associated2.cjs +0 -383
- package/shared/form-associated2.js +0 -381
- package/shared/key-codes2.cjs +0 -1565
- package/shared/key-codes2.js +0 -1551
- package/shared/listbox2.cjs +0 -1267
- package/shared/listbox2.js +0 -1264
- package/shared/strings2.cjs +0 -37
- package/shared/strings2.js +0 -33
package/shared/definition48.js
CHANGED
|
@@ -28,6 +28,7 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
28
28
|
class Switch extends FormAssociatedSwitch {
|
|
29
29
|
constructor() {
|
|
30
30
|
super();
|
|
31
|
+
this.ariaLabel = null;
|
|
31
32
|
/**
|
|
32
33
|
* The element's value to be included in form submission when checked.
|
|
33
34
|
* Default to "on" to reach parity with input[type="checkbox"]
|
|
@@ -77,6 +78,9 @@ class Switch extends FormAssociatedSwitch {
|
|
|
77
78
|
this.setFormValue(value, value);
|
|
78
79
|
}
|
|
79
80
|
}
|
|
81
|
+
__decorateClass([
|
|
82
|
+
attr({ attribute: "aria-label" })
|
|
83
|
+
], Switch.prototype, "ariaLabel");
|
|
80
84
|
__decorateClass([
|
|
81
85
|
attr
|
|
82
86
|
], Switch.prototype, "label");
|
|
@@ -102,24 +106,27 @@ const getClasses = (_) => classNames(
|
|
|
102
106
|
]
|
|
103
107
|
);
|
|
104
108
|
const SwitchTemplate = html`
|
|
105
|
-
<
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
109
|
+
<template role="${(x) => x.ariaLabel ? "presentation" : null}">
|
|
110
|
+
<div
|
|
111
|
+
class="${getClasses}"
|
|
112
|
+
role="switch"
|
|
113
|
+
aria-label="${(x) => x.ariaLabel}"
|
|
114
|
+
aria-checked="${(x) => x.checked}"
|
|
115
|
+
aria-disabled="${(x) => x.disabled}"
|
|
116
|
+
aria-readonly="${(x) => x.readOnly}"
|
|
117
|
+
tabindex="${(x) => x.disabled ? null : 0}"
|
|
118
|
+
@keypress="${(x, c) => x.keypressHandler(c.event)}"
|
|
119
|
+
@click="${(x) => x.clickHandler()}"
|
|
120
|
+
>
|
|
121
|
+
<div class="switch">
|
|
122
|
+
<span class="checked-indicator"></span>
|
|
123
|
+
</div>
|
|
124
|
+
${when(
|
|
119
125
|
(x) => x.label,
|
|
120
126
|
html`<div class="label">${(x) => x.label}</div>`
|
|
121
127
|
)}
|
|
122
|
-
|
|
128
|
+
</div>
|
|
129
|
+
</template>
|
|
123
130
|
`;
|
|
124
131
|
|
|
125
132
|
const switchDefinition = defineVividComponent(
|
package/shared/definition5.cjs
CHANGED
|
@@ -12,7 +12,7 @@ const when = require('./when.cjs');
|
|
|
12
12
|
const repeat = require('./repeat.cjs');
|
|
13
13
|
const classNames = require('./class-names.cjs');
|
|
14
14
|
|
|
15
|
-
const styles = ":host{display:block}.wrapper{container-type:inline-size}.base{display:inline-flex;box-sizing:border-box;align-items:center;padding:8px;color:var(--vvd-color-canvas-text);gap:
|
|
15
|
+
const styles = ":host{display:block}.wrapper{container-type:inline-size}.base{display:inline-flex;box-sizing:border-box;align-items:center;padding:8px;color:var(--vvd-color-canvas-text);gap:8px;inline-size:100%;user-select:none}.base.disabled{color:var(--vvd-color-neutral-300)}.base .slider{flex:1;grid-area:slider}.base .controls{display:flex;align-items:center;justify-content:center;gap:8px;grid-area:controls}.base .time-stamp{display:inline-flex}.base .time-stamp .current-time,.base .time-stamp .total-time{margin-inline:6px;min-inline-size:32px}.base .playback-button{grid-area:playback}@container (max-width: 500px){.base.two-lines{display:inline-grid;grid-template:auto auto/1fr;grid-template-areas:\"slider\" \"controls\";inline-size:100%;row-gap:4px}.base.two-lines .time-stamp{margin-inline:auto 2px}.base.two-lines.playback{grid-template-areas:\"slider slider\" \"controls playback\";grid-template-columns:1fr auto}.base.two-lines.playback .time-stamp{margin-inline:auto}.base .slider{box-sizing:border-box;min-inline-size:auto;padding-inline:2px}}";
|
|
16
16
|
|
|
17
17
|
var __defProp = Object.defineProperty;
|
|
18
18
|
var __decorateClass = (decorators, target, key, kind) => {
|
|
@@ -282,7 +282,8 @@ function renderSlider(context) {
|
|
|
282
282
|
max="100"
|
|
283
283
|
ariaValuetext="${(x) => formatTime(x.currentTime)}"
|
|
284
284
|
connotation="${(x) => x.connotation}"
|
|
285
|
-
?disabled="${(x) => x.disabled || !x.duration}"
|
|
285
|
+
?disabled="${(x) => x.disabled || !x.duration}"
|
|
286
|
+
internal-part>
|
|
286
287
|
</${sliderTag}>`;
|
|
287
288
|
}
|
|
288
289
|
function renderTimestamp() {
|
package/shared/definition5.js
CHANGED
|
@@ -10,7 +10,7 @@ import { w as when } from './when.js';
|
|
|
10
10
|
import { r as repeat } from './repeat.js';
|
|
11
11
|
import { c as classNames } from './class-names.js';
|
|
12
12
|
|
|
13
|
-
const styles = ":host{display:block}.wrapper{container-type:inline-size}.base{display:inline-flex;box-sizing:border-box;align-items:center;padding:8px;color:var(--vvd-color-canvas-text);gap:
|
|
13
|
+
const styles = ":host{display:block}.wrapper{container-type:inline-size}.base{display:inline-flex;box-sizing:border-box;align-items:center;padding:8px;color:var(--vvd-color-canvas-text);gap:8px;inline-size:100%;user-select:none}.base.disabled{color:var(--vvd-color-neutral-300)}.base .slider{flex:1;grid-area:slider}.base .controls{display:flex;align-items:center;justify-content:center;gap:8px;grid-area:controls}.base .time-stamp{display:inline-flex}.base .time-stamp .current-time,.base .time-stamp .total-time{margin-inline:6px;min-inline-size:32px}.base .playback-button{grid-area:playback}@container (max-width: 500px){.base.two-lines{display:inline-grid;grid-template:auto auto/1fr;grid-template-areas:\"slider\" \"controls\";inline-size:100%;row-gap:4px}.base.two-lines .time-stamp{margin-inline:auto 2px}.base.two-lines.playback{grid-template-areas:\"slider slider\" \"controls playback\";grid-template-columns:1fr auto}.base.two-lines.playback .time-stamp{margin-inline:auto}.base .slider{box-sizing:border-box;min-inline-size:auto;padding-inline:2px}}";
|
|
14
14
|
|
|
15
15
|
var __defProp = Object.defineProperty;
|
|
16
16
|
var __decorateClass = (decorators, target, key, kind) => {
|
|
@@ -280,7 +280,8 @@ function renderSlider(context) {
|
|
|
280
280
|
max="100"
|
|
281
281
|
ariaValuetext="${(x) => formatTime(x.currentTime)}"
|
|
282
282
|
connotation="${(x) => x.connotation}"
|
|
283
|
-
?disabled="${(x) => x.disabled || !x.duration}"
|
|
283
|
+
?disabled="${(x) => x.disabled || !x.duration}"
|
|
284
|
+
internal-part>
|
|
284
285
|
</${sliderTag}>`;
|
|
285
286
|
}
|
|
286
287
|
function renderTimestamp() {
|
package/shared/definition50.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { i as iconDefinition } from './definition27.js';
|
|
2
2
|
import { V as VividElement, a as attr, h as html, d as defineVividComponent, f as createRegisterFunction } from './vivid-element.js';
|
|
3
3
|
import { a as applyMixins } from './apply-mixins.js';
|
|
4
|
-
import {
|
|
4
|
+
import { A as AffixIconWithTrailing, a as affixIconTemplateFactory, I as IconWrapper } from './affix.js';
|
|
5
5
|
import { L as Localized } from './localized.js';
|
|
6
6
|
import { c as classNames } from './class-names.js';
|
|
7
7
|
|
package/shared/definition51.cjs
CHANGED
|
@@ -3,387 +3,14 @@
|
|
|
3
3
|
const definition = require('./definition50.cjs');
|
|
4
4
|
const definition$1 = require('./definition49.cjs');
|
|
5
5
|
const vividElement = require('./vivid-element.cjs');
|
|
6
|
-
const keyCodes
|
|
7
|
-
const
|
|
8
|
-
const applyMixins = require('./apply-mixins2.cjs');
|
|
9
|
-
const strings = require('./strings2.cjs');
|
|
10
|
-
const strings$1 = require('./strings.cjs');
|
|
6
|
+
const keyCodes = require('./key-codes.cjs');
|
|
7
|
+
const strings = require('./strings.cjs');
|
|
11
8
|
const numbers = require('./numbers.cjs');
|
|
12
9
|
const ref = require('./ref.cjs');
|
|
13
10
|
const slotted = require('./slotted.cjs');
|
|
14
11
|
const when = require('./when.cjs');
|
|
15
12
|
const classNames = require('./class-names.cjs');
|
|
16
13
|
|
|
17
|
-
/**
|
|
18
|
-
* The orientation of the {@link @microsoft/fast-foundation#(Tabs:class)} component
|
|
19
|
-
* @public
|
|
20
|
-
*/
|
|
21
|
-
const TabsOrientation = {
|
|
22
|
-
vertical: "vertical",
|
|
23
|
-
horizontal: "horizontal",
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* A Tabs Custom HTML Element.
|
|
27
|
-
* Implements the {@link https://www.w3.org/TR/wai-aria-1.1/#tablist | ARIA tablist }.
|
|
28
|
-
*
|
|
29
|
-
* @slot start - Content which can be provided before the tablist element
|
|
30
|
-
* @slot end - Content which can be provided after the tablist element
|
|
31
|
-
* @slot tab - The slot for tabs
|
|
32
|
-
* @slot tabpanel - The slot for tabpanels
|
|
33
|
-
* @csspart tablist - The element wrapping for the tabs
|
|
34
|
-
* @csspart tab - The tab slot
|
|
35
|
-
* @csspart activeIndicator - The visual indicator
|
|
36
|
-
* @csspart tabpanel - The tabpanel slot
|
|
37
|
-
* @fires change - Fires a custom 'change' event when a tab is clicked or during keyboard navigation
|
|
38
|
-
*
|
|
39
|
-
* @public
|
|
40
|
-
*/
|
|
41
|
-
let Tabs$1 = class Tabs extends keyCodes.FoundationElement {
|
|
42
|
-
constructor() {
|
|
43
|
-
super(...arguments);
|
|
44
|
-
/**
|
|
45
|
-
* The orientation
|
|
46
|
-
* @public
|
|
47
|
-
* @remarks
|
|
48
|
-
* HTML Attribute: orientation
|
|
49
|
-
*/
|
|
50
|
-
this.orientation = TabsOrientation.horizontal;
|
|
51
|
-
/**
|
|
52
|
-
* Whether or not to show the active indicator
|
|
53
|
-
* @public
|
|
54
|
-
* @remarks
|
|
55
|
-
* HTML Attribute: activeindicator
|
|
56
|
-
*/
|
|
57
|
-
this.activeindicator = true;
|
|
58
|
-
/**
|
|
59
|
-
* @internal
|
|
60
|
-
*/
|
|
61
|
-
this.showActiveIndicator = true;
|
|
62
|
-
this.prevActiveTabIndex = 0;
|
|
63
|
-
this.activeTabIndex = 0;
|
|
64
|
-
this.ticking = false;
|
|
65
|
-
this.change = () => {
|
|
66
|
-
this.$emit("change", this.activetab);
|
|
67
|
-
};
|
|
68
|
-
this.isDisabledElement = (el) => {
|
|
69
|
-
return el.getAttribute("aria-disabled") === "true";
|
|
70
|
-
};
|
|
71
|
-
this.isHiddenElement = (el) => {
|
|
72
|
-
return el.hasAttribute("hidden");
|
|
73
|
-
};
|
|
74
|
-
this.isFocusableElement = (el) => {
|
|
75
|
-
return !this.isDisabledElement(el) && !this.isHiddenElement(el);
|
|
76
|
-
};
|
|
77
|
-
this.setTabs = () => {
|
|
78
|
-
const gridHorizontalProperty = "gridColumn";
|
|
79
|
-
const gridVerticalProperty = "gridRow";
|
|
80
|
-
const gridProperty = this.isHorizontal()
|
|
81
|
-
? gridHorizontalProperty
|
|
82
|
-
: gridVerticalProperty;
|
|
83
|
-
this.activeTabIndex = this.getActiveIndex();
|
|
84
|
-
this.showActiveIndicator = false;
|
|
85
|
-
this.tabs.forEach((tab, index) => {
|
|
86
|
-
if (tab.slot === "tab") {
|
|
87
|
-
const isActiveTab = this.activeTabIndex === index && this.isFocusableElement(tab);
|
|
88
|
-
if (this.activeindicator && this.isFocusableElement(tab)) {
|
|
89
|
-
this.showActiveIndicator = true;
|
|
90
|
-
}
|
|
91
|
-
const tabId = this.tabIds[index];
|
|
92
|
-
const tabpanelId = this.tabpanelIds[index];
|
|
93
|
-
tab.setAttribute("id", tabId);
|
|
94
|
-
tab.setAttribute("aria-selected", isActiveTab ? "true" : "false");
|
|
95
|
-
tab.setAttribute("aria-controls", tabpanelId);
|
|
96
|
-
tab.addEventListener("click", this.handleTabClick);
|
|
97
|
-
tab.addEventListener("keydown", this.handleTabKeyDown);
|
|
98
|
-
tab.setAttribute("tabindex", isActiveTab ? "0" : "-1");
|
|
99
|
-
if (isActiveTab) {
|
|
100
|
-
this.activetab = tab;
|
|
101
|
-
this.activeid = tabId;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
// If the original property isn't emptied out,
|
|
105
|
-
// the next set will morph into a grid-area style setting that is not what we want
|
|
106
|
-
tab.style[gridHorizontalProperty] = "";
|
|
107
|
-
tab.style[gridVerticalProperty] = "";
|
|
108
|
-
tab.style[gridProperty] = `${index + 1}`;
|
|
109
|
-
!this.isHorizontal()
|
|
110
|
-
? tab.classList.add("vertical")
|
|
111
|
-
: tab.classList.remove("vertical");
|
|
112
|
-
});
|
|
113
|
-
};
|
|
114
|
-
this.setTabPanels = () => {
|
|
115
|
-
this.tabpanels.forEach((tabpanel, index) => {
|
|
116
|
-
const tabId = this.tabIds[index];
|
|
117
|
-
const tabpanelId = this.tabpanelIds[index];
|
|
118
|
-
tabpanel.setAttribute("id", tabpanelId);
|
|
119
|
-
tabpanel.setAttribute("aria-labelledby", tabId);
|
|
120
|
-
this.activeTabIndex !== index
|
|
121
|
-
? tabpanel.setAttribute("hidden", "")
|
|
122
|
-
: tabpanel.removeAttribute("hidden");
|
|
123
|
-
});
|
|
124
|
-
};
|
|
125
|
-
this.handleTabClick = (event) => {
|
|
126
|
-
const selectedTab = event.currentTarget;
|
|
127
|
-
if (selectedTab.nodeType === 1 && this.isFocusableElement(selectedTab)) {
|
|
128
|
-
this.prevActiveTabIndex = this.activeTabIndex;
|
|
129
|
-
this.activeTabIndex = this.tabs.indexOf(selectedTab);
|
|
130
|
-
this.setComponent();
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
this.handleTabKeyDown = (event) => {
|
|
134
|
-
if (this.isHorizontal()) {
|
|
135
|
-
switch (event.key) {
|
|
136
|
-
case keyCodes.keyArrowLeft:
|
|
137
|
-
event.preventDefault();
|
|
138
|
-
this.adjustBackward(event);
|
|
139
|
-
break;
|
|
140
|
-
case keyCodes.keyArrowRight:
|
|
141
|
-
event.preventDefault();
|
|
142
|
-
this.adjustForward(event);
|
|
143
|
-
break;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
switch (event.key) {
|
|
148
|
-
case keyCodes.keyArrowUp:
|
|
149
|
-
event.preventDefault();
|
|
150
|
-
this.adjustBackward(event);
|
|
151
|
-
break;
|
|
152
|
-
case keyCodes.keyArrowDown:
|
|
153
|
-
event.preventDefault();
|
|
154
|
-
this.adjustForward(event);
|
|
155
|
-
break;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
switch (event.key) {
|
|
159
|
-
case keyCodes.keyHome:
|
|
160
|
-
event.preventDefault();
|
|
161
|
-
this.adjust(-this.activeTabIndex);
|
|
162
|
-
break;
|
|
163
|
-
case keyCodes.keyEnd:
|
|
164
|
-
event.preventDefault();
|
|
165
|
-
this.adjust(this.tabs.length - this.activeTabIndex - 1);
|
|
166
|
-
break;
|
|
167
|
-
}
|
|
168
|
-
};
|
|
169
|
-
this.adjustForward = (e) => {
|
|
170
|
-
const group = this.tabs;
|
|
171
|
-
let index = 0;
|
|
172
|
-
index = this.activetab ? group.indexOf(this.activetab) + 1 : 1;
|
|
173
|
-
if (index === group.length) {
|
|
174
|
-
index = 0;
|
|
175
|
-
}
|
|
176
|
-
while (index < group.length && group.length > 1) {
|
|
177
|
-
if (this.isFocusableElement(group[index])) {
|
|
178
|
-
this.moveToTabByIndex(group, index);
|
|
179
|
-
break;
|
|
180
|
-
}
|
|
181
|
-
else if (this.activetab && index === group.indexOf(this.activetab)) {
|
|
182
|
-
break;
|
|
183
|
-
}
|
|
184
|
-
else if (index + 1 >= group.length) {
|
|
185
|
-
index = 0;
|
|
186
|
-
}
|
|
187
|
-
else {
|
|
188
|
-
index += 1;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
};
|
|
192
|
-
this.adjustBackward = (e) => {
|
|
193
|
-
const group = this.tabs;
|
|
194
|
-
let index = 0;
|
|
195
|
-
index = this.activetab ? group.indexOf(this.activetab) - 1 : 0;
|
|
196
|
-
index = index < 0 ? group.length - 1 : index;
|
|
197
|
-
while (index >= 0 && group.length > 1) {
|
|
198
|
-
if (this.isFocusableElement(group[index])) {
|
|
199
|
-
this.moveToTabByIndex(group, index);
|
|
200
|
-
break;
|
|
201
|
-
}
|
|
202
|
-
else if (index - 1 < 0) {
|
|
203
|
-
index = group.length - 1;
|
|
204
|
-
}
|
|
205
|
-
else {
|
|
206
|
-
index -= 1;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
};
|
|
210
|
-
this.moveToTabByIndex = (group, index) => {
|
|
211
|
-
const tab = group[index];
|
|
212
|
-
this.activetab = tab;
|
|
213
|
-
this.prevActiveTabIndex = this.activeTabIndex;
|
|
214
|
-
this.activeTabIndex = index;
|
|
215
|
-
tab.focus();
|
|
216
|
-
this.setComponent();
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
|
-
/**
|
|
220
|
-
* @internal
|
|
221
|
-
*/
|
|
222
|
-
orientationChanged() {
|
|
223
|
-
if (this.$fastController.isConnected) {
|
|
224
|
-
this.setTabs();
|
|
225
|
-
this.setTabPanels();
|
|
226
|
-
this.handleActiveIndicatorPosition();
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* @internal
|
|
231
|
-
*/
|
|
232
|
-
activeidChanged(oldValue, newValue) {
|
|
233
|
-
if (this.$fastController.isConnected &&
|
|
234
|
-
this.tabs.length <= this.tabpanels.length) {
|
|
235
|
-
this.prevActiveTabIndex = this.tabs.findIndex((item) => item.id === oldValue);
|
|
236
|
-
this.setTabs();
|
|
237
|
-
this.setTabPanels();
|
|
238
|
-
this.handleActiveIndicatorPosition();
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
/**
|
|
242
|
-
* @internal
|
|
243
|
-
*/
|
|
244
|
-
tabsChanged() {
|
|
245
|
-
if (this.$fastController.isConnected &&
|
|
246
|
-
this.tabs.length <= this.tabpanels.length) {
|
|
247
|
-
this.tabIds = this.getTabIds();
|
|
248
|
-
this.tabpanelIds = this.getTabPanelIds();
|
|
249
|
-
this.setTabs();
|
|
250
|
-
this.setTabPanels();
|
|
251
|
-
this.handleActiveIndicatorPosition();
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
/**
|
|
255
|
-
* @internal
|
|
256
|
-
*/
|
|
257
|
-
tabpanelsChanged() {
|
|
258
|
-
if (this.$fastController.isConnected &&
|
|
259
|
-
this.tabpanels.length <= this.tabs.length) {
|
|
260
|
-
this.tabIds = this.getTabIds();
|
|
261
|
-
this.tabpanelIds = this.getTabPanelIds();
|
|
262
|
-
this.setTabs();
|
|
263
|
-
this.setTabPanels();
|
|
264
|
-
this.handleActiveIndicatorPosition();
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
getActiveIndex() {
|
|
268
|
-
const id = this.activeid;
|
|
269
|
-
if (id !== undefined) {
|
|
270
|
-
return this.tabIds.indexOf(this.activeid) === -1
|
|
271
|
-
? 0
|
|
272
|
-
: this.tabIds.indexOf(this.activeid);
|
|
273
|
-
}
|
|
274
|
-
else {
|
|
275
|
-
return 0;
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
getTabIds() {
|
|
279
|
-
return this.tabs.map((tab) => {
|
|
280
|
-
var _a;
|
|
281
|
-
return (_a = tab.getAttribute("id")) !== null && _a !== void 0 ? _a : `tab-${strings.uniqueId()}`;
|
|
282
|
-
});
|
|
283
|
-
}
|
|
284
|
-
getTabPanelIds() {
|
|
285
|
-
return this.tabpanels.map((tabPanel) => {
|
|
286
|
-
var _a;
|
|
287
|
-
return (_a = tabPanel.getAttribute("id")) !== null && _a !== void 0 ? _a : `panel-${strings.uniqueId()}`;
|
|
288
|
-
});
|
|
289
|
-
}
|
|
290
|
-
setComponent() {
|
|
291
|
-
if (this.activeTabIndex !== this.prevActiveTabIndex) {
|
|
292
|
-
this.activeid = this.tabIds[this.activeTabIndex];
|
|
293
|
-
this.focusTab();
|
|
294
|
-
this.change();
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
isHorizontal() {
|
|
298
|
-
return this.orientation === TabsOrientation.horizontal;
|
|
299
|
-
}
|
|
300
|
-
handleActiveIndicatorPosition() {
|
|
301
|
-
// Ignore if we click twice on the same tab
|
|
302
|
-
if (this.showActiveIndicator &&
|
|
303
|
-
this.activeindicator &&
|
|
304
|
-
this.activeTabIndex !== this.prevActiveTabIndex) {
|
|
305
|
-
if (this.ticking) {
|
|
306
|
-
this.ticking = false;
|
|
307
|
-
}
|
|
308
|
-
else {
|
|
309
|
-
this.ticking = true;
|
|
310
|
-
this.animateActiveIndicator();
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
animateActiveIndicator() {
|
|
315
|
-
this.ticking = true;
|
|
316
|
-
const gridProperty = this.isHorizontal() ? "gridColumn" : "gridRow";
|
|
317
|
-
const translateProperty = this.isHorizontal()
|
|
318
|
-
? "translateX"
|
|
319
|
-
: "translateY";
|
|
320
|
-
const offsetProperty = this.isHorizontal() ? "offsetLeft" : "offsetTop";
|
|
321
|
-
const prev = this.activeIndicatorRef[offsetProperty];
|
|
322
|
-
this.activeIndicatorRef.style[gridProperty] = `${this.activeTabIndex + 1}`;
|
|
323
|
-
const next = this.activeIndicatorRef[offsetProperty];
|
|
324
|
-
this.activeIndicatorRef.style[gridProperty] = `${this.prevActiveTabIndex + 1}`;
|
|
325
|
-
const dif = next - prev;
|
|
326
|
-
this.activeIndicatorRef.style.transform = `${translateProperty}(${dif}px)`;
|
|
327
|
-
this.activeIndicatorRef.classList.add("activeIndicatorTransition");
|
|
328
|
-
this.activeIndicatorRef.addEventListener("transitionend", () => {
|
|
329
|
-
this.ticking = false;
|
|
330
|
-
this.activeIndicatorRef.style[gridProperty] = `${this.activeTabIndex + 1}`;
|
|
331
|
-
this.activeIndicatorRef.style.transform = `${translateProperty}(0px)`;
|
|
332
|
-
this.activeIndicatorRef.classList.remove("activeIndicatorTransition");
|
|
333
|
-
});
|
|
334
|
-
}
|
|
335
|
-
/**
|
|
336
|
-
* The adjust method for FASTTabs
|
|
337
|
-
* @public
|
|
338
|
-
* @remarks
|
|
339
|
-
* This method allows the active index to be adjusted by numerical increments
|
|
340
|
-
*/
|
|
341
|
-
adjust(adjustment) {
|
|
342
|
-
const focusableTabs = this.tabs.filter(t => this.isFocusableElement(t));
|
|
343
|
-
const currentActiveTabIndex = focusableTabs.indexOf(this.activetab);
|
|
344
|
-
const nextTabIndex = strings.limit(0, focusableTabs.length - 1, currentActiveTabIndex + adjustment);
|
|
345
|
-
// the index of the next focusable tab within the context of all available tabs
|
|
346
|
-
const nextIndex = this.tabs.indexOf(focusableTabs[nextTabIndex]);
|
|
347
|
-
if (nextIndex > -1) {
|
|
348
|
-
this.moveToTabByIndex(this.tabs, nextIndex);
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
focusTab() {
|
|
352
|
-
this.tabs[this.activeTabIndex].focus();
|
|
353
|
-
}
|
|
354
|
-
/**
|
|
355
|
-
* @internal
|
|
356
|
-
*/
|
|
357
|
-
connectedCallback() {
|
|
358
|
-
super.connectedCallback();
|
|
359
|
-
this.tabIds = this.getTabIds();
|
|
360
|
-
this.tabpanelIds = this.getTabPanelIds();
|
|
361
|
-
this.activeTabIndex = this.getActiveIndex();
|
|
362
|
-
}
|
|
363
|
-
};
|
|
364
|
-
keyCodes.__decorate([
|
|
365
|
-
vividElement.attr
|
|
366
|
-
], Tabs$1.prototype, "orientation", void 0);
|
|
367
|
-
keyCodes.__decorate([
|
|
368
|
-
vividElement.attr
|
|
369
|
-
], Tabs$1.prototype, "activeid", void 0);
|
|
370
|
-
keyCodes.__decorate([
|
|
371
|
-
vividElement.observable
|
|
372
|
-
], Tabs$1.prototype, "tabs", void 0);
|
|
373
|
-
keyCodes.__decorate([
|
|
374
|
-
vividElement.observable
|
|
375
|
-
], Tabs$1.prototype, "tabpanels", void 0);
|
|
376
|
-
keyCodes.__decorate([
|
|
377
|
-
vividElement.attr({ mode: "boolean" })
|
|
378
|
-
], Tabs$1.prototype, "activeindicator", void 0);
|
|
379
|
-
keyCodes.__decorate([
|
|
380
|
-
vividElement.observable
|
|
381
|
-
], Tabs$1.prototype, "activeIndicatorRef", void 0);
|
|
382
|
-
keyCodes.__decorate([
|
|
383
|
-
vividElement.observable
|
|
384
|
-
], Tabs$1.prototype, "showActiveIndicator", void 0);
|
|
385
|
-
applyMixins.applyMixins(Tabs$1, keyCodes.StartEnd);
|
|
386
|
-
|
|
387
14
|
const styles = ":host{display:block}.base{--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: transparent;--_appearance-color-outline: transparent}.base.connotation-cta{--_connotation-color-firm: var(--vvd-tabs-cta-firm, var(--vvd-color-cta-600))}.base:not(.connotation-cta){--_connotation-color-firm: var(--vvd-tabs-accent-firm, var(--vvd-color-canvas-text))}.base{--_tabs-tablist-gutter: 8px;--_tabs-active-indicator-stroke-width: 2px;display:grid;box-sizing:border-box}.base.orientation-vertical{overflow:hidden;block-size:inherit;grid-template-columns:auto 1fr;grid-template-rows:1fr}.base:not(.orientation-vertical){grid-template-columns:1fr;grid-template-rows:auto 1fr;max-block-size:100%}.base.layout-stretch .scroll-shadow{flex:1}.base:not(.orientation-vertical) .scroll-shadow{position:relative;overflow:hidden;isolation:isolate}.base:not(.orientation-vertical) .scroll-shadow.start-scroll:before,.base:not(.orientation-vertical) .scroll-shadow.start-scroll:after,.base:not(.orientation-vertical) .scroll-shadow.end-scroll:before,.base:not(.orientation-vertical) .scroll-shadow.end-scroll:after{position:absolute;content:\"\";inline-size:10px;inset-block:0;opacity:0;transition:opacity .1s}.base:not(.orientation-vertical) .scroll-shadow.start-scroll:before{z-index:1;box-shadow:inset 7px 1px 5px -3px var(--vvd-color-neutral-950);inset-inline-start:0;opacity:.2}.base:not(.orientation-vertical) .scroll-shadow.end-scroll:after{box-shadow:inset -7px 1px 5px -3px var(--vvd-color-neutral-950);inset-inline-end:0;opacity:.2}.tabs{display:flex;overflow:hidden}.base.orientation-vertical .tabs{flex-direction:column;box-shadow:1px 0 0 0 var(--vvd-color-neutral-300)}.base.orientation-horizontal .tabs{flex-direction:row;border-bottom:1px solid var(--vvd-color-neutral-300)}.tablist{position:relative;display:grid;box-sizing:border-box;color:var(--_appearance-color-text)}.base.layout-stretch .tablist{--_tab-justify-content: center;--_tabs-tablist-column: 1fr}.tablist .base:not(.layout-stretch){--_tabs-tablist-column: auto}.base.orientation-vertical .tablist{padding:var(--_tabs-tablist-gutter);grid-row:1/2;grid-template-columns:auto 1fr;grid-template-rows:auto;inline-size:100%;place-self:flex-start end;row-gap:var(--_tabs-tablist-gutter)}.base:not(.orientation-vertical) .tablist{justify-content:flex-start;column-gap:var(--_tabs-tablist-gutter);grid-auto-flow:column;grid-template-rows:auto auto;inline-size:100%;padding-inline:var(--_tabs-tablist-gutter)}.base.has-action-items.orientation-vertical .tablist{padding-block-end:0}.base.has-action-items:not(.orientation-vertical) .tablist{padding-inline-end:0}.tablist-wrapper{--scrollbar-track-color: transparent;--scrollbar-thumb-color: color-mix(in srgb, var(--vvd-color-neutral-950), transparent 70%)}.tablist-wrapper{scrollbar-color:var(--scrollbar-thumb-color) var(--scrollbar-track-color);scrollbar-width:thin}.tablist-wrapper ::-webkit-scrollbar{width:4px}.tablist-wrapper ::-webkit-scrollbar-track{background:var(--scrollbar-track-color)}.tablist-wrapper ::-webkit-scrollbar-thumb{border:0;border-radius:4px;background-color:var(--scrollbar-thumb-color)}.base:not(.orientation-vertical) .tablist-wrapper{overflow:auto hidden;align-self:end;inline-size:100%}.base.orientation-vertical .tablist-wrapper{overflow:hidden auto;block-size:100%}.tablist-wrapper::-webkit-scrollbar{display:none}slot[name=action-items]{display:flex}.base.has-action-items.orientation-horizontal slot[name=action-items]{align-items:center;margin-inline:var(--_tabs-tablist-gutter)}.base.has-action-items.orientation-vertical slot[name=action-items]{margin-block:var(--_tabs-tablist-gutter)}.tabpanel{box-sizing:border-box;block-size:100%;min-block-size:0;min-inline-size:0}.base.scroll .tabpanel{overflow-y:auto;--scrollbar-track-color: transparent;--scrollbar-thumb-color: color-mix(in srgb, var(--vvd-color-neutral-950), transparent 70%)}.base.scroll .tabpanel{scrollbar-color:var(--scrollbar-thumb-color) var(--scrollbar-track-color);scrollbar-width:thin}.base.scroll .tabpanel ::-webkit-scrollbar{width:4px}.base.scroll .tabpanel ::-webkit-scrollbar-track{background:var(--scrollbar-track-color)}.base.scroll .tabpanel ::-webkit-scrollbar-thumb{border:0;border-radius:4px;background-color:var(--scrollbar-thumb-color)}.base.gutters-small .tabpanel{padding:calc(1px*(40 + 4*clamp(-1,var(--vvd-size-density, 0),2)) - (1px*(24 + 4*clamp(-1,var(--vvd-size-density, 0),2))))}.active-indicator{background:currentColor;margin-inline-start:calc(var(--_tabs-tablist-gutter) * -1)}.base.orientation-vertical .active-indicator{align-self:center;border-radius:2px;block-size:80%;grid-area:1/1/auto/auto;inline-size:var(--_tabs-active-indicator-stroke-width)}.base:not(.orientation-vertical) .active-indicator{position:absolute;z-index:1;border-radius:2px;block-size:var(--_tabs-active-indicator-stroke-width);grid-column:1/auto;inline-size:calc(var(--_tabs-active-tab-inline-size));inset-block-end:0;inset-inline-start:8px}.activeIndicatorTransition{transition:transform .2s ease-out 0s,inline-size .2s ease-out 0s}";
|
|
388
15
|
|
|
389
16
|
var __defProp = Object.defineProperty;
|
|
@@ -397,6 +24,10 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
397
24
|
};
|
|
398
25
|
const ACTIVE_TAB_WIDTH = "--_tabs-active-tab-inline-size";
|
|
399
26
|
const TABLIST_COLUMN = "--_tabs-tablist-column";
|
|
27
|
+
const TabsOrientation = {
|
|
28
|
+
vertical: "vertical",
|
|
29
|
+
horizontal: "horizontal"
|
|
30
|
+
};
|
|
400
31
|
class Tabs extends vividElement.VividElement {
|
|
401
32
|
constructor() {
|
|
402
33
|
super(...arguments);
|
|
@@ -488,33 +119,33 @@ class Tabs extends vividElement.VividElement {
|
|
|
488
119
|
this.#handleTabKeyDown = (event) => {
|
|
489
120
|
if (this.#isHorizontal()) {
|
|
490
121
|
switch (event.key) {
|
|
491
|
-
case keyCodes
|
|
122
|
+
case keyCodes.keyArrowLeft:
|
|
492
123
|
event.preventDefault();
|
|
493
124
|
this.adjustBackward(event);
|
|
494
125
|
break;
|
|
495
|
-
case keyCodes
|
|
126
|
+
case keyCodes.keyArrowRight:
|
|
496
127
|
event.preventDefault();
|
|
497
128
|
this.adjustForward(event);
|
|
498
129
|
break;
|
|
499
130
|
}
|
|
500
131
|
} else {
|
|
501
132
|
switch (event.key) {
|
|
502
|
-
case keyCodes
|
|
133
|
+
case keyCodes.keyArrowUp:
|
|
503
134
|
event.preventDefault();
|
|
504
135
|
this.adjustBackward(event);
|
|
505
136
|
break;
|
|
506
|
-
case keyCodes
|
|
137
|
+
case keyCodes.keyArrowDown:
|
|
507
138
|
event.preventDefault();
|
|
508
139
|
this.adjustForward(event);
|
|
509
140
|
break;
|
|
510
141
|
}
|
|
511
142
|
}
|
|
512
143
|
switch (event.key) {
|
|
513
|
-
case keyCodes
|
|
144
|
+
case keyCodes.keyHome:
|
|
514
145
|
event.preventDefault();
|
|
515
146
|
this.adjust(-this.activeTabIndex);
|
|
516
147
|
break;
|
|
517
|
-
case keyCodes
|
|
148
|
+
case keyCodes.keyEnd:
|
|
518
149
|
event.preventDefault();
|
|
519
150
|
this.adjust(this.tabs.length - this.activeTabIndex - 1);
|
|
520
151
|
break;
|
|
@@ -610,12 +241,12 @@ class Tabs extends vividElement.VividElement {
|
|
|
610
241
|
}
|
|
611
242
|
getTabIds() {
|
|
612
243
|
return this.tabs.map((tab) => {
|
|
613
|
-
return tab.getAttribute("id") ?? `tab-${strings
|
|
244
|
+
return tab.getAttribute("id") ?? `tab-${strings.uniqueId()}`;
|
|
614
245
|
});
|
|
615
246
|
}
|
|
616
247
|
getTabPanelIds() {
|
|
617
248
|
return this.tabpanels.map((tabPanel) => {
|
|
618
|
-
return tabPanel.getAttribute("id") ?? `panel-${strings
|
|
249
|
+
return tabPanel.getAttribute("id") ?? `panel-${strings.uniqueId()}`;
|
|
619
250
|
});
|
|
620
251
|
}
|
|
621
252
|
setComponent() {
|