@vonage/vivid 3.48.0 → 3.49.0-preview.1
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.cjs +21 -0
- package/accordion-item/index.cjs +18 -0
- package/action-group/index.cjs +7 -0
- package/alert/index.cjs +30 -0
- package/appearance-ui/index.cjs +96 -0
- package/audio-player/index.cjs +34 -0
- package/avatar/index.cjs +11 -0
- package/badge/index.cjs +14 -0
- package/banner/index.cjs +29 -0
- package/breadcrumb/index.cjs +13 -0
- package/breadcrumb-item/index.cjs +22 -0
- package/button/index.cjs +25 -0
- package/calendar/index.cjs +9 -0
- package/calendar-event/index.cjs +9 -0
- package/card/index.cjs +14 -0
- package/checkbox/index.cjs +21 -0
- package/combobox/index.cjs +39 -0
- package/data-grid/index.cjs +18 -0
- package/date-picker/index.cjs +40 -0
- package/date-range-picker/index.cjs +40 -0
- package/dialog/index.cjs +31 -0
- package/divider/index.cjs +8 -0
- package/elevation/index.cjs +7 -0
- package/empty-state/index.cjs +12 -0
- package/fab/index.cjs +22 -0
- package/file-picker/index.cjs +30 -0
- package/focus/index.cjs +7 -0
- package/header/index.cjs +8 -0
- package/icon/index.cjs +10 -0
- package/index.cjs +296 -0
- package/layout/index.cjs +7 -0
- package/listbox/index.cjs +77 -0
- package/locales/en-GB.cjs +106 -0
- package/locales/en-US.cjs +106 -0
- package/locales/ja-JP.cjs +106 -0
- package/locales/zh-CN.cjs +106 -0
- package/menu/index.cjs +32 -0
- package/menu-item/index.cjs +22 -0
- package/nav/index.cjs +6 -0
- package/nav-disclosure/index.cjs +17 -0
- package/nav-item/index.cjs +22 -0
- package/note/index.cjs +16 -0
- package/number-field/index.cjs +33 -0
- package/option/index.cjs +23 -0
- package/package.json +20 -2
- package/pagination/index.cjs +28 -0
- package/popup/index.cjs +27 -0
- package/progress/index.cjs +9 -0
- package/progress-ring/index.cjs +9 -0
- package/radio/index.cjs +14 -0
- package/radio-group/index.cjs +14 -0
- package/select/index.cjs +38 -0
- package/selectable-box/index.cjs +25 -0
- package/shared/Reflector.cjs +67 -0
- package/shared/_has.cjs +62 -0
- package/shared/affix.cjs +64 -0
- package/shared/affix.js +8 -4
- package/shared/anchor.cjs +90 -0
- package/shared/anchored.cjs +78 -0
- package/shared/apply-mixins.cjs +25 -0
- package/shared/aria-global.cjs +74 -0
- package/shared/aria.cjs +11 -0
- package/shared/aria2.cjs +11 -0
- package/shared/base-progress.cjs +72 -0
- package/shared/breadcrumb-item.cjs +27 -0
- package/shared/button.cjs +202 -0
- package/shared/calendar-event.cjs +41 -0
- package/shared/children.cjs +61 -0
- package/shared/class-names.cjs +17 -0
- package/shared/definition.cjs +165 -0
- package/shared/definition10.cjs +102 -0
- package/shared/definition11.cjs +164 -0
- package/shared/definition11.js +38 -36
- package/shared/definition12.cjs +50 -0
- package/shared/definition13.cjs +779 -0
- package/shared/definition14.cjs +157 -0
- package/shared/definition15.cjs +249 -0
- package/shared/definition16.cjs +746 -0
- package/shared/definition17.cjs +1372 -0
- package/shared/definition18.cjs +175 -0
- package/shared/definition19.cjs +416 -0
- package/shared/definition2.cjs +232 -0
- package/shared/definition20.cjs +278 -0
- package/shared/definition21.cjs +83 -0
- package/shared/definition22.cjs +74 -0
- package/shared/definition23.cjs +106 -0
- package/shared/definition24.cjs +2392 -0
- package/shared/definition25.cjs +75 -0
- package/shared/definition26.cjs +39 -0
- package/shared/definition27.cjs +66 -0
- package/shared/definition28.cjs +849 -0
- package/shared/definition29.cjs +72 -0
- package/shared/definition3.cjs +72 -0
- package/shared/definition30.cjs +98 -0
- package/shared/definition31.cjs +37 -0
- package/shared/definition32.cjs +24 -0
- package/shared/definition33.cjs +64 -0
- package/shared/definition34.cjs +533 -0
- package/shared/definition35.cjs +295 -0
- package/shared/definition36.cjs +219 -0
- package/shared/definition37.cjs +109 -0
- package/shared/definition38.cjs +92 -0
- package/shared/definition39.cjs +448 -0
- package/shared/definition4.cjs +198 -0
- package/shared/definition40.cjs +49 -0
- package/shared/definition41.cjs +694 -0
- package/shared/definition42.cjs +152 -0
- package/shared/definition43.cjs +113 -0
- package/shared/definition44.cjs +607 -0
- package/shared/definition45.cjs +152 -0
- package/shared/definition46.cjs +166 -0
- package/shared/definition47.cjs +35 -0
- package/shared/definition48.cjs +98 -0
- package/shared/definition49.cjs +543 -0
- package/shared/definition5.cjs +199 -0
- package/shared/definition50.cjs +52 -0
- package/shared/definition51.cjs +150 -0
- package/shared/definition52.cjs +304 -0
- package/shared/definition53.cjs +309 -0
- package/shared/definition54.cjs +146 -0
- package/shared/definition55.cjs +128 -0
- package/shared/definition56.cjs +99 -0
- package/shared/definition57.cjs +310 -0
- package/shared/definition58.cjs +20 -0
- package/shared/definition59.cjs +51 -0
- package/shared/definition6.cjs +83 -0
- package/shared/definition60.cjs +1810 -0
- package/shared/definition7.cjs +72 -0
- package/shared/definition8.cjs +152 -0
- package/shared/definition9.cjs +69 -0
- package/shared/dialog-polyfill.esm.cjs +862 -0
- package/shared/direction.cjs +22 -0
- package/shared/dom.cjs +23 -0
- package/shared/enums.cjs +87 -0
- package/shared/focus.cjs +8 -0
- package/shared/focus2.cjs +11 -0
- package/shared/form-associated.cjs +470 -0
- package/shared/icon.cjs +237 -0
- package/shared/index.cjs +5061 -0
- package/shared/index2.cjs +231 -0
- package/shared/key-codes.cjs +115 -0
- package/shared/key-codes2.cjs +14 -0
- package/shared/listbox.cjs +1072 -0
- package/shared/localized.cjs +11 -0
- package/shared/numbers.cjs +38 -0
- package/shared/patterns/affix.d.ts +5 -1
- package/shared/presentationDate.cjs +6192 -0
- package/shared/radio.cjs +153 -0
- package/shared/ref.cjs +43 -0
- package/shared/repeat.cjs +767 -0
- package/shared/select.options.cjs +12 -0
- package/shared/slotted.cjs +123 -0
- package/shared/start-end.cjs +52 -0
- package/shared/strings.cjs +11 -0
- package/shared/text-anchor.cjs +33 -0
- package/shared/text-anchor.template.cjs +48 -0
- package/shared/text-field.cjs +5 -0
- package/shared/text-field2.cjs +228 -0
- package/shared/tree-item.cjs +154 -0
- package/shared/when.cjs +31 -0
- package/side-drawer/index.cjs +8 -0
- package/slider/index.cjs +16 -0
- package/split-button/index.cjs +20 -0
- 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.cjs +15 -0
- package/tab/index.cjs +17 -0
- package/tab-panel/index.cjs +6 -0
- package/tabs/index.cjs +24 -0
- package/tag/index.cjs +17 -0
- package/tag-group/index.cjs +7 -0
- package/text-anchor/index.cjs +24 -0
- package/text-area/index.cjs +25 -0
- package/text-field/index.cjs +27 -0
- package/toggletip/index.cjs +29 -0
- package/tooltip/index.cjs +29 -0
- package/tree-item/index.cjs +22 -0
- package/tree-view/index.cjs +14 -0
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const index = require('./index.cjs');
|
|
4
|
+
const definition = require('./definition60.cjs');
|
|
5
|
+
const anchored = require('./anchored.cjs');
|
|
6
|
+
const when = require('./when.cjs');
|
|
7
|
+
const classNames = require('./class-names.cjs');
|
|
8
|
+
|
|
9
|
+
const styles = ".control{display:inline-block}.content-wrapper{width:var(--toggletip-inline-size, auto);padding:16px}.headline{font:var(--vvd-typography-base-bold)}.action-items{display:flex;justify-content:flex-end;gap:10px}::slotted([slot=action-items]){margin-block-start:16px}\n";
|
|
10
|
+
|
|
11
|
+
var __defProp = Object.defineProperty;
|
|
12
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
14
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
15
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
16
|
+
if (decorator = decorators[i])
|
|
17
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
18
|
+
if (kind && result)
|
|
19
|
+
__defProp(target, key, result);
|
|
20
|
+
return result;
|
|
21
|
+
};
|
|
22
|
+
let Toggletip = class extends index.FoundationElement {
|
|
23
|
+
constructor() {
|
|
24
|
+
super(...arguments);
|
|
25
|
+
this.#ANCHOR_ARIA_LABEL_SUFFIX = " ; Show more information";
|
|
26
|
+
this.alternate = false;
|
|
27
|
+
this.placement = "right";
|
|
28
|
+
this.open = false;
|
|
29
|
+
this.#openIfClosed = () => {
|
|
30
|
+
if (!this.open)
|
|
31
|
+
index.DOM.queueUpdate(() => this.open = true);
|
|
32
|
+
};
|
|
33
|
+
this.#closeOnClickOutside = (e) => {
|
|
34
|
+
if (!this.contains(e.target))
|
|
35
|
+
this.open = false;
|
|
36
|
+
};
|
|
37
|
+
this.#closeOnEscape = (e) => {
|
|
38
|
+
if (e.key === "Escape")
|
|
39
|
+
this.open = false;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
#ANCHOR_ARIA_LABEL_SUFFIX;
|
|
43
|
+
openChanged(oldValue, newValue) {
|
|
44
|
+
if (oldValue === void 0)
|
|
45
|
+
return;
|
|
46
|
+
if (newValue) {
|
|
47
|
+
this.setAttribute("role", "status");
|
|
48
|
+
} else {
|
|
49
|
+
this.removeAttribute("role");
|
|
50
|
+
}
|
|
51
|
+
this.#updateListeners();
|
|
52
|
+
if (this._anchorEl) {
|
|
53
|
+
this.#updateAnchor(this._anchorEl);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
connectedCallback() {
|
|
57
|
+
super.connectedCallback();
|
|
58
|
+
this.#updateListeners();
|
|
59
|
+
}
|
|
60
|
+
disconnectedCallback() {
|
|
61
|
+
super.disconnectedCallback();
|
|
62
|
+
this.#updateListeners();
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* @internal
|
|
66
|
+
*/
|
|
67
|
+
_anchorElChanged(oldValue, newValue) {
|
|
68
|
+
if (oldValue)
|
|
69
|
+
this.#cleanupAnchor(oldValue);
|
|
70
|
+
if (newValue)
|
|
71
|
+
this.#setupAnchor(newValue);
|
|
72
|
+
}
|
|
73
|
+
#setupAnchor(a) {
|
|
74
|
+
a.addEventListener("click", this.#openIfClosed, true);
|
|
75
|
+
a.ariaLabel = (a.ariaLabel ?? "") + this.#ANCHOR_ARIA_LABEL_SUFFIX;
|
|
76
|
+
this.#updateAnchor(a);
|
|
77
|
+
}
|
|
78
|
+
#updateAnchor(a) {
|
|
79
|
+
a.setAttribute("aria-expanded", this.open.toString());
|
|
80
|
+
}
|
|
81
|
+
#cleanupAnchor(a) {
|
|
82
|
+
a.removeEventListener("click", this.#openIfClosed, true);
|
|
83
|
+
if (a.ariaLabel)
|
|
84
|
+
a.ariaLabel = a.ariaLabel.replace(this.#ANCHOR_ARIA_LABEL_SUFFIX, "");
|
|
85
|
+
}
|
|
86
|
+
#openIfClosed;
|
|
87
|
+
#updateListeners() {
|
|
88
|
+
document.removeEventListener("click", this.#closeOnClickOutside);
|
|
89
|
+
document.removeEventListener("keydown", this.#closeOnEscape);
|
|
90
|
+
if (this.open && this.isConnected) {
|
|
91
|
+
document.addEventListener("click", this.#closeOnClickOutside);
|
|
92
|
+
document.addEventListener("keydown", this.#closeOnEscape);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
#closeOnClickOutside;
|
|
96
|
+
#closeOnEscape;
|
|
97
|
+
};
|
|
98
|
+
__decorateClass([
|
|
99
|
+
index.attr
|
|
100
|
+
], Toggletip.prototype, "headline", 2);
|
|
101
|
+
__decorateClass([
|
|
102
|
+
index.attr({ mode: "boolean" })
|
|
103
|
+
], Toggletip.prototype, "alternate", 2);
|
|
104
|
+
__decorateClass([
|
|
105
|
+
index.attr({ mode: "fromView" })
|
|
106
|
+
], Toggletip.prototype, "placement", 2);
|
|
107
|
+
__decorateClass([
|
|
108
|
+
index.attr({ mode: "boolean" })
|
|
109
|
+
], Toggletip.prototype, "open", 2);
|
|
110
|
+
Toggletip = __decorateClass([
|
|
111
|
+
anchored.anchored
|
|
112
|
+
], Toggletip);
|
|
113
|
+
|
|
114
|
+
const getClasses = (_) => classNames.classNames("control");
|
|
115
|
+
const ToggletipTemplate = (context) => {
|
|
116
|
+
const popup = context.tagFor(definition.Popup);
|
|
117
|
+
return index.html`
|
|
118
|
+
<${popup}
|
|
119
|
+
class="${getClasses}"
|
|
120
|
+
arrow
|
|
121
|
+
:anchor="${(x) => x._anchorEl}"
|
|
122
|
+
:open="${(x) => x.open}"
|
|
123
|
+
?alternate="${(x) => !x.alternate}"
|
|
124
|
+
placement="${(x) => x.placement}"
|
|
125
|
+
exportparts="vvd-theme-alternate"
|
|
126
|
+
>
|
|
127
|
+
<div class="content-wrapper">
|
|
128
|
+
${when.when((x) => x.headline, index.html`<header class="headline">${(x) => x.headline}</header>`)}
|
|
129
|
+
<slot></slot>
|
|
130
|
+
<footer class="action-items"><slot name="action-items"></slot></footer>
|
|
131
|
+
</div>
|
|
132
|
+
</${popup}>
|
|
133
|
+
`;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
const toggletipDefinition = Toggletip.compose({
|
|
137
|
+
baseName: "toggletip",
|
|
138
|
+
template: ToggletipTemplate,
|
|
139
|
+
styles
|
|
140
|
+
});
|
|
141
|
+
const toggletipRegistries = [toggletipDefinition(), ...definition.popupRegistries];
|
|
142
|
+
const registerToggletip = index.registerFactory(toggletipRegistries);
|
|
143
|
+
|
|
144
|
+
exports.registerToggletip = registerToggletip;
|
|
145
|
+
exports.toggletipDefinition = toggletipDefinition;
|
|
146
|
+
exports.toggletipRegistries = toggletipRegistries;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const index = require('./index.cjs');
|
|
4
|
+
const definition = require('./definition60.cjs');
|
|
5
|
+
const anchored = require('./anchored.cjs');
|
|
6
|
+
const classNames = require('./class-names.cjs');
|
|
7
|
+
|
|
8
|
+
const styles = ".control{pointer-events:none}.tooltip{width:var(--tooltip-inline-size, auto)}.tooltip-text{padding:8px 12px;color:var(--vvd-color-canvas-text);font:var(--vvd-typography-base-bold)}\n";
|
|
9
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
13
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
14
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
15
|
+
if (decorator = decorators[i])
|
|
16
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
17
|
+
if (kind && result)
|
|
18
|
+
__defProp(target, key, result);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
let Tooltip = class extends index.FoundationElement {
|
|
22
|
+
constructor() {
|
|
23
|
+
super(...arguments);
|
|
24
|
+
this.open = false;
|
|
25
|
+
this.#show = () => {
|
|
26
|
+
this.open = true;
|
|
27
|
+
};
|
|
28
|
+
this.#hide = () => {
|
|
29
|
+
this.open = false;
|
|
30
|
+
};
|
|
31
|
+
this.#closeOnEscape = (e) => {
|
|
32
|
+
if (e.key === "Escape")
|
|
33
|
+
this.#hide();
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
connectedCallback() {
|
|
37
|
+
super.connectedCallback();
|
|
38
|
+
this.#updateListeners();
|
|
39
|
+
}
|
|
40
|
+
disconnectedCallback() {
|
|
41
|
+
super.disconnectedCallback();
|
|
42
|
+
this.#updateListeners();
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* @internal
|
|
46
|
+
*/
|
|
47
|
+
_anchorElChanged(oldValue, newValue) {
|
|
48
|
+
if (oldValue)
|
|
49
|
+
this.#cleanupAnchor(oldValue);
|
|
50
|
+
if (newValue)
|
|
51
|
+
this.#setupAnchor(newValue);
|
|
52
|
+
}
|
|
53
|
+
#setupAnchor(a) {
|
|
54
|
+
a.addEventListener("mouseover", this.#show);
|
|
55
|
+
a.addEventListener("mouseout", this.#hide);
|
|
56
|
+
a.addEventListener("focusin", this.#show);
|
|
57
|
+
a.addEventListener("focusout", this.#hide);
|
|
58
|
+
}
|
|
59
|
+
#cleanupAnchor(a) {
|
|
60
|
+
a.removeEventListener("mouseover", this.#show);
|
|
61
|
+
a.removeEventListener("mouseout", this.#hide);
|
|
62
|
+
a.removeEventListener("focusin", this.#show);
|
|
63
|
+
a.removeEventListener("focusout", this.#hide);
|
|
64
|
+
}
|
|
65
|
+
#show;
|
|
66
|
+
#hide;
|
|
67
|
+
#updateListeners() {
|
|
68
|
+
document.removeEventListener("keydown", this.#closeOnEscape);
|
|
69
|
+
if (this.open && this.isConnected) {
|
|
70
|
+
document.addEventListener("keydown", this.#closeOnEscape);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
#closeOnEscape;
|
|
74
|
+
/**
|
|
75
|
+
* @internal
|
|
76
|
+
*/
|
|
77
|
+
openChanged(oldValue) {
|
|
78
|
+
if (oldValue === void 0)
|
|
79
|
+
return;
|
|
80
|
+
this.#updateListeners();
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
__decorateClass([
|
|
84
|
+
index.attr
|
|
85
|
+
], Tooltip.prototype, "text", 2);
|
|
86
|
+
__decorateClass([
|
|
87
|
+
index.attr({ mode: "fromView" })
|
|
88
|
+
], Tooltip.prototype, "placement", 2);
|
|
89
|
+
__decorateClass([
|
|
90
|
+
index.attr({ mode: "boolean" })
|
|
91
|
+
], Tooltip.prototype, "open", 2);
|
|
92
|
+
Tooltip = __decorateClass([
|
|
93
|
+
anchored.anchored
|
|
94
|
+
], Tooltip);
|
|
95
|
+
|
|
96
|
+
const getClasses = ({
|
|
97
|
+
open
|
|
98
|
+
}) => classNames.classNames(
|
|
99
|
+
"control",
|
|
100
|
+
["open", Boolean(open)]
|
|
101
|
+
);
|
|
102
|
+
const TooltipTemplate = (context) => {
|
|
103
|
+
const popupTag = context.tagFor(definition.Popup);
|
|
104
|
+
return index.html`
|
|
105
|
+
<${popupTag} class="${getClasses}" arrow alternate
|
|
106
|
+
:placement=${(x) => x.placement}
|
|
107
|
+
:anchor="${(x) => x._anchorEl}"
|
|
108
|
+
:open=${(x) => x.open}
|
|
109
|
+
exportparts="vvd-theme-alternate">
|
|
110
|
+
<div class="tooltip" role="tooltip">
|
|
111
|
+
<header part="vvd-theme-alternate" class="tooltip-header">
|
|
112
|
+
<div class="tooltip-text">${(x) => x.text}</div>
|
|
113
|
+
</header>
|
|
114
|
+
</div>
|
|
115
|
+
</${popupTag}>`;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const tooltipDefinition = Tooltip.compose({
|
|
119
|
+
baseName: "tooltip",
|
|
120
|
+
template: TooltipTemplate,
|
|
121
|
+
styles
|
|
122
|
+
});
|
|
123
|
+
const tooltipRegistries = [tooltipDefinition(), ...definition.popupRegistries];
|
|
124
|
+
const registerTooltip = index.registerFactory(tooltipRegistries);
|
|
125
|
+
|
|
126
|
+
exports.registerTooltip = registerTooltip;
|
|
127
|
+
exports.tooltipDefinition = tooltipDefinition;
|
|
128
|
+
exports.tooltipRegistries = tooltipRegistries;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const index = require('./index.cjs');
|
|
4
|
+
const definition = require('./definition26.cjs');
|
|
5
|
+
const definition$1 = require('./definition58.cjs');
|
|
6
|
+
const affix = require('./affix.cjs');
|
|
7
|
+
const treeItem = require('./tree-item.cjs');
|
|
8
|
+
const applyMixins = require('./apply-mixins.cjs');
|
|
9
|
+
const icon = require('./icon.cjs');
|
|
10
|
+
const focus = require('./focus2.cjs');
|
|
11
|
+
const slotted = require('./slotted.cjs');
|
|
12
|
+
const children = require('./children.cjs');
|
|
13
|
+
const when = require('./when.cjs');
|
|
14
|
+
const classNames = require('./class-names.cjs');
|
|
15
|
+
const ref = require('./ref.cjs');
|
|
16
|
+
|
|
17
|
+
const styles = "@supports selector(:focus-visible){:host(:focus-visible){outline:none}}:host([disabled]){cursor:not-allowed}.control{position:relative;display:inline-flex;box-sizing:border-box;align-items:center;background-color:var(--_appearance-color-fill);border-radius:8px;box-shadow:inset 0 0 0 1px var(--_appearance-color-outline);color:var(--_appearance-color-text);font:var(--vvd-typography-base);gap:12px;hyphens:auto;inline-size:100%;min-block-size:calc(1px*(40 + 4*clamp(-1,var(--vvd-size-density, 0),2)));padding-inline:16px;text-decoration:none;vertical-align:middle;word-break:break-word}.control{--_appearance-color-text: var(--_connotation-color-primary);--_appearance-color-fill: transparent;--_appearance-color-outline: transparent}.control:where(:disabled,.disabled){--_appearance-color-text: var(--vvd-color-neutral-300);--_appearance-color-fill: transparent;--_appearance-color-outline: transparent}.control:where(:hover,.hover):where(:not(:disabled,.disabled,.readonly)){--_appearance-color-text: var(--_connotation-color-primary);--_appearance-color-fill: var(--_connotation-color-faint);--_appearance-color-outline: transparent}.control:where(:active,.active):where(:not(:disabled,.disabled)){--_appearance-color-text: var(--_connotation-color-primary);--_appearance-color-fill: var(--_connotation-color-soft);--_appearance-color-outline: transparent}.control:where(.selected,[aria-current]):where(:not(:disabled,.disabled)){--_appearance-color-text: var(--_connotation-color-primary-text);--_appearance-color-fill: var(--_connotation-color-primary);--_appearance-color-outline: transparent}.control:where(.selected,[aria-current]):where(:hover,.hover):where(:not(:disabled,.disabled,.readonly)){--_appearance-color-text: var(--_connotation-color-primary-text);--_appearance-color-fill: var(--_connotation-color-primary-increment);--_appearance-color-outline: transparent}.control{--_connotation-color-primary: var(--vvd-tree-item-accent-primary, var(--vvd-color-canvas-text));--_connotation-color-primary-text: var(--vvd-tree-item-accent-primary-text, var(--vvd-color-canvas));--_connotation-color-primary-increment: var(--vvd-tree-item-accent-primary-increment, var(--vvd-color-neutral-800));--_connotation-color-faint: var(--vvd-tree-item-accent-faint, var(--vvd-color-neutral-50));--_connotation-color-soft: var(--vvd-tree-item-accent-soft, var(--vvd-color-neutral-100))}@supports selector(:focus-visible){.control:focus-visible{outline:none}}@supports (user-select: none){.control{user-select:none}}.control:not(.disabled){cursor:pointer}.control.disabled{pointer-events:none}.control .text{font:var(--vvd-typography-base)}.expandCollapseButton{display:flex;align-items:center;border-radius:8px;font-size:20px}.expandCollapseButton .expandCollapseIcon{margin:4px}.expandCollapseButton:hover{background-color:var(--vvd-color-neutral-100)}.selected .expandCollapseButton:hover{background-color:var(--vvd-color-neutral-700)}.items{display:flex;flex-direction:column;gap:4px;margin-block:4px;padding-inline-start:48px}:host(:not(:focus-visible)) .focus-indicator{display:none}slot[name=icon]{font-size:20px;line-height:1}.control:not(.disabled,.selected) slot[name=icon]{color:var(--vvd-color-neutral-600)}\n";
|
|
18
|
+
|
|
19
|
+
var __defProp = Object.defineProperty;
|
|
20
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
21
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
22
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
23
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
24
|
+
if (decorator = decorators[i])
|
|
25
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
26
|
+
if (kind && result)
|
|
27
|
+
__defProp(target, key, result);
|
|
28
|
+
return result;
|
|
29
|
+
};
|
|
30
|
+
class TreeItem extends treeItem.TreeItem {
|
|
31
|
+
}
|
|
32
|
+
__decorateClass([
|
|
33
|
+
index.attr
|
|
34
|
+
], TreeItem.prototype, "text", 2);
|
|
35
|
+
applyMixins.applyMixins(TreeItem, affix.AffixIcon);
|
|
36
|
+
|
|
37
|
+
const getClasses = ({
|
|
38
|
+
disabled,
|
|
39
|
+
selected
|
|
40
|
+
}) => classNames.classNames(
|
|
41
|
+
"control",
|
|
42
|
+
["disabled", disabled],
|
|
43
|
+
["selected", Boolean(selected)]
|
|
44
|
+
);
|
|
45
|
+
const expandCollapseButton = (context) => {
|
|
46
|
+
const iconTag = context.tagFor(icon.Icon);
|
|
47
|
+
return index.html`
|
|
48
|
+
<div aria-hidden="true"
|
|
49
|
+
class="expandCollapseButton"
|
|
50
|
+
@click="${(x, c) => x.handleExpandCollapseButtonClick(c.event)}"
|
|
51
|
+
${ref.ref("expandCollapseButton")}
|
|
52
|
+
>
|
|
53
|
+
<${iconTag} class="expandCollapseIcon" name="${(x) => x.expanded ? "chevron-down-line" : "chevron-right-line"}"></${iconTag}>
|
|
54
|
+
</div>`;
|
|
55
|
+
};
|
|
56
|
+
const TreeItemTemplate = (context) => {
|
|
57
|
+
const affixIconTemplate = affix.affixIconTemplateFactory(context);
|
|
58
|
+
const focusTemplate = focus.focusTemplateFactory(context);
|
|
59
|
+
return index.html`
|
|
60
|
+
<template
|
|
61
|
+
role="treeitem"
|
|
62
|
+
slot="${(x) => x.isNestedItem() ? "item" : void 0}"
|
|
63
|
+
tabindex="-1"
|
|
64
|
+
aria-expanded="${(x) => x.childItems && x.childItems.length > 0 ? x.expanded : void 0}"
|
|
65
|
+
aria-selected="${(x) => x.selected}"
|
|
66
|
+
aria-disabled="${(x) => x.disabled}"
|
|
67
|
+
@focusin="${(x, c) => x.handleFocus(c.event)}"
|
|
68
|
+
@focusout="${(x, c) => x.handleBlur(c.event)}"
|
|
69
|
+
${children.children({ property: "childItems", filter: slotted.elements(context.tagFor(TreeItem)) })}
|
|
70
|
+
>
|
|
71
|
+
<div class="${getClasses}">
|
|
72
|
+
${() => focusTemplate}
|
|
73
|
+
${when.when((x) => x.childItems && x.childItems.length > 0, expandCollapseButton(context))}
|
|
74
|
+
${(x) => affixIconTemplate(x.icon, affix.IconWrapper.Slot)}
|
|
75
|
+
${(x) => x.text}
|
|
76
|
+
</div>
|
|
77
|
+
${when.when(
|
|
78
|
+
(x) => x.childItems && x.childItems.length > 0 && x.expanded,
|
|
79
|
+
index.html`
|
|
80
|
+
<div role="group" class="items">
|
|
81
|
+
<slot name="item" ${slotted.slotted("items")}></slot>
|
|
82
|
+
</div>`
|
|
83
|
+
)}
|
|
84
|
+
</template>`;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const treeItemDefinition = TreeItem.compose(
|
|
88
|
+
{
|
|
89
|
+
baseName: "tree-item",
|
|
90
|
+
template: TreeItemTemplate,
|
|
91
|
+
styles
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
const treeItemRegistries = [treeItemDefinition(), ...definition.iconRegistries, ...definition$1.focusRegistries];
|
|
95
|
+
const registerTreeItem = index.registerFactory(treeItemRegistries);
|
|
96
|
+
|
|
97
|
+
exports.registerTreeItem = registerTreeItem;
|
|
98
|
+
exports.treeItemDefinition = treeItemDefinition;
|
|
99
|
+
exports.treeItemRegistries = treeItemRegistries;
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const index = require('./index.cjs');
|
|
4
|
+
const treeItem = require('./tree-item.cjs');
|
|
5
|
+
const dom = require('./dom.cjs');
|
|
6
|
+
const keyCodes = require('./key-codes.cjs');
|
|
7
|
+
const ref = require('./ref.cjs');
|
|
8
|
+
const slotted = require('./slotted.cjs');
|
|
9
|
+
const classNames = require('./class-names.cjs');
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A Tree view Custom HTML Element.
|
|
13
|
+
* Implements the {@link https://w3c.github.io/aria-practices/#TreeView | ARIA TreeView }.
|
|
14
|
+
*
|
|
15
|
+
* @slot - The default slot for tree items
|
|
16
|
+
*
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
let TreeView$1 = class TreeView extends index.FoundationElement {
|
|
20
|
+
constructor() {
|
|
21
|
+
super(...arguments);
|
|
22
|
+
/**
|
|
23
|
+
* The tree item that is designated to be in the tab queue.
|
|
24
|
+
*
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
this.currentFocused = null;
|
|
28
|
+
/**
|
|
29
|
+
* Handle focus events
|
|
30
|
+
*
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
33
|
+
this.handleFocus = (e) => {
|
|
34
|
+
if (this.slottedTreeItems.length < 1) {
|
|
35
|
+
// no child items, nothing to do
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (e.target === this) {
|
|
39
|
+
if (this.currentFocused === null) {
|
|
40
|
+
this.currentFocused = this.getValidFocusableItem();
|
|
41
|
+
}
|
|
42
|
+
if (this.currentFocused !== null) {
|
|
43
|
+
treeItem.TreeItem.focusItem(this.currentFocused);
|
|
44
|
+
}
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (this.contains(e.target)) {
|
|
48
|
+
this.setAttribute("tabindex", "-1");
|
|
49
|
+
this.currentFocused = e.target;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Handle blur events
|
|
54
|
+
*
|
|
55
|
+
* @internal
|
|
56
|
+
*/
|
|
57
|
+
this.handleBlur = (e) => {
|
|
58
|
+
if (e.target instanceof HTMLElement &&
|
|
59
|
+
(e.relatedTarget === null || !this.contains(e.relatedTarget))) {
|
|
60
|
+
this.setAttribute("tabindex", "0");
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* KeyDown handler
|
|
65
|
+
*
|
|
66
|
+
* @internal
|
|
67
|
+
*/
|
|
68
|
+
this.handleKeyDown = (e) => {
|
|
69
|
+
if (e.defaultPrevented) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (this.slottedTreeItems.length < 1) {
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
const treeItems = this.getVisibleNodes();
|
|
76
|
+
switch (e.key) {
|
|
77
|
+
case keyCodes.keyHome:
|
|
78
|
+
if (treeItems.length) {
|
|
79
|
+
treeItem.TreeItem.focusItem(treeItems[0]);
|
|
80
|
+
}
|
|
81
|
+
return;
|
|
82
|
+
case keyCodes.keyEnd:
|
|
83
|
+
if (treeItems.length) {
|
|
84
|
+
treeItem.TreeItem.focusItem(treeItems[treeItems.length - 1]);
|
|
85
|
+
}
|
|
86
|
+
return;
|
|
87
|
+
case keyCodes.keyArrowLeft:
|
|
88
|
+
if (e.target && this.isFocusableElement(e.target)) {
|
|
89
|
+
const item = e.target;
|
|
90
|
+
if (item instanceof treeItem.TreeItem &&
|
|
91
|
+
item.childItemLength() > 0 &&
|
|
92
|
+
item.expanded) {
|
|
93
|
+
item.expanded = false;
|
|
94
|
+
}
|
|
95
|
+
else if (item instanceof treeItem.TreeItem &&
|
|
96
|
+
item.parentElement instanceof treeItem.TreeItem) {
|
|
97
|
+
treeItem.TreeItem.focusItem(item.parentElement);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return false;
|
|
101
|
+
case keyCodes.keyArrowRight:
|
|
102
|
+
if (e.target && this.isFocusableElement(e.target)) {
|
|
103
|
+
const item = e.target;
|
|
104
|
+
if (item instanceof treeItem.TreeItem &&
|
|
105
|
+
item.childItemLength() > 0 &&
|
|
106
|
+
!item.expanded) {
|
|
107
|
+
item.expanded = true;
|
|
108
|
+
}
|
|
109
|
+
else if (item instanceof treeItem.TreeItem && item.childItemLength() > 0) {
|
|
110
|
+
this.focusNextNode(1, e.target);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return;
|
|
114
|
+
case keyCodes.keyArrowDown:
|
|
115
|
+
if (e.target && this.isFocusableElement(e.target)) {
|
|
116
|
+
this.focusNextNode(1, e.target);
|
|
117
|
+
}
|
|
118
|
+
return;
|
|
119
|
+
case keyCodes.keyArrowUp:
|
|
120
|
+
if (e.target && this.isFocusableElement(e.target)) {
|
|
121
|
+
this.focusNextNode(-1, e.target);
|
|
122
|
+
}
|
|
123
|
+
return;
|
|
124
|
+
case keyCodes.keyEnter:
|
|
125
|
+
// In single-select trees where selection does not follow focus (see note below),
|
|
126
|
+
// the default action is typically to select the focused node.
|
|
127
|
+
this.handleClick(e);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
// don't prevent default if we took no action
|
|
131
|
+
return true;
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* Handles the selected-changed events bubbling up
|
|
135
|
+
* from child tree items
|
|
136
|
+
*
|
|
137
|
+
* @internal
|
|
138
|
+
*/
|
|
139
|
+
this.handleSelectedChange = (e) => {
|
|
140
|
+
if (e.defaultPrevented) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
if (!(e.target instanceof Element) || !treeItem.isTreeItemElement(e.target)) {
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
const item = e.target;
|
|
147
|
+
if (item.selected) {
|
|
148
|
+
if (this.currentSelected && this.currentSelected !== item) {
|
|
149
|
+
this.currentSelected.selected = false;
|
|
150
|
+
}
|
|
151
|
+
// new selected item
|
|
152
|
+
this.currentSelected = item;
|
|
153
|
+
}
|
|
154
|
+
else if (!item.selected && this.currentSelected === item) {
|
|
155
|
+
// selected item deselected
|
|
156
|
+
this.currentSelected = null;
|
|
157
|
+
}
|
|
158
|
+
return;
|
|
159
|
+
};
|
|
160
|
+
/**
|
|
161
|
+
* Updates the tree view when slottedTreeItems changes
|
|
162
|
+
*/
|
|
163
|
+
this.setItems = () => {
|
|
164
|
+
// force single selection
|
|
165
|
+
// defaults to first one found
|
|
166
|
+
const selectedItem = this.treeView.querySelector("[aria-selected='true']");
|
|
167
|
+
this.currentSelected = selectedItem;
|
|
168
|
+
// invalidate the current focused item if it is no longer valid
|
|
169
|
+
if (this.currentFocused === null || !this.contains(this.currentFocused)) {
|
|
170
|
+
this.currentFocused = this.getValidFocusableItem();
|
|
171
|
+
}
|
|
172
|
+
// toggle properties on child elements
|
|
173
|
+
this.nested = this.checkForNestedItems();
|
|
174
|
+
const treeItems = this.getVisibleNodes();
|
|
175
|
+
treeItems.forEach(node => {
|
|
176
|
+
if (treeItem.isTreeItemElement(node)) {
|
|
177
|
+
node.nested = this.nested;
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
};
|
|
181
|
+
/**
|
|
182
|
+
* check if the item is focusable
|
|
183
|
+
*/
|
|
184
|
+
this.isFocusableElement = (el) => {
|
|
185
|
+
return treeItem.isTreeItemElement(el);
|
|
186
|
+
};
|
|
187
|
+
this.isSelectedElement = (el) => {
|
|
188
|
+
return el.selected;
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
slottedTreeItemsChanged() {
|
|
192
|
+
if (this.$fastController.isConnected) {
|
|
193
|
+
// update for slotted children change
|
|
194
|
+
this.setItems();
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
connectedCallback() {
|
|
198
|
+
super.connectedCallback();
|
|
199
|
+
this.setAttribute("tabindex", "0");
|
|
200
|
+
index.DOM.queueUpdate(() => {
|
|
201
|
+
this.setItems();
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Handles click events bubbling up
|
|
206
|
+
*
|
|
207
|
+
* @internal
|
|
208
|
+
*/
|
|
209
|
+
handleClick(e) {
|
|
210
|
+
if (e.defaultPrevented) {
|
|
211
|
+
// handled, do nothing
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
if (!(e.target instanceof Element) || !treeItem.isTreeItemElement(e.target)) {
|
|
215
|
+
// not a tree item, ignore
|
|
216
|
+
return true;
|
|
217
|
+
}
|
|
218
|
+
const item = e.target;
|
|
219
|
+
if (!item.disabled) {
|
|
220
|
+
item.selected = !item.selected;
|
|
221
|
+
}
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Move focus to a tree item based on its offset from the provided item
|
|
226
|
+
*/
|
|
227
|
+
focusNextNode(delta, item) {
|
|
228
|
+
const visibleNodes = this.getVisibleNodes();
|
|
229
|
+
if (!visibleNodes) {
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
const focusItem = visibleNodes[visibleNodes.indexOf(item) + delta];
|
|
233
|
+
if (dom.isHTMLElement(focusItem)) {
|
|
234
|
+
treeItem.TreeItem.focusItem(focusItem);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* checks if there are any nested tree items
|
|
239
|
+
*/
|
|
240
|
+
getValidFocusableItem() {
|
|
241
|
+
const treeItems = this.getVisibleNodes();
|
|
242
|
+
// default to selected element if there is one
|
|
243
|
+
let focusIndex = treeItems.findIndex(this.isSelectedElement);
|
|
244
|
+
if (focusIndex === -1) {
|
|
245
|
+
// otherwise first focusable tree item
|
|
246
|
+
focusIndex = treeItems.findIndex(this.isFocusableElement);
|
|
247
|
+
}
|
|
248
|
+
if (focusIndex !== -1) {
|
|
249
|
+
return treeItems[focusIndex];
|
|
250
|
+
}
|
|
251
|
+
return null;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* checks if there are any nested tree items
|
|
255
|
+
*/
|
|
256
|
+
checkForNestedItems() {
|
|
257
|
+
return this.slottedTreeItems.some((node) => {
|
|
258
|
+
return treeItem.isTreeItemElement(node) && node.querySelector("[role='treeitem']");
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
getVisibleNodes() {
|
|
262
|
+
return dom.getDisplayedNodes(this, "[role='treeitem']") || [];
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
index.__decorate([
|
|
266
|
+
index.attr({ attribute: "render-collapsed-nodes" })
|
|
267
|
+
], TreeView$1.prototype, "renderCollapsedNodes", void 0);
|
|
268
|
+
index.__decorate([
|
|
269
|
+
index.observable
|
|
270
|
+
], TreeView$1.prototype, "currentSelected", void 0);
|
|
271
|
+
index.__decorate([
|
|
272
|
+
index.observable
|
|
273
|
+
], TreeView$1.prototype, "slottedTreeItems", void 0);
|
|
274
|
+
|
|
275
|
+
const styles = ".control{position:relative;display:flex;flex-direction:column;gap:4px}\n";
|
|
276
|
+
|
|
277
|
+
class TreeView extends TreeView$1 {
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
const getClasses = (_) => classNames.classNames("control");
|
|
281
|
+
const TreeViewTemplate = () => {
|
|
282
|
+
return index.html`
|
|
283
|
+
<template
|
|
284
|
+
role="tree"
|
|
285
|
+
${ref.ref("treeView")}
|
|
286
|
+
@keydown="${(x, c) => x.handleKeyDown(c.event)}"
|
|
287
|
+
@focusin="${(x, c) => x.handleFocus(c.event)}"
|
|
288
|
+
@focusout="${(x, c) => x.handleBlur(c.event)}"
|
|
289
|
+
@click="${(x, c) => x.handleClick(c.event)}"
|
|
290
|
+
@selected-change="${(x, c) => x.handleSelectedChange(c.event)}"
|
|
291
|
+
>
|
|
292
|
+
<div class="${getClasses}">
|
|
293
|
+
<slot ${slotted.slotted("slottedTreeItems")}></slot>
|
|
294
|
+
</div>
|
|
295
|
+
</template>`;
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
const treeViewDefinition = TreeView.compose(
|
|
299
|
+
{
|
|
300
|
+
baseName: "tree-view",
|
|
301
|
+
template: TreeViewTemplate,
|
|
302
|
+
styles
|
|
303
|
+
}
|
|
304
|
+
);
|
|
305
|
+
const treeViewRegistries = [treeViewDefinition()];
|
|
306
|
+
const registerTreeView = index.registerFactory(treeViewRegistries);
|
|
307
|
+
|
|
308
|
+
exports.registerTreeView = registerTreeView;
|
|
309
|
+
exports.treeViewDefinition = treeViewDefinition;
|
|
310
|
+
exports.treeViewRegistries = treeViewRegistries;
|