@vonage/vivid 3.31.0 → 3.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/accordion/index.js +5 -5
- package/accordion-item/index.js +4 -4
- package/action-group/index.js +1 -1
- package/alert/index.js +8 -7
- package/avatar/index.js +2 -2
- package/badge/index.js +2 -2
- package/banner/index.js +5 -5
- package/breadcrumb/index.js +1 -1
- package/breadcrumb-item/index.js +3 -3
- package/button/index.js +4 -4
- package/calendar/index.js +1 -1
- package/calendar-event/index.js +1 -1
- package/card/index.js +3 -3
- package/checkbox/index.js +7 -4
- package/combobox/index.js +10 -9
- package/custom-elements.json +996 -29
- package/data-grid/index.js +2 -2
- package/date-picker/index.js +35 -0
- package/dialog/index.js +6 -6
- package/divider/index.js +1 -1
- package/elevation/index.js +1 -1
- package/empty-state/index.js +2 -2
- package/fab/index.js +4 -4
- package/file-picker/index.js +7 -6
- package/focus/index.js +1 -1
- package/header/index.js +2 -2
- package/icon/index.js +1 -1
- package/index.d.ts +1 -0
- package/index.js +68 -66
- package/layout/index.js +1 -1
- package/lib/button/button.d.ts +2 -0
- package/lib/calendar/calendar.d.ts +1 -1
- package/lib/components.d.ts +20 -19
- package/lib/date-picker/calendar/calendarGrid.d.ts +17 -0
- package/lib/date-picker/calendar/dateStr.d.ts +7 -0
- package/lib/date-picker/calendar/month.d.ts +12 -0
- package/lib/date-picker/calendar/monthPickerGrid.d.ts +10 -0
- package/lib/date-picker/calendar/presentationDate.d.ts +4 -0
- package/lib/date-picker/calendar/year.d.ts +2 -0
- package/lib/date-picker/date-picker.d.ts +18 -0
- package/lib/date-picker/date-picker.template.d.ts +4 -0
- package/lib/date-picker/definition.d.ts +3 -0
- package/lib/date-picker/locale.d.ts +21 -0
- package/lib/icon/icon.d.ts +0 -1
- package/lib/listbox/listbox.d.ts +9 -1
- package/lib/select/select.d.ts +4 -2
- package/lib/text-field/text-field.d.ts +1 -0
- package/listbox/index.js +22 -17
- package/locales/en-GB.d.ts +3 -0
- package/locales/en-GB.js +59 -0
- package/locales/en-US.d.ts +3 -0
- package/locales/en-US.js +59 -0
- package/locales/ja-JP.d.ts +3 -0
- package/locales/ja-JP.js +59 -0
- package/locales/zh-CN.d.ts +3 -0
- package/locales/zh-CN.js +59 -0
- package/menu/index.js +8 -8
- package/menu-item/index.js +4 -4
- package/nav/index.js +1 -1
- package/nav-disclosure/index.js +3 -3
- package/nav-item/index.js +3 -3
- package/note/index.js +4 -4
- package/number-field/index.js +8 -7
- package/option/index.js +5 -4
- package/package.json +2 -15
- package/pagination/index.js +5 -5
- package/popup/index.js +6 -6
- package/progress/index.js +1 -1
- package/progress-ring/index.js +1 -1
- package/radio/index.js +2 -2
- package/radio-group/index.js +1 -1
- package/select/index.js +10 -9
- package/shared/affix.js +25 -9
- package/shared/apply-mixins.js +1 -1
- package/shared/breadcrumb-item.js +5 -5
- package/shared/button.js +13 -13
- package/shared/calendar-event.js +36 -16
- package/shared/definition.js +133 -194
- package/shared/definition10.js +225 -40
- package/shared/definition11.js +36 -32
- package/shared/definition12.js +763 -98
- package/shared/definition13.js +125 -89
- package/shared/definition14.js +207 -27
- package/shared/definition15.js +710 -731
- package/shared/definition16.js +1289 -47
- package/shared/definition17.js +6113 -93
- package/shared/definition18.js +242 -164
- package/shared/definition19.js +47 -692
- package/shared/definition2.js +199 -117
- package/shared/definition20.js +59 -1671
- package/shared/definition21.js +95 -255
- package/shared/definition22.js +2218 -1167
- package/shared/definition23.js +57 -219
- package/shared/definition24.js +27 -68
- package/shared/definition25.js +54 -38
- package/shared/definition26.js +395 -70
- package/shared/definition27.js +381 -2223
- package/shared/definition28.js +85 -44
- package/shared/definition29.js +27 -40
- package/shared/definition3.js +61 -24
- package/shared/definition30.js +13 -427
- package/shared/definition31.js +49 -360
- package/shared/definition32.js +466 -13
- package/shared/definition33.js +273 -63
- package/shared/definition34.js +195 -25
- package/shared/definition35.js +86 -35
- package/shared/definition36.js +66 -427
- package/shared/definition37.js +430 -190
- package/shared/definition38.js +34 -52
- package/shared/definition39.js +683 -31
- package/shared/definition4.js +157 -12
- package/shared/definition40.js +97 -422
- package/shared/definition41.js +473 -543
- package/shared/definition42.js +122 -73
- package/shared/definition43.js +103 -502
- package/shared/definition44.js +23 -101
- package/shared/definition45.js +76 -126
- package/shared/definition46.js +494 -48
- package/shared/definition47.js +23 -23
- package/shared/definition48.js +126 -476
- package/shared/definition49.js +275 -98
- package/shared/definition5.js +71 -36
- package/shared/definition50.js +157 -16
- package/shared/definition51.js +133 -263
- package/shared/definition52.js +131 -115
- package/shared/definition53.js +85 -120
- package/shared/definition54.js +295 -111
- package/shared/definition55.js +12 -71
- package/shared/definition56.js +39 -295
- package/shared/definition57.js +181 -0
- package/shared/definition6.js +56 -111
- package/shared/definition7.js +119 -187
- package/shared/definition8.js +58 -23
- package/shared/definition9.js +92 -66
- package/shared/focus.js +2 -1
- package/shared/focus2.js +1 -1
- package/shared/form-associated.js +2 -2
- package/shared/icon.js +48 -27
- package/shared/index.js +7 -27
- package/shared/index2.js +202 -0
- package/shared/key-codes.js +1 -1
- package/shared/listbox.js +88 -11
- package/shared/localization/Locale.d.ts +4 -0
- package/shared/localization/index.d.ts +7 -0
- package/shared/patterns/form-elements/form-elements.d.ts +4 -4
- package/shared/patterns/index.d.ts +1 -0
- package/shared/patterns/localized.d.ts +4 -0
- package/shared/radio.js +23 -7
- package/shared/repeat.js +1 -1
- package/shared/text-anchor.js +21 -4
- package/shared/text-anchor.template.js +37 -40
- package/shared/text-field.js +2 -2
- package/shared/text-field2.js +15 -15
- package/shared/tree-item.js +12 -12
- package/side-drawer/index.js +1 -1
- package/slider/index.js +2 -2
- package/split-button/index.js +3 -3
- package/style.css +6097 -0
- package/styles/core/all.css +25 -3
- package/styles/core/theme.css +1 -1
- package/styles/core/typography.css +25 -3
- package/styles/tokens/theme-dark.css +4 -4
- package/styles/tokens/theme-light.css +4 -4
- package/styles/tokens/vivid-2-compat.css +2 -2
- package/switch/index.js +5 -4
- package/tab/index.js +3 -3
- package/tab-panel/index.js +1 -1
- package/tabs/index.js +5 -5
- package/tag/index.js +3 -3
- package/tag-group/index.js +1 -1
- package/text-anchor/index.js +1 -1
- package/text-area/index.js +5 -4
- package/text-field/index.js +5 -4
- package/toggletip/index.js +7 -7
- package/tooltip/index.js +7 -7
- package/tree-item/index.js +3 -3
- package/tree-view/index.js +1 -1
- package/vivid.api.json +137 -0
- package/lib/accordion/index.d.ts +0 -1
- package/lib/accordion-item/index.d.ts +0 -1
- package/lib/action-group/index.d.ts +0 -1
- package/lib/alert/index.d.ts +0 -1
- package/lib/avatar/index.d.ts +0 -1
- package/lib/badge/index.d.ts +0 -1
- package/lib/banner/index.d.ts +0 -1
- package/lib/breadcrumb/index.d.ts +0 -1
- package/lib/breadcrumb-item/index.d.ts +0 -1
- package/lib/button/index.d.ts +0 -1
- package/lib/calendar/index.d.ts +0 -1
- package/lib/calendar-event/index.d.ts +0 -1
- package/lib/card/index.d.ts +0 -1
- package/lib/checkbox/index.d.ts +0 -1
- package/lib/combobox/index.d.ts +0 -1
- package/lib/data-grid/index.d.ts +0 -1
- package/lib/dialog/index.d.ts +0 -1
- package/lib/divider/index.d.ts +0 -1
- package/lib/elevation/index.d.ts +0 -1
- package/lib/empty-state/index.d.ts +0 -1
- package/lib/fab/index.d.ts +0 -1
- package/lib/file-picker/index.d.ts +0 -1
- package/lib/focus/index.d.ts +0 -1
- package/lib/header/index.d.ts +0 -1
- package/lib/icon/index.d.ts +0 -1
- package/lib/layout/index.d.ts +0 -1
- package/lib/listbox/index.d.ts +0 -1
- package/lib/menu/index.d.ts +0 -1
- package/lib/menu-item/index.d.ts +0 -1
- package/lib/nav/index.d.ts +0 -1
- package/lib/nav-disclosure/index.d.ts +0 -1
- package/lib/nav-item/index.d.ts +0 -1
- package/lib/note/index.d.ts +0 -1
- package/lib/number-field/index.d.ts +0 -1
- package/lib/option/index.d.ts +0 -1
- package/lib/pagination/index.d.ts +0 -1
- package/lib/popup/index.d.ts +0 -1
- package/lib/progress/index.d.ts +0 -1
- package/lib/progress-ring/index.d.ts +0 -1
- package/lib/radio/index.d.ts +0 -1
- package/lib/radio-group/index.d.ts +0 -1
- package/lib/select/index.d.ts +0 -1
- package/lib/side-drawer/index.d.ts +0 -1
- package/lib/slider/index.d.ts +0 -1
- package/lib/split-button/index.d.ts +0 -1
- package/lib/switch/index.d.ts +0 -1
- package/lib/tab/index.d.ts +0 -1
- package/lib/tab-panel/index.d.ts +0 -1
- package/lib/tabs/index.d.ts +0 -1
- package/lib/tag/index.d.ts +0 -1
- package/lib/tag-group/index.d.ts +0 -1
- package/lib/text-anchor/index.d.ts +0 -1
- package/lib/text-area/index.d.ts +0 -1
- package/lib/text-field/index.d.ts +0 -1
- package/lib/toggletip/index.d.ts +0 -1
- package/lib/tooltip/index.d.ts +0 -1
- package/lib/tree-item/index.d.ts +0 -1
- package/lib/tree-view/index.d.ts +0 -1
- package/shared/form-elements.js +0 -162
package/shared/definition56.js
CHANGED
|
@@ -1,303 +1,47 @@
|
|
|
1
|
-
import {
|
|
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 { r as ref } from './ref.js';
|
|
6
|
-
import { s as slotted } from './slotted.js';
|
|
1
|
+
import { a as attr, F as FoundationElement, h as html, r as registerFactory } from './index.js';
|
|
7
2
|
import { c as classNames } from './class-names.js';
|
|
8
3
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
}
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
7
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
8
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
9
|
+
if (decorator = decorators[i])
|
|
10
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
11
|
+
if (kind && result)
|
|
12
|
+
__defProp(target, key, result);
|
|
13
|
+
return result;
|
|
14
|
+
};
|
|
15
|
+
class Elevation extends FoundationElement {
|
|
262
16
|
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
],
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
],
|
|
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}";
|
|
17
|
+
__decorateClass([
|
|
18
|
+
attr
|
|
19
|
+
], Elevation.prototype, "dp", 2);
|
|
20
|
+
__decorateClass([
|
|
21
|
+
attr({ attribute: "no-shadow", mode: "boolean" })
|
|
22
|
+
], Elevation.prototype, "noShadow", 2);
|
|
274
23
|
|
|
275
|
-
|
|
24
|
+
const styles = ":host {\n display: contents;\n}\n\n.control {\n display: contents;\n}\n.control.dp-0 {\n --_elevation-fill: var(--vvd-color-surface-0dp);\n --_elevation-shadow: var(--vvd-shadow-surface-0dp);\n}\n.control.dp-4 {\n --_elevation-fill: var(--vvd-color-surface-4dp);\n --_elevation-shadow: var(--vvd-shadow-surface-4dp);\n}\n.control.dp-8 {\n --_elevation-fill: var(--vvd-color-surface-8dp);\n --_elevation-shadow: var(--vvd-shadow-surface-8dp);\n}\n.control.dp-12 {\n --_elevation-fill: var(--vvd-color-surface-12dp);\n --_elevation-shadow: var(--vvd-shadow-surface-12dp);\n}\n.control.dp-16 {\n --_elevation-fill: var(--vvd-color-surface-16dp);\n --_elevation-shadow: var(--vvd-shadow-surface-16dp);\n}\n.control.dp-24 {\n --_elevation-fill: var(--vvd-color-surface-24dp);\n --_elevation-shadow: var(--vvd-shadow-surface-24dp);\n}\n.control:not(.dp-0, .dp-4, .dp-8, .dp-12, .dp-16, .dp-24) {\n --_elevation-fill: var(--vvd-color-surface-2dp);\n --_elevation-shadow: var(--vvd-shadow-surface-2dp);\n}\n.control ::slotted(*) {\n position: relative;\n isolation: isolate;\n}\n.control ::slotted(*)::before {\n position: absolute;\n z-index: -1;\n background: var(--_elevation-fill);\n block-size: 100%;\n border-radius: inherit;\n content: \"\";\n filter: var(--_elevation-shadow);\n inline-size: 100%;\n inset-block-start: 0;\n inset-inline-start: 0;\n transition: background-color 0.15s linear, filter 0.15s linear;\n}\n.control.no-shadow ::slotted(*)::before {\n filter: none;\n}";
|
|
276
25
|
|
|
277
|
-
const getClasses =
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
<div class="${getClasses}">
|
|
290
|
-
<slot ${slotted('slottedTreeItems')}></slot>
|
|
291
|
-
</div>
|
|
292
|
-
</template>`;
|
|
293
|
-
};
|
|
26
|
+
const getClasses = ({
|
|
27
|
+
dp,
|
|
28
|
+
noShadow
|
|
29
|
+
}) => classNames(
|
|
30
|
+
"control",
|
|
31
|
+
[`dp-${dp}`, Boolean(dp)],
|
|
32
|
+
["no-shadow", Boolean(noShadow)]
|
|
33
|
+
);
|
|
34
|
+
const elevationTemplate = () => html`
|
|
35
|
+
<div class="${getClasses}" part="base">
|
|
36
|
+
<slot></slot>
|
|
37
|
+
</div>`;
|
|
294
38
|
|
|
295
|
-
const
|
|
296
|
-
baseName:
|
|
297
|
-
template:
|
|
298
|
-
styles
|
|
39
|
+
const elevationDefinition = Elevation.compose({
|
|
40
|
+
baseName: "elevation",
|
|
41
|
+
template: elevationTemplate,
|
|
42
|
+
styles
|
|
299
43
|
});
|
|
300
|
-
const
|
|
301
|
-
const
|
|
44
|
+
const elevationRegistries = [elevationDefinition()];
|
|
45
|
+
const registerElevation = registerFactory(elevationRegistries);
|
|
302
46
|
|
|
303
|
-
export {
|
|
47
|
+
export { Elevation as E, elevationRegistries as e, registerElevation as r };
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { a as attr, F as FoundationElement, h as html, r as registerFactory } from './index.js';
|
|
2
|
+
import { B as Button, a as buttonRegistries } from './definition10.js';
|
|
3
|
+
import { E as Elevation, e as elevationRegistries } from './definition56.js';
|
|
4
|
+
import { r as ref } from './ref.js';
|
|
5
|
+
import { w as when } from './when.js';
|
|
6
|
+
import { c as classNames } from './class-names.js';
|
|
7
|
+
|
|
8
|
+
function t(t){return t.split("-")[1]}function e(t){return "y"===t?"height":"width"}function n$1(t){return t.split("-")[0]}function o$1(t){return ["top","bottom"].includes(n$1(t))?"x":"y"}function i$1(i,r,a){let{reference:l,floating:s}=i;const c=l.x+l.width/2-s.width/2,f=l.y+l.height/2-s.height/2,m=o$1(r),u=e(m),g=l[u]/2-s[u]/2,d="x"===m;let p;switch(n$1(r)){case"top":p={x:c,y:l.y-s.height};break;case"bottom":p={x:c,y:l.y+l.height};break;case"right":p={x:l.x+l.width,y:f};break;case"left":p={x:l.x-s.width,y:f};break;default:p={x:l.x,y:l.y};}switch(t(r)){case"start":p[m]-=g*(a&&d?-1:1);break;case"end":p[m]+=g*(a&&d?-1:1);}return p}const r$1=async(t,e,n)=>{const{placement:o="bottom",strategy:r="absolute",middleware:a=[],platform:l}=n,s=a.filter(Boolean),c=await(null==l.isRTL?void 0:l.isRTL(e));let f=await l.getElementRects({reference:t,floating:e,strategy:r}),{x:m,y:u}=i$1(f,o,c),g=o,d={},p=0;for(let n=0;n<s.length;n++){const{name:a,fn:h}=s[n],{x:y,y:x,data:w,reset:v}=await h({x:m,y:u,initialPlacement:o,placement:g,strategy:r,middlewareData:d,rects:f,platform:l,elements:{reference:t,floating:e}});m=null!=y?y:m,u=null!=x?x:u,d={...d,[a]:{...d[a],...w}},v&&p<=50&&(p++,"object"==typeof v&&(v.placement&&(g=v.placement),v.rects&&(f=!0===v.rects?await l.getElementRects({reference:t,floating:e,strategy:r}):v.rects),({x:m,y:u}=i$1(f,g,c))),n=-1);}return {x:m,y:u,placement:g,strategy:r,middlewareData:d}};function a$1(t,e){return "function"==typeof t?t(e):t}function l$1(t){return "number"!=typeof t?function(t){return {top:0,right:0,bottom:0,left:0,...t}}(t):{top:t,right:t,bottom:t,left:t}}function s$1(t){return {...t,top:t.y,left:t.x,right:t.x+t.width,bottom:t.y+t.height}}async function c$1(t,e){var n;void 0===e&&(e={});const{x:o,y:i,platform:r,rects:c,elements:f,strategy:m}=t,{boundary:u="clippingAncestors",rootBoundary:g="viewport",elementContext:d="floating",altBoundary:p=!1,padding:h=0}=a$1(e,t),y=l$1(h),x=f[p?"floating"===d?"reference":"floating":d],w=s$1(await r.getClippingRect({element:null==(n=await(null==r.isElement?void 0:r.isElement(x)))||n?x:x.contextElement||await(null==r.getDocumentElement?void 0:r.getDocumentElement(f.floating)),boundary:u,rootBoundary:g,strategy:m})),v="floating"===d?{...c.floating,x:o,y:i}:c.reference,b=await(null==r.getOffsetParent?void 0:r.getOffsetParent(f.floating)),A=await(null==r.isElement?void 0:r.isElement(b))&&await(null==r.getScale?void 0:r.getScale(b))||{x:1,y:1},R=s$1(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({rect:v,offsetParent:b,strategy:m}):v);return {top:(w.top-R.top+y.top)/A.y,bottom:(R.bottom-w.bottom+y.bottom)/A.y,left:(w.left-R.left+y.left)/A.x,right:(R.right-w.right+y.right)/A.x}}const f$1=Math.min,m$1=Math.max;function u$1(t,e,n){return m$1(t,f$1(e,n))}const g$1=n=>({name:"arrow",options:n,async fn(i){const{x:r,y:s,placement:c,rects:m,platform:g,elements:d}=i,{element:p,padding:h=0}=a$1(n,i)||{};if(null==p)return {};const y=l$1(h),x={x:r,y:s},w=o$1(c),v=e(w),b=await g.getDimensions(p),A="y"===w,R=A?"top":"left",P=A?"bottom":"right",E=A?"clientHeight":"clientWidth",T=m.reference[v]+m.reference[w]-x[w]-m.floating[v],D=x[w]-m.reference[w],L=await(null==g.getOffsetParent?void 0:g.getOffsetParent(p));let k=L?L[E]:0;k&&await(null==g.isElement?void 0:g.isElement(L))||(k=d.floating[E]||m.floating[v]);const O=T/2-D/2,B=k/2-b[v]/2-1,C=f$1(y[R],B),H=f$1(y[P],B),S=C,F=k-b[v]-H,M=k/2-b[v]/2+O,V=u$1(S,M,F),W=null!=t(c)&&M!=V&&m.reference[v]/2-(M<S?C:H)-b[v]/2<0?M<S?S-M:F-M:0;return {[w]:x[w]-W,data:{[w]:V,centerOffset:M-V+W}}}}),d$1=["top","right","bottom","left"];d$1.reduce(((t,e)=>t.concat(e,e+"-start",e+"-end")),[]);const h$1={left:"right",right:"left",bottom:"top",top:"bottom"};function y$1(t){return t.replace(/left|right|bottom|top/g,(t=>h$1[t]))}function x$1(n,i,r){void 0===r&&(r=!1);const a=t(n),l=o$1(n),s=e(l);let c="x"===l?a===(r?"end":"start")?"right":"left":"start"===a?"bottom":"top";return i.reference[s]>i.floating[s]&&(c=y$1(c)),{main:c,cross:y$1(c)}}const w$1={start:"end",end:"start"};function v$1(t){return t.replace(/start|end/g,(t=>w$1[t]))}const A$1=function(e){return void 0===e&&(e={}),{name:"flip",options:e,async fn(o){var i;const{placement:r,middlewareData:l,rects:s,initialPlacement:f,platform:m,elements:u}=o,{mainAxis:g=!0,crossAxis:d=!0,fallbackPlacements:p,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:w="none",flipAlignment:b=!0,...A}=a$1(e,o),R=n$1(r),P=n$1(f)===f,E=await(null==m.isRTL?void 0:m.isRTL(u.floating)),T=p||(P||!b?[y$1(f)]:function(t){const e=y$1(t);return [v$1(t),e,v$1(e)]}(f));p||"none"===w||T.push(...function(e,o,i,r){const a=t(e);let l=function(t,e,n){const o=["left","right"],i=["right","left"],r=["top","bottom"],a=["bottom","top"];switch(t){case"top":case"bottom":return n?e?i:o:e?o:i;case"left":case"right":return e?r:a;default:return []}}(n$1(e),"start"===i,r);return a&&(l=l.map((t=>t+"-"+a)),o&&(l=l.concat(l.map(v$1)))),l}(f,b,w,E));const D=[f,...T],L=await c$1(o,A),k=[];let O=(null==(i=l.flip)?void 0:i.overflows)||[];if(g&&k.push(L[R]),d){const{main:t,cross:e}=x$1(r,s,E);k.push(L[t],L[e]);}if(O=[...O,{placement:r,overflows:k}],!k.every((t=>t<=0))){var B,C;const t=((null==(B=l.flip)?void 0:B.index)||0)+1,e=D[t];if(e)return {data:{index:t,overflows:O},reset:{placement:e}};let n=null==(C=O.filter((t=>t.overflows[0]<=0)).sort(((t,e)=>t.overflows[1]-e.overflows[1]))[0])?void 0:C.placement;if(!n)switch(h){case"bestFit":{var H;const t=null==(H=O.map((t=>[t.placement,t.overflows.filter((t=>t>0)).reduce(((t,e)=>t+e),0)])).sort(((t,e)=>t[1]-e[1]))[0])?void 0:H[0];t&&(n=t);break}case"initialPlacement":n=f;}if(r!==n)return {reset:{placement:n}}}return {}}}};function R$1(t,e){return {top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function P$1(t){return d$1.some((e=>t[e]>=0))}const E$1=function(t){return void 0===t&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n}=e,{strategy:o="referenceHidden",...i}=a$1(t,e);switch(o){case"referenceHidden":{const t=R$1(await c$1(e,{...i,elementContext:"reference"}),n.reference);return {data:{referenceHiddenOffsets:t,referenceHidden:P$1(t)}}}case"escaped":{const t=R$1(await c$1(e,{...i,altBoundary:!0}),n.floating);return {data:{escapedOffsets:t,escaped:P$1(t)}}}default:return {}}}}};function T$1(t){const e=f$1(...t.map((t=>t.left))),n=f$1(...t.map((t=>t.top)));return {x:e,y:n,width:m$1(...t.map((t=>t.right)))-e,height:m$1(...t.map((t=>t.bottom)))-n}}const D$1=function(t){return void 0===t&&(t={}),{name:"inline",options:t,async fn(e){const{placement:i,elements:r,rects:c,platform:u,strategy:g}=e,{padding:d=2,x:p,y:h}=a$1(t,e),y=Array.from(await(null==u.getClientRects?void 0:u.getClientRects(r.reference))||[]),x=function(t){const e=t.slice().sort(((t,e)=>t.y-e.y)),n=[];let o=null;for(let t=0;t<e.length;t++){const i=e[t];!o||i.y-o.y>o.height/2?n.push([i]):n[n.length-1].push(i),o=i;}return n.map((t=>s$1(T$1(t))))}(y),w=s$1(T$1(y)),v=l$1(d);const b=await u.getElementRects({reference:{getBoundingClientRect:function(){if(2===x.length&&x[0].left>x[1].right&&null!=p&&null!=h)return x.find((t=>p>t.left-v.left&&p<t.right+v.right&&h>t.top-v.top&&h<t.bottom+v.bottom))||w;if(x.length>=2){if("x"===o$1(i)){const t=x[0],e=x[x.length-1],o="top"===n$1(i),r=t.top,a=e.bottom,l=o?t.left:e.left,s=o?t.right:e.right;return {top:r,bottom:a,left:l,right:s,width:s-l,height:a-r,x:l,y:r}}const t="left"===n$1(i),e=m$1(...x.map((t=>t.right))),r=f$1(...x.map((t=>t.left))),a=x.filter((n=>t?n.left===r:n.right===e)),l=a[0].top,s=a[a.length-1].bottom;return {top:l,bottom:s,left:r,right:e,width:e-r,height:s-l,x:r,y:l}}return w}},floating:r.floating,strategy:g});return c.reference.x!==b.reference.x||c.reference.y!==b.reference.y||c.reference.width!==b.reference.width||c.reference.height!==b.reference.height?{reset:{rects:b}}:{}}}};const L$1=function(e){return void 0===e&&(e=0),{name:"offset",options:e,async fn(i){const{x:r,y:l}=i,s=await async function(e,i){const{placement:r,platform:l,elements:s}=e,c=await(null==l.isRTL?void 0:l.isRTL(s.floating)),f=n$1(r),m=t(r),u="x"===o$1(r),g=["left","top"].includes(f)?-1:1,d=c&&u?-1:1,p=a$1(i,e);let{mainAxis:h,crossAxis:y,alignmentAxis:x}="number"==typeof p?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...p};return m&&"number"==typeof x&&(y="end"===m?-1*x:x),u?{x:y*d,y:h*g}:{x:h*g,y:y*d}}(i,e);return {x:r+s.x,y:l+s.y,data:s}}}};
|
|
9
|
+
|
|
10
|
+
function n(t){var e;return (null==t||null==(e=t.ownerDocument)?void 0:e.defaultView)||window}function o(t){return n(t).getComputedStyle(t)}function i(t){return t instanceof n(t).Node}function r(t){return i(t)?(t.nodeName||"").toLowerCase():"#document"}function c(t){return t instanceof HTMLElement||t instanceof n(t).HTMLElement}function l(t){return "undefined"!=typeof ShadowRoot&&(t instanceof n(t).ShadowRoot||t instanceof ShadowRoot)}function s(t){const{overflow:e,overflowX:n,overflowY:i,display:r}=o(t);return /auto|scroll|overlay|hidden|clip/.test(e+i+n)&&!["inline","contents"].includes(r)}function f(t){return ["table","td","th"].includes(r(t))}function u(t){const e=a(),n=o(t);return "none"!==n.transform||"none"!==n.perspective||!!n.containerType&&"normal"!==n.containerType||!e&&!!n.backdropFilter&&"none"!==n.backdropFilter||!e&&!!n.filter&&"none"!==n.filter||["transform","perspective","filter"].some((t=>(n.willChange||"").includes(t)))||["paint","layout","strict","content"].some((t=>(n.contain||"").includes(t)))}function a(){return !("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function d(t){return ["html","body","#document"].includes(r(t))}const h=Math.min,p=Math.max,m=Math.round,g=Math.floor,y=t=>({x:t,y:t});function w(t){const e=o(t);let n=parseFloat(e.width)||0,i=parseFloat(e.height)||0;const r=c(t),l=r?t.offsetWidth:n,s=r?t.offsetHeight:i,f=m(n)!==l||m(i)!==s;return f&&(n=l,i=s),{width:n,height:i,$:f}}function x(t){return t instanceof Element||t instanceof n(t).Element}function v(t){return x(t)?t:t.contextElement}function b(t){const e=v(t);if(!c(e))return y(1);const n=e.getBoundingClientRect(),{width:o,height:i,$:r}=w(e);let l=(r?m(n.width):n.width)/o,s=(r?m(n.height):n.height)/i;return l&&Number.isFinite(l)||(l=1),s&&Number.isFinite(s)||(s=1),{x:l,y:s}}const L=y(0);function T(t){const e=n(t);return a()&&e.visualViewport?{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}:L}function R(e,o,i,r){void 0===o&&(o=!1),void 0===i&&(i=!1);const c=e.getBoundingClientRect(),l=v(e);let s=y(1);o&&(r?x(r)&&(s=b(r)):s=b(e));const f=function(t,e,o){return void 0===e&&(e=!1),!(!o||e&&o!==n(t))&&e}(l,i,r)?T(l):y(0);let u=(c.left+f.x)/s.x,a=(c.top+f.y)/s.y,d=c.width/s.x,h=c.height/s.y;if(l){const t=n(l),e=r&&x(r)?n(r):r;let o=t.frameElement;for(;o&&r&&e!==t;){const t=b(o),e=o.getBoundingClientRect(),i=getComputedStyle(o),r=e.left+(o.clientLeft+parseFloat(i.paddingLeft))*t.x,c=e.top+(o.clientTop+parseFloat(i.paddingTop))*t.y;u*=t.x,a*=t.y,d*=t.x,h*=t.y,u+=r,a+=c,o=n(o).frameElement;}}return s$1({width:d,height:h,x:u,y:a})}function E(t){return x(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function S(t){var e;return null==(e=(i(t)?t.ownerDocument:t.document)||window.document)?void 0:e.documentElement}function C(t){return R(S(t)).left+E(t).scrollLeft}function F(t){if("html"===r(t))return t;const e=t.assignedSlot||t.parentNode||l(t)&&t.host||S(t);return l(e)?e.host:e}function O(t){const e=F(t);return d(e)?t.ownerDocument?t.ownerDocument.body:t.body:c(e)&&s(e)?e:O(e)}function D(t,e){var o;void 0===e&&(e=[]);const i=O(t),r=i===(null==(o=t.ownerDocument)?void 0:o.body),c=n(i);return r?e.concat(c,c.visualViewport||[],s(i)?i:[]):e.concat(i,D(i))}function H(e,i,r){let l;if("viewport"===i)l=function(t,e){const o=n(t),i=S(t),r=o.visualViewport;let c=i.clientWidth,l=i.clientHeight,s=0,f=0;if(r){c=r.width,l=r.height;const t=a();(!t||t&&"fixed"===e)&&(s=r.offsetLeft,f=r.offsetTop);}return {width:c,height:l,x:s,y:f}}(e,r);else if("document"===i)l=function(t){const e=S(t),n=E(t),i=t.ownerDocument.body,r=p(e.scrollWidth,e.clientWidth,i.scrollWidth,i.clientWidth),c=p(e.scrollHeight,e.clientHeight,i.scrollHeight,i.clientHeight);let l=-n.scrollLeft+C(t);const s=-n.scrollTop;return "rtl"===o(i).direction&&(l+=p(e.clientWidth,i.clientWidth)-r),{width:r,height:c,x:l,y:s}}(S(e));else if(x(i))l=function(t,e){const n=R(t,!0,"fixed"===e),o=n.top+t.clientTop,i=n.left+t.clientLeft,r=c(t)?b(t):y(1);return {width:t.clientWidth*r.x,height:t.clientHeight*r.y,x:i*r.x,y:o*r.y}}(i,r);else {const t=T(e);l={...i,x:i.x-t.x,y:i.y-t.y};}return s$1(l)}function W(t,e){const n=F(t);return !(n===e||!x(n)||d(n))&&("fixed"===o(n).position||W(n,e))}function M(t,e,n){const o=c(e),i=S(e),l="fixed"===n,f=R(t,!0,l,e);let u={scrollLeft:0,scrollTop:0};const a=y(0);if(o||!o&&!l)if(("body"!==r(e)||s(i))&&(u=E(e)),c(e)){const t=R(e,!0,l,e);a.x=t.x+e.clientLeft,a.y=t.y+e.clientTop;}else i&&(a.x=C(i));return {x:f.left+u.scrollLeft-a.x,y:f.top+u.scrollTop-a.y,width:f.width,height:f.height}}function z(t,e){return c(t)&&"fixed"!==o(t).position?e?e(t):t.offsetParent:null}function P(t,e){const i=n(t);if(!c(t))return i;let l=z(t,e);for(;l&&f(l)&&"static"===o(l).position;)l=z(l,e);return l&&("html"===r(l)||"body"===r(l)&&"static"===o(l).position&&!u(l))?i:l||function(t){let e=F(t);for(;c(e)&&!d(e);){if(u(e))return e;e=F(e);}return null}(t)||i}const V={convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{rect:e,offsetParent:n,strategy:o}=t;const i=c(n),l=S(n);if(n===l)return e;let f={scrollLeft:0,scrollTop:0},u=y(1);const a=y(0);if((i||!i&&"fixed"!==o)&&(("body"!==r(n)||s(l))&&(f=E(n)),c(n))){const t=R(n);u=b(n),a.x=t.x+n.clientLeft,a.y=t.y+n.clientTop;}return {width:e.width*u.x,height:e.height*u.y,x:e.x*u.x-f.scrollLeft*u.x+a.x,y:e.y*u.y-f.scrollTop*u.y+a.y}},getDocumentElement:S,getClippingRect:function(t){let{element:e,boundary:n,rootBoundary:i,strategy:c}=t;const l=[..."clippingAncestors"===n?function(t,e){const n=e.get(t);if(n)return n;let i=D(t).filter((t=>x(t)&&"body"!==r(t))),c=null;const l="fixed"===o(t).position;let f=l?F(t):t;for(;x(f)&&!d(f);){const e=o(f),n=u(f);n||"fixed"!==e.position||(c=null),(l?!n&&!c:!n&&"static"===e.position&&c&&["absolute","fixed"].includes(c.position)||s(f)&&!n&&W(t,f))?i=i.filter((t=>t!==f)):c=e,f=F(f);}return e.set(t,i),i}(e,this._c):[].concat(n),i],f=l[0],a=l.reduce(((t,n)=>{const o=H(e,n,c);return t.top=p(o.top,t.top),t.right=h(o.right,t.right),t.bottom=h(o.bottom,t.bottom),t.left=p(o.left,t.left),t}),H(e,f,c));return {width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}},getOffsetParent:P,getElementRects:async function(t){let{reference:e,floating:n,strategy:o}=t;const i=this.getOffsetParent||P,r=this.getDimensions;return {reference:M(e,await i(n),o),floating:{x:0,y:0,...await r(n)}}},getClientRects:function(t){return Array.from(t.getClientRects())},getDimensions:function(t){return w(t)},getScale:b,isElement:x,isRTL:function(t){return "rtl"===getComputedStyle(t).direction}};function A(t,e,n,o){void 0===o&&(o={});const{ancestorScroll:i=!0,ancestorResize:r=!0,elementResize:c="function"==typeof ResizeObserver,layoutShift:l="function"==typeof IntersectionObserver,animationFrame:s=!1}=o,f=v(t),u=i||r?[...f?D(f):[],...D(e)]:[];u.forEach((t=>{i&&t.addEventListener("scroll",n,{passive:!0}),r&&t.addEventListener("resize",n);}));const a=f&&l?function(t,e){let n,o=null;const i=S(t);function r(){clearTimeout(n),o&&o.disconnect(),o=null;}return function c(l,s){void 0===l&&(l=!1),void 0===s&&(s=1),r();const{left:f,top:u,width:a,height:d}=t.getBoundingClientRect();if(l||e(),!a||!d)return;const m={rootMargin:-g(u)+"px "+-g(i.clientWidth-(f+a))+"px "+-g(i.clientHeight-(u+d))+"px "+-g(f)+"px",threshold:p(0,h(1,s))||1};let y=!0;function w(t){const e=t[0].intersectionRatio;if(e!==s){if(!y)return c();e?c(!1,e):n=setTimeout((()=>{c(!1,1e-7);}),100);}y=!1;}try{o=new IntersectionObserver(w,{...m,root:i.ownerDocument});}catch(t){o=new IntersectionObserver(w,m);}o.observe(t);}(!0),r}(f,n):null;let d,m=-1,y=null;c&&(y=new ResizeObserver((t=>{let[o]=t;o&&o.target===f&&y&&(y.unobserve(e),cancelAnimationFrame(m),m=requestAnimationFrame((()=>{y&&y.observe(e);}))),n();})),f&&!s&&y.observe(f),y.observe(e));let w=s?R(t):null;return s&&function e(){const o=R(t);!w||o.x===w.x&&o.y===w.y&&o.width===w.width&&o.height===w.height||n();w=o,d=requestAnimationFrame(e);}(),n(),()=>{u.forEach((t=>{i&&t.removeEventListener("scroll",n),r&&t.removeEventListener("resize",n);})),a&&a(),y&&y.disconnect(),y=null,s&&cancelAnimationFrame(d);}}const B=(t,n,o)=>{const i=new Map,r={platform:V,...o},c={...r.platform,_c:i};return r$1(t,n,{...r,platform:c})};
|
|
11
|
+
|
|
12
|
+
var __defProp = Object.defineProperty;
|
|
13
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
14
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
15
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
16
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
17
|
+
if (decorator = decorators[i])
|
|
18
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
19
|
+
if (kind && result)
|
|
20
|
+
__defProp(target, key, result);
|
|
21
|
+
return result;
|
|
22
|
+
};
|
|
23
|
+
class Popup extends FoundationElement {
|
|
24
|
+
constructor() {
|
|
25
|
+
super(...arguments);
|
|
26
|
+
this.open = false;
|
|
27
|
+
this.dismissible = false;
|
|
28
|
+
this.arrow = false;
|
|
29
|
+
this.alternate = false;
|
|
30
|
+
this.strategy = "fixed";
|
|
31
|
+
}
|
|
32
|
+
get #middleware() {
|
|
33
|
+
let middleware = [D$1(), A$1(), E$1()];
|
|
34
|
+
if (this.arrow) {
|
|
35
|
+
middleware = [L$1(12), ...middleware, g$1({ element: this.arrowEl, padding: 10 })];
|
|
36
|
+
}
|
|
37
|
+
return middleware;
|
|
38
|
+
}
|
|
39
|
+
#cleanup;
|
|
40
|
+
openChanged(_, newValue) {
|
|
41
|
+
newValue ? this.$emit("vwc-popup:open") : this.$emit("vwc-popup:close");
|
|
42
|
+
}
|
|
43
|
+
disconnectedCallback() {
|
|
44
|
+
super.disconnectedCallback();
|
|
45
|
+
this.#cleanup?.();
|
|
46
|
+
}
|
|
47
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
48
|
+
super.attributeChangedCallback(name, oldValue, newValue);
|
|
49
|
+
this.#cleanup?.();
|
|
50
|
+
if (this.anchorEl && this.popupEl) {
|
|
51
|
+
this.#cleanup = A(this.anchorEl, this.popupEl, () => this.updatePosition());
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Updates popup's position
|
|
56
|
+
*
|
|
57
|
+
* @public
|
|
58
|
+
*/
|
|
59
|
+
async updatePosition() {
|
|
60
|
+
if (!this.open || !this.anchorEl) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const positionData = await B(this.anchorEl, this.popupEl, {
|
|
64
|
+
placement: this.placement,
|
|
65
|
+
strategy: this.strategy,
|
|
66
|
+
middleware: this.#middleware
|
|
67
|
+
});
|
|
68
|
+
this.#assignPopupPosition(positionData);
|
|
69
|
+
if (this.arrow) {
|
|
70
|
+
this.#assignArrowPosition(positionData);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
#assignPopupPosition(data) {
|
|
74
|
+
const { x: popupX, y: popupY } = data;
|
|
75
|
+
const { referenceHidden } = data.middlewareData.hide;
|
|
76
|
+
Object.assign(this.popupEl.style, {
|
|
77
|
+
left: `${popupX}px`,
|
|
78
|
+
top: `${popupY}px`,
|
|
79
|
+
visibility: referenceHidden ? "hidden" : "visible"
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
#assignArrowPosition(data) {
|
|
83
|
+
const { x: arrowX, y: arrowY } = data.middlewareData.arrow;
|
|
84
|
+
const styles = {
|
|
85
|
+
"left": "calc(100% - 4px)",
|
|
86
|
+
"right": "-4px",
|
|
87
|
+
"top": "calc(100% - 4px)",
|
|
88
|
+
"bottom": "-4px"
|
|
89
|
+
};
|
|
90
|
+
const staticAxis = data.placement.split("-")[0];
|
|
91
|
+
Object.assign(this.arrowEl.style, {
|
|
92
|
+
left: arrowX ? `${arrowX}px` : styles[staticAxis],
|
|
93
|
+
top: arrowY ? `${arrowY}px` : styles[staticAxis]
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Gets the anchor element by id
|
|
98
|
+
*/
|
|
99
|
+
get anchorEl() {
|
|
100
|
+
return this.anchor instanceof HTMLElement ? this.anchor : document.getElementById(this.anchor ? this.anchor : "");
|
|
101
|
+
}
|
|
102
|
+
show() {
|
|
103
|
+
this.open = true;
|
|
104
|
+
}
|
|
105
|
+
hide() {
|
|
106
|
+
this.open = false;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
__decorateClass([
|
|
110
|
+
attr({
|
|
111
|
+
mode: "boolean"
|
|
112
|
+
})
|
|
113
|
+
], Popup.prototype, "open", 2);
|
|
114
|
+
__decorateClass([
|
|
115
|
+
attr({
|
|
116
|
+
mode: "boolean"
|
|
117
|
+
})
|
|
118
|
+
], Popup.prototype, "dismissible", 2);
|
|
119
|
+
__decorateClass([
|
|
120
|
+
attr({
|
|
121
|
+
mode: "boolean"
|
|
122
|
+
})
|
|
123
|
+
], Popup.prototype, "arrow", 2);
|
|
124
|
+
__decorateClass([
|
|
125
|
+
attr({
|
|
126
|
+
mode: "boolean"
|
|
127
|
+
})
|
|
128
|
+
], Popup.prototype, "alternate", 2);
|
|
129
|
+
__decorateClass([
|
|
130
|
+
attr({ mode: "fromView" })
|
|
131
|
+
], Popup.prototype, "placement", 2);
|
|
132
|
+
__decorateClass([
|
|
133
|
+
attr({ mode: "fromView" })
|
|
134
|
+
], Popup.prototype, "strategy", 2);
|
|
135
|
+
__decorateClass([
|
|
136
|
+
attr
|
|
137
|
+
], Popup.prototype, "anchor", 2);
|
|
138
|
+
|
|
139
|
+
const styles = ".control {\n background: var(--vvd-color-surface-4dp);\n border-radius: inherit;\n contain: layout;\n}\n.control:not(.open) {\n display: none;\n}\n\n.popup-wrapper {\n z-index: 10;\n border-radius: 6px;\n inline-size: fit-content;\n}\n.popup-wrapper:not(.absolute) {\n position: fixed;\n}\n.popup-wrapper.absolute {\n position: absolute;\n}\n\n.popup-content {\n display: grid;\n color: var(--vvd-color-canvas-text); /* neutral-100 */\n}\n.dismissible .popup-content {\n align-content: start;\n grid-template-columns: 1fr auto;\n}\n\n.arrow {\n position: absolute;\n z-index: -1;\n width: 8px;\n height: 8px;\n background: var(--vvd-color-surface-4dp);\n transform: rotate(45deg);\n}\n\n.dismissible-button {\n align-self: flex-start;\n margin-block-start: 4px;\n margin-inline-end: 4px;\n}";
|
|
140
|
+
|
|
141
|
+
const getClasses = ({
|
|
142
|
+
open,
|
|
143
|
+
dismissible,
|
|
144
|
+
alternate
|
|
145
|
+
}) => classNames(
|
|
146
|
+
"control",
|
|
147
|
+
["open", Boolean(open)],
|
|
148
|
+
["dismissible", Boolean(dismissible)],
|
|
149
|
+
["alternate", Boolean(alternate)]
|
|
150
|
+
);
|
|
151
|
+
const popupTemplate = (context) => {
|
|
152
|
+
const elevationTag = context.tagFor(Elevation);
|
|
153
|
+
const buttonTag = context.tagFor(Button);
|
|
154
|
+
return html`
|
|
155
|
+
<${elevationTag}>
|
|
156
|
+
<div class="popup-wrapper ${(x) => x.strategy}" ${ref("popupEl")} part="popup-base">
|
|
157
|
+
<div class="${getClasses}" aria-hidden="${(x) => x.open ? "false" : "true"}"
|
|
158
|
+
part="${(x) => x.alternate ? "vvd-theme-alternate" : ""}">
|
|
159
|
+
<div class="popup-content">
|
|
160
|
+
<slot></slot>
|
|
161
|
+
${when(
|
|
162
|
+
(x) => x.dismissible,
|
|
163
|
+
html`<${buttonTag} size="condensed" @click="${(x) => x.open = false}"
|
|
164
|
+
class="dismissible-button" icon="close-small-solid" shape="pill"></${buttonTag}>`
|
|
165
|
+
)}
|
|
166
|
+
</div>
|
|
167
|
+
${when((x) => x.arrow, html`<div class="arrow" ${ref("arrowEl")}></div>`)}
|
|
168
|
+
</div>
|
|
169
|
+
</div>
|
|
170
|
+
</${elevationTag}>`;
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
const popupDefinition = Popup.compose({
|
|
174
|
+
baseName: "popup",
|
|
175
|
+
template: popupTemplate,
|
|
176
|
+
styles
|
|
177
|
+
});
|
|
178
|
+
const popupRegistries = [popupDefinition(), ...elevationRegistries, ...buttonRegistries];
|
|
179
|
+
const registerPopup = registerFactory(popupRegistries);
|
|
180
|
+
|
|
181
|
+
export { Popup as P, popupRegistries as p, registerPopup as r };
|