@vonage/vivid 3.9.0 → 3.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/alert/index.js +28 -0
- package/avatar/index.js +1 -1
- package/badge/index.js +1 -1
- package/banner/index.js +3 -3
- package/breadcrumb/index.js +1 -1
- package/breadcrumb-item/index.js +1 -1
- package/button/index.js +2 -2
- package/calendar/index.js +1 -1
- package/calendar-event/index.js +1 -1
- package/card/index.js +2 -2
- package/checkbox/index.js +1 -1
- package/combobox/index.js +6 -6
- package/custom-elements.json +269 -27
- package/data-grid/index.js +1 -1
- package/dialog/index.js +4 -4
- package/divider/index.js +1 -1
- package/elevation/index.js +1 -1
- package/fab/index.js +1 -1
- package/header/index.js +2 -2
- package/index.js +51 -50
- package/layout/index.js +1 -1
- package/lib/alert/alert.d.ts +24 -0
- package/lib/alert/alert.template.d.ts +4 -0
- package/lib/alert/definition.d.ts +2 -0
- package/lib/alert/index.d.ts +1 -0
- package/lib/components.d.ts +1 -0
- package/lib/text-area/text-area.d.ts +2 -1
- package/lib/tooltip/tooltip.d.ts +1 -0
- package/listbox/index.js +2 -2
- package/menu/index.js +6 -6
- package/menu-item/index.js +1 -1
- package/nav/index.js +1 -1
- package/nav-disclosure/index.js +1 -1
- package/nav-item/index.js +1 -1
- package/note/index.js +1 -1
- package/number-field/index.js +4 -4
- package/option/index.js +1 -1
- package/package.json +1 -1
- package/popup/index.js +4 -4
- package/progress/index.js +1 -1
- package/progress-ring/index.js +1 -1
- package/radio/index.js +1 -1
- package/radio-group/index.js +1 -1
- package/select/index.js +6 -6
- package/shared/definition.js +1 -1
- package/shared/definition10.js +46 -63
- package/shared/definition11.js +38 -92
- package/shared/definition12.js +96 -31
- package/shared/definition13.js +84 -757
- package/shared/definition14.js +32 -95
- package/shared/definition15.js +758 -100
- package/shared/definition16.js +103 -24
- package/shared/definition17.js +96 -154
- package/shared/definition18.js +108 -663
- package/shared/definition19.js +667 -1532
- package/shared/definition2.js +1 -1
- package/shared/definition20.js +1544 -223
- package/shared/definition21.js +183 -964
- package/shared/definition22.js +1037 -222
- package/shared/definition23.js +226 -67
- package/shared/definition24.js +68 -77
- package/shared/definition25.js +76 -47
- package/shared/definition26.js +46 -32
- package/shared/definition27.js +35 -49
- package/shared/definition28.js +48 -344
- package/shared/definition29.js +273 -282
- package/shared/definition30.js +356 -14
- package/shared/definition31.js +13 -67
- package/shared/definition32.js +65 -21
- package/shared/definition33.js +21 -39
- package/shared/definition34.js +31 -432
- package/shared/definition35.js +432 -76
- package/shared/definition36.js +82 -33
- package/shared/definition37.js +31 -422
- package/shared/definition38.js +357 -564
- package/shared/definition39.js +628 -75
- package/shared/definition4.js +1 -1
- package/shared/definition40.js +70 -573
- package/shared/definition41.js +538 -81
- package/shared/definition42.js +127 -47
- package/shared/definition43.js +51 -16
- package/shared/definition44.js +17 -425
- package/shared/definition45.js +421 -103
- package/shared/definition46.js +114 -19
- package/shared/definition47.js +19 -269
- package/shared/definition48.js +244 -86
- package/shared/definition49.js +110 -70
- package/shared/definition5.js +1 -1
- package/shared/definition50.js +80 -67
- package/shared/definition51.js +69 -295
- package/shared/definition52.js +305 -0
- package/shared/definition6.js +142 -45
- package/shared/definition7.js +95 -23
- package/shared/definition8.js +22 -103
- package/shared/definition9.js +62 -102
- package/shared/es.object.assign.js +1 -1
- package/shared/form-associated.js +1 -1
- package/shared/form-elements.js +2 -2
- package/shared/index.js +1 -1
- package/shared/listbox.js +2 -2
- package/shared/patterns/form-elements/form-elements.d.ts +4 -4
- package/shared/repeat.js +1 -1
- package/shared/text-field.js +1 -1
- package/shared/text-field2.js +1 -1
- package/side-drawer/index.js +1 -1
- package/slider/index.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/switch/index.js +1 -1
- package/tab/index.js +1 -1
- package/tab-panel/index.js +1 -1
- package/tabs/index.js +3 -3
- package/tag/index.js +1 -1
- package/tag-group/index.js +1 -1
- package/text-area/index.js +1 -1
- package/text-field/index.js +1 -1
- package/tooltip/index.js +5 -5
- package/tree-item/index.js +1 -1
- package/tree-view/index.js +1 -1
- package/vivid.api.json +91 -0
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
import { F as FoundationElement, Y as DOM, _ as __decorate, a as attr, o as observable, h as html, r as registerFactory } from './index.js';
|
|
2
|
+
import { T as TreeItem, i as isTreeItemElement } from './tree-item.js';
|
|
3
|
+
import { i as isHTMLElement, g as getDisplayedNodes } from './dom.js';
|
|
4
|
+
import { d as keyEnter, c as keyArrowUp, b as keyArrowDown, h as keyArrowRight, i as keyArrowLeft, k as keyEnd, a as keyHome } from './key-codes.js';
|
|
5
|
+
import { s as slotted } from './slotted.js';
|
|
6
|
+
import { r as ref } from './ref.js';
|
|
7
|
+
import { c as classNames } from './class-names.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A Tree view Custom HTML Element.
|
|
11
|
+
* Implements the {@link https://w3c.github.io/aria-practices/#TreeView | ARIA TreeView }.
|
|
12
|
+
*
|
|
13
|
+
* @slot - The default slot for tree items
|
|
14
|
+
*
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
class TreeView$1 extends FoundationElement {
|
|
18
|
+
constructor() {
|
|
19
|
+
super(...arguments);
|
|
20
|
+
/**
|
|
21
|
+
* The tree item that is designated to be in the tab queue.
|
|
22
|
+
*
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
25
|
+
this.currentFocused = null;
|
|
26
|
+
/**
|
|
27
|
+
* Handle focus events
|
|
28
|
+
*
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
this.handleFocus = (e) => {
|
|
32
|
+
if (this.slottedTreeItems.length < 1) {
|
|
33
|
+
// no child items, nothing to do
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (e.target === this) {
|
|
37
|
+
if (this.currentFocused === null) {
|
|
38
|
+
this.currentFocused = this.getValidFocusableItem();
|
|
39
|
+
}
|
|
40
|
+
if (this.currentFocused !== null) {
|
|
41
|
+
TreeItem.focusItem(this.currentFocused);
|
|
42
|
+
}
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (this.contains(e.target)) {
|
|
46
|
+
this.setAttribute("tabindex", "-1");
|
|
47
|
+
this.currentFocused = e.target;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Handle blur events
|
|
52
|
+
*
|
|
53
|
+
* @internal
|
|
54
|
+
*/
|
|
55
|
+
this.handleBlur = (e) => {
|
|
56
|
+
if (e.target instanceof HTMLElement &&
|
|
57
|
+
(e.relatedTarget === null || !this.contains(e.relatedTarget))) {
|
|
58
|
+
this.setAttribute("tabindex", "0");
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* KeyDown handler
|
|
63
|
+
*
|
|
64
|
+
* @internal
|
|
65
|
+
*/
|
|
66
|
+
this.handleKeyDown = (e) => {
|
|
67
|
+
if (e.defaultPrevented) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (this.slottedTreeItems.length < 1) {
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
const treeItems = this.getVisibleNodes();
|
|
74
|
+
switch (e.key) {
|
|
75
|
+
case keyHome:
|
|
76
|
+
if (treeItems.length) {
|
|
77
|
+
TreeItem.focusItem(treeItems[0]);
|
|
78
|
+
}
|
|
79
|
+
return;
|
|
80
|
+
case keyEnd:
|
|
81
|
+
if (treeItems.length) {
|
|
82
|
+
TreeItem.focusItem(treeItems[treeItems.length - 1]);
|
|
83
|
+
}
|
|
84
|
+
return;
|
|
85
|
+
case keyArrowLeft:
|
|
86
|
+
if (e.target && this.isFocusableElement(e.target)) {
|
|
87
|
+
const item = e.target;
|
|
88
|
+
if (item instanceof TreeItem &&
|
|
89
|
+
item.childItemLength() > 0 &&
|
|
90
|
+
item.expanded) {
|
|
91
|
+
item.expanded = false;
|
|
92
|
+
}
|
|
93
|
+
else if (item instanceof TreeItem &&
|
|
94
|
+
item.parentElement instanceof TreeItem) {
|
|
95
|
+
TreeItem.focusItem(item.parentElement);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return false;
|
|
99
|
+
case keyArrowRight:
|
|
100
|
+
if (e.target && this.isFocusableElement(e.target)) {
|
|
101
|
+
const item = e.target;
|
|
102
|
+
if (item instanceof TreeItem &&
|
|
103
|
+
item.childItemLength() > 0 &&
|
|
104
|
+
!item.expanded) {
|
|
105
|
+
item.expanded = true;
|
|
106
|
+
}
|
|
107
|
+
else if (item instanceof TreeItem && item.childItemLength() > 0) {
|
|
108
|
+
this.focusNextNode(1, e.target);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return;
|
|
112
|
+
case keyArrowDown:
|
|
113
|
+
if (e.target && this.isFocusableElement(e.target)) {
|
|
114
|
+
this.focusNextNode(1, e.target);
|
|
115
|
+
}
|
|
116
|
+
return;
|
|
117
|
+
case keyArrowUp:
|
|
118
|
+
if (e.target && this.isFocusableElement(e.target)) {
|
|
119
|
+
this.focusNextNode(-1, e.target);
|
|
120
|
+
}
|
|
121
|
+
return;
|
|
122
|
+
case keyEnter:
|
|
123
|
+
// In single-select trees where selection does not follow focus (see note below),
|
|
124
|
+
// the default action is typically to select the focused node.
|
|
125
|
+
this.handleClick(e);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
// don't prevent default if we took no action
|
|
129
|
+
return true;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* Handles the selected-changed events bubbling up
|
|
133
|
+
* from child tree items
|
|
134
|
+
*
|
|
135
|
+
* @internal
|
|
136
|
+
*/
|
|
137
|
+
this.handleSelectedChange = (e) => {
|
|
138
|
+
if (e.defaultPrevented) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
if (!(e.target instanceof Element) || !isTreeItemElement(e.target)) {
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
const item = e.target;
|
|
145
|
+
if (item.selected) {
|
|
146
|
+
if (this.currentSelected && this.currentSelected !== item) {
|
|
147
|
+
this.currentSelected.selected = false;
|
|
148
|
+
}
|
|
149
|
+
// new selected item
|
|
150
|
+
this.currentSelected = item;
|
|
151
|
+
}
|
|
152
|
+
else if (!item.selected && this.currentSelected === item) {
|
|
153
|
+
// selected item deselected
|
|
154
|
+
this.currentSelected = null;
|
|
155
|
+
}
|
|
156
|
+
return;
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* Updates the tree view when slottedTreeItems changes
|
|
160
|
+
*/
|
|
161
|
+
this.setItems = () => {
|
|
162
|
+
// force single selection
|
|
163
|
+
// defaults to first one found
|
|
164
|
+
const selectedItem = this.treeView.querySelector("[aria-selected='true']");
|
|
165
|
+
this.currentSelected = selectedItem;
|
|
166
|
+
// invalidate the current focused item if it is no longer valid
|
|
167
|
+
if (this.currentFocused === null || !this.contains(this.currentFocused)) {
|
|
168
|
+
this.currentFocused = this.getValidFocusableItem();
|
|
169
|
+
}
|
|
170
|
+
// toggle properties on child elements
|
|
171
|
+
this.nested = this.checkForNestedItems();
|
|
172
|
+
const treeItems = this.getVisibleNodes();
|
|
173
|
+
treeItems.forEach(node => {
|
|
174
|
+
if (isTreeItemElement(node)) {
|
|
175
|
+
node.nested = this.nested;
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
};
|
|
179
|
+
/**
|
|
180
|
+
* check if the item is focusable
|
|
181
|
+
*/
|
|
182
|
+
this.isFocusableElement = (el) => {
|
|
183
|
+
return isTreeItemElement(el);
|
|
184
|
+
};
|
|
185
|
+
this.isSelectedElement = (el) => {
|
|
186
|
+
return el.selected;
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
slottedTreeItemsChanged() {
|
|
190
|
+
if (this.$fastController.isConnected) {
|
|
191
|
+
// update for slotted children change
|
|
192
|
+
this.setItems();
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
connectedCallback() {
|
|
196
|
+
super.connectedCallback();
|
|
197
|
+
this.setAttribute("tabindex", "0");
|
|
198
|
+
DOM.queueUpdate(() => {
|
|
199
|
+
this.setItems();
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Handles click events bubbling up
|
|
204
|
+
*
|
|
205
|
+
* @internal
|
|
206
|
+
*/
|
|
207
|
+
handleClick(e) {
|
|
208
|
+
if (e.defaultPrevented) {
|
|
209
|
+
// handled, do nothing
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
if (!(e.target instanceof Element) || !isTreeItemElement(e.target)) {
|
|
213
|
+
// not a tree item, ignore
|
|
214
|
+
return true;
|
|
215
|
+
}
|
|
216
|
+
const item = e.target;
|
|
217
|
+
if (!item.disabled) {
|
|
218
|
+
item.selected = !item.selected;
|
|
219
|
+
}
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Move focus to a tree item based on its offset from the provided item
|
|
224
|
+
*/
|
|
225
|
+
focusNextNode(delta, item) {
|
|
226
|
+
const visibleNodes = this.getVisibleNodes();
|
|
227
|
+
if (!visibleNodes) {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
const focusItem = visibleNodes[visibleNodes.indexOf(item) + delta];
|
|
231
|
+
if (isHTMLElement(focusItem)) {
|
|
232
|
+
TreeItem.focusItem(focusItem);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* checks if there are any nested tree items
|
|
237
|
+
*/
|
|
238
|
+
getValidFocusableItem() {
|
|
239
|
+
const treeItems = this.getVisibleNodes();
|
|
240
|
+
// default to selected element if there is one
|
|
241
|
+
let focusIndex = treeItems.findIndex(this.isSelectedElement);
|
|
242
|
+
if (focusIndex === -1) {
|
|
243
|
+
// otherwise first focusable tree item
|
|
244
|
+
focusIndex = treeItems.findIndex(this.isFocusableElement);
|
|
245
|
+
}
|
|
246
|
+
if (focusIndex !== -1) {
|
|
247
|
+
return treeItems[focusIndex];
|
|
248
|
+
}
|
|
249
|
+
return null;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* checks if there are any nested tree items
|
|
253
|
+
*/
|
|
254
|
+
checkForNestedItems() {
|
|
255
|
+
return this.slottedTreeItems.some((node) => {
|
|
256
|
+
return isTreeItemElement(node) && node.querySelector("[role='treeitem']");
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
getVisibleNodes() {
|
|
260
|
+
return getDisplayedNodes(this, "[role='treeitem']") || [];
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
__decorate([
|
|
264
|
+
attr({ attribute: "render-collapsed-nodes" })
|
|
265
|
+
], TreeView$1.prototype, "renderCollapsedNodes", void 0);
|
|
266
|
+
__decorate([
|
|
267
|
+
observable
|
|
268
|
+
], TreeView$1.prototype, "currentSelected", void 0);
|
|
269
|
+
__decorate([
|
|
270
|
+
observable
|
|
271
|
+
], TreeView$1.prototype, "slottedTreeItems", void 0);
|
|
272
|
+
|
|
273
|
+
var css_248z = ".control {\n position: relative;\n display: flex;\n flex-direction: column;\n gap: 4px;\n}";
|
|
274
|
+
|
|
275
|
+
class TreeView extends TreeView$1 {}
|
|
276
|
+
|
|
277
|
+
let _2 = t => t,
|
|
278
|
+
_t;
|
|
279
|
+
const getClasses = _ => classNames('control');
|
|
280
|
+
const TreeViewTemplate = () => {
|
|
281
|
+
return html(_t || (_t = _2`
|
|
282
|
+
<template
|
|
283
|
+
role="tree"
|
|
284
|
+
${0}
|
|
285
|
+
@keydown="${0}"
|
|
286
|
+
@focusin="${0}"
|
|
287
|
+
@focusout="${0}"
|
|
288
|
+
@click="${0}"
|
|
289
|
+
@selected-change="${0}"
|
|
290
|
+
>
|
|
291
|
+
<div class="${0}">
|
|
292
|
+
<slot ${0}></slot>
|
|
293
|
+
</div>
|
|
294
|
+
</template>`), ref('treeView'), (x, c) => x.handleKeyDown(c.event), (x, c) => x.handleFocus(c.event), (x, c) => x.handleBlur(c.event), (x, c) => x.handleClick(c.event), (x, c) => x.handleSelectedChange(c.event), getClasses, slotted('slottedTreeItems'));
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
const treeViewDefinition = TreeView.compose({
|
|
298
|
+
baseName: 'tree-view',
|
|
299
|
+
template: TreeViewTemplate,
|
|
300
|
+
styles: css_248z
|
|
301
|
+
});
|
|
302
|
+
const treeViewRegistries = [treeViewDefinition()];
|
|
303
|
+
const registerTreeView = registerFactory(treeViewRegistries);
|
|
304
|
+
|
|
305
|
+
export { treeViewRegistries as a, registerTreeView as r, treeViewDefinition as t };
|
package/shared/definition6.js
CHANGED
|
@@ -1,60 +1,157 @@
|
|
|
1
|
-
import { F as FoundationElement, _ as __decorate, a as attr, b as __metadata, h as html, r as registerFactory } from './index.js';
|
|
1
|
+
import { F as FoundationElement, U as __classPrivateFieldGet, _ as __decorate, a as attr, b as __metadata, h as html, r as registerFactory } from './index.js';
|
|
2
|
+
import { b as buttonRegistries } from './definition7.js';
|
|
3
|
+
import { E as Elevation, e as elevationRegistries } from './definition8.js';
|
|
2
4
|
import { i as iconRegistries } from './definition3.js';
|
|
3
|
-
import {
|
|
5
|
+
import { C as Connotation } from './enums.js';
|
|
6
|
+
import { b as AffixIcon, a as affixIconTemplateFactory } from './affix.js';
|
|
7
|
+
import { a as applyMixins } from './apply-mixins.js';
|
|
8
|
+
import './focus.js';
|
|
9
|
+
import './form-elements.js';
|
|
10
|
+
import { B as Button } from './button.js';
|
|
4
11
|
import { w as when } from './when.js';
|
|
5
12
|
import { c as classNames } from './class-names.js';
|
|
6
13
|
|
|
7
|
-
var css_248z = "/**\n * Do not edit directly\n * Generated on
|
|
14
|
+
var css_248z = "/**\n * Do not edit directly\n * Generated on Thu, 27 Apr 2023 09:20:45 GMT\n */\n.control {\n position: fixed;\n z-index: 10;\n border-radius: 6px;\n inline-size: max-content;\n inset-block-end: 0;\n inset-inline-end: 0;\n inset-inline-start: 0;\n margin-block: 16px;\n margin-inline: auto;\n min-inline-size: var(--alert-min-inline-size, 420px);\n transition: opacity 150ms cubic-bezier(0, 0, 0.2, 1) 0ms, transform 150ms cubic-bezier(0, 0, 0.2, 1) 0ms;\n}\n.control.placement-top, .control.placement-top-start, .control.placement-top-end {\n inset-block-end: auto;\n inset-block-start: 0;\n}\n.control.placement-top-start, .control.placement-bottom-start {\n right: auto;\n inset-inline-end: auto;\n margin-inline: 16px;\n}\n.control.placement-top-end, .control.placement-bottom-end {\n inset-inline-start: auto;\n margin-inline: 16px;\n}\n.control:not(.open) {\n opacity: 0;\n transform: scale(0.8);\n}\n.control.open {\n opacity: 1;\n transform: scale(1);\n}\n\n.base {\n display: flex;\n align-items: center;\n padding: 16px;\n background-color: var(--vvd-color-neutral-50);\n border-radius: 6px;\n color: var(--vvd-color-canvas-text);\n column-gap: 16px;\n}\n.base.connotation-success {\n --_connotation-color-primary: var(--vvd-color-success-500);\n --_connotation-color-primary-text: var(--vvd-color-canvas);\n}\n.base.connotation-information {\n --_connotation-color-primary: var(--vvd-color-information-500);\n --_connotation-color-primary-text: var(--vvd-color-canvas);\n}\n.base.connotation-alert {\n --_connotation-color-primary: var(--vvd-color-alert-500);\n --_connotation-color-primary-text: var(--vvd-color-canvas);\n}\n.base.connotation-warning {\n --_connotation-color-primary: var(--vvd-color-warning-300);\n --_connotation-color-primary-text: var(--vvd-color-canvas-text);\n}\n.base:not(.connotation-success, .connotation-information, .connotation-alert, .connotation-warning) {\n --_connotation-color-primary: var(--vvd-color-canvas-text);\n --_connotation-color-primary-text: var(--vvd-color-canvas);\n}\n.base {\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 .alert-text {\n display: flex;\n flex-direction: column;\n gap: 4px;\n justify-self: flex-start;\n margin-inline-end: auto;\n}\n.base .alert-text .headline {\n font: var(--vvd-typography-base-bold);\n}\n.base .alert-text .subtitle {\n font: var(--vvd-typography-base);\n}\n.base .icon {\n flex-shrink: 0;\n color: var(--_appearance-color-fill);\n font-size: 24px;\n line-height: 1;\n}\n.base .dismiss-button {\n border-left: 1px solid var(--vvd-color-neutral-200);\n padding-inline-start: 8px;\n}";
|
|
8
15
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
var _Alert_show, _Alert_closeOnKeyDown;
|
|
17
|
+
const connotationIconMap = new Map([[Connotation.Accent, 'megaphone-line'], [Connotation.Information, 'info-line'], [Connotation.Success, 'check-circle-line'], [Connotation.Warning, 'warning-line'], [Connotation.Alert, 'error-line']]);
|
|
18
|
+
const defaultConnotation = connotation => connotationIconMap.get(connotation);
|
|
19
|
+
class Alert extends FoundationElement {
|
|
20
|
+
constructor() {
|
|
21
|
+
super(...arguments);
|
|
22
|
+
this.removable = false;
|
|
23
|
+
this.placement = 'bottom';
|
|
24
|
+
this.open = false;
|
|
25
|
+
this.timeoutms = 0;
|
|
26
|
+
_Alert_show.set(this, () => {
|
|
27
|
+
this.open = true;
|
|
28
|
+
if (this.timeout) {
|
|
29
|
+
clearTimeout(this.timeout);
|
|
30
|
+
}
|
|
31
|
+
if (this.timeoutms > 0) {
|
|
32
|
+
this.timeout = setTimeout(this.remove, this.timeoutms);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
this.remove = () => {
|
|
36
|
+
this.open = false;
|
|
37
|
+
if (this.timeout) {
|
|
38
|
+
clearTimeout(this.timeout);
|
|
39
|
+
}
|
|
40
|
+
this.$emit('removed');
|
|
41
|
+
};
|
|
42
|
+
_Alert_closeOnKeyDown.set(this, e => {
|
|
43
|
+
if (e.key !== 'Escape' || !this.removable) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
this.remove();
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
get conditionedIcon() {
|
|
50
|
+
var _a;
|
|
51
|
+
return (_a = this.icon) !== null && _a !== void 0 ? _a : defaultConnotation(this.connotation);
|
|
52
|
+
}
|
|
53
|
+
connectedCallback() {
|
|
54
|
+
super.connectedCallback();
|
|
55
|
+
this.addEventListener('keydown', __classPrivateFieldGet(this, _Alert_closeOnKeyDown, "f"));
|
|
56
|
+
if (this.open) {
|
|
57
|
+
__classPrivateFieldGet(this, _Alert_show, "f").call(this);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
disconnectedCallback() {
|
|
61
|
+
super.disconnectedCallback();
|
|
62
|
+
this.removeEventListener('keydown', __classPrivateFieldGet(this, _Alert_closeOnKeyDown, "f"));
|
|
63
|
+
clearTimeout(this.timeout);
|
|
64
|
+
}
|
|
65
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
66
|
+
super.attributeChangedCallback(name, oldValue, newValue);
|
|
67
|
+
switch (name) {
|
|
68
|
+
case 'open':
|
|
69
|
+
{
|
|
70
|
+
this.open ? __classPrivateFieldGet(this, _Alert_show, "f").call(this) : this.remove();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
_Alert_show = new WeakMap(), _Alert_closeOnKeyDown = new WeakMap();
|
|
76
|
+
__decorate([attr({
|
|
77
|
+
mode: 'boolean'
|
|
78
|
+
}), __metadata("design:type", Object)], Alert.prototype, "removable", void 0);
|
|
79
|
+
__decorate([attr({
|
|
80
|
+
mode: 'fromView'
|
|
81
|
+
}), __metadata("design:type", String)], Alert.prototype, "placement", void 0);
|
|
82
|
+
__decorate([attr, __metadata("design:type", String)], Alert.prototype, "headline", void 0);
|
|
83
|
+
__decorate([attr, __metadata("design:type", String)], Alert.prototype, "subtitle", void 0);
|
|
84
|
+
__decorate([attr, __metadata("design:type", String)], Alert.prototype, "icon", void 0);
|
|
85
|
+
__decorate([attr({
|
|
86
|
+
mode: 'boolean'
|
|
87
|
+
}), __metadata("design:type", Object)], Alert.prototype, "open", void 0);
|
|
88
|
+
__decorate([attr({
|
|
89
|
+
mode: 'fromView'
|
|
90
|
+
}), __metadata("design:type", Number)], Alert.prototype, "timeoutms", void 0);
|
|
91
|
+
__decorate([attr, __metadata("design:type", String)], Alert.prototype, "connotation", void 0);
|
|
92
|
+
applyMixins(Alert, AffixIcon);
|
|
16
93
|
|
|
17
|
-
let
|
|
94
|
+
let _2 = t => t,
|
|
18
95
|
_t,
|
|
19
96
|
_t2,
|
|
20
|
-
_t3
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
97
|
+
_t3,
|
|
98
|
+
_t4,
|
|
99
|
+
_t5;
|
|
100
|
+
const getClasses = _ => classNames('base', [`connotation-${_.connotation}`, !!_.connotation]);
|
|
101
|
+
const getControlClasses = _ => classNames('control', ['open', _.open], [`placement-${_.placement}`, !!_.placement]);
|
|
102
|
+
function Headline() {
|
|
103
|
+
return html(_t || (_t = _2`
|
|
104
|
+
<div class="headline">${0}</div>
|
|
105
|
+
`), x => x.headline);
|
|
106
|
+
}
|
|
107
|
+
function Subtitle() {
|
|
108
|
+
return html(_t2 || (_t2 = _2`
|
|
109
|
+
<div class="subtitle">${0}</div>
|
|
110
|
+
`), x => x.subtitle);
|
|
111
|
+
}
|
|
112
|
+
function renderIcon(context) {
|
|
113
|
+
const affixIconTemplate = affixIconTemplateFactory(context);
|
|
114
|
+
return html(_t3 || (_t3 = _2`
|
|
115
|
+
${0}
|
|
116
|
+
`), x => affixIconTemplate(x.conditionedIcon));
|
|
33
117
|
}
|
|
34
|
-
function
|
|
35
|
-
return html(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
118
|
+
function renderDismissButton(buttonTag) {
|
|
119
|
+
return html(_t4 || (_t4 = _2`
|
|
120
|
+
<${0}
|
|
121
|
+
size="condensed"
|
|
122
|
+
class="dismiss-button"
|
|
123
|
+
icon="close-line"
|
|
124
|
+
@click="${0}">
|
|
125
|
+
</${0}>`), buttonTag, x => x.remove(), buttonTag);
|
|
40
126
|
}
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
127
|
+
const AlertTemplate = context => {
|
|
128
|
+
const elevationTag = context.tagFor(Elevation);
|
|
129
|
+
const buttonTag = context.tagFor(Button);
|
|
130
|
+
return html(_t5 || (_t5 = _2`
|
|
131
|
+
<${0} class="elevation" dp='8' exportparts="vvd-theme-alternate">
|
|
132
|
+
<div class="${0}" role="alert" aria-live="assertive">
|
|
133
|
+
<slot name="main">
|
|
134
|
+
<div part="vvd-theme-alternate" class="${0}">
|
|
135
|
+
${0}
|
|
136
|
+
<div class="alert-text">
|
|
137
|
+
${0}
|
|
138
|
+
${0}
|
|
139
|
+
</div>
|
|
140
|
+
<slot class="action-items" name="action-items"></slot>
|
|
141
|
+
${0}
|
|
142
|
+
</div>
|
|
143
|
+
</slot>
|
|
144
|
+
</div>
|
|
145
|
+
</${0}>
|
|
146
|
+
`), elevationTag, getControlClasses, getClasses, when(x => x.icon || x.connotation, renderIcon(context)), when(x => x.headline, Headline()), when(x => x.subtitle, Subtitle()), when(x => x.removable, renderDismissButton(buttonTag)), elevationTag);
|
|
50
147
|
};
|
|
51
148
|
|
|
52
|
-
const
|
|
53
|
-
baseName: '
|
|
54
|
-
template:
|
|
149
|
+
const alertDefinition = Alert.compose({
|
|
150
|
+
baseName: 'alert',
|
|
151
|
+
template: AlertTemplate,
|
|
55
152
|
styles: css_248z
|
|
56
153
|
});
|
|
57
|
-
const
|
|
58
|
-
const
|
|
154
|
+
const alertRegistries = [alertDefinition(), ...iconRegistries, ...buttonRegistries, ...elevationRegistries];
|
|
155
|
+
const registerAlert = registerFactory(alertRegistries);
|
|
59
156
|
|
|
60
|
-
export {
|
|
157
|
+
export { alertDefinition as a, alertRegistries as b, registerAlert as r };
|