@vonage/vivid 3.32.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.
Files changed (218) hide show
  1. package/accordion/index.js +5 -5
  2. package/accordion-item/index.js +4 -4
  3. package/action-group/index.js +1 -1
  4. package/alert/index.js +6 -6
  5. package/avatar/index.js +2 -2
  6. package/badge/index.js +2 -2
  7. package/banner/index.js +5 -5
  8. package/breadcrumb/index.js +1 -1
  9. package/breadcrumb-item/index.js +3 -3
  10. package/button/index.js +4 -4
  11. package/calendar/index.js +1 -1
  12. package/calendar-event/index.js +1 -1
  13. package/card/index.js +3 -3
  14. package/checkbox/index.js +5 -3
  15. package/combobox/index.js +8 -8
  16. package/custom-elements.json +246 -16
  17. package/data-grid/index.js +2 -2
  18. package/date-picker/index.js +9 -9
  19. package/dialog/index.js +6 -6
  20. package/divider/index.js +1 -1
  21. package/elevation/index.js +1 -1
  22. package/empty-state/index.js +2 -2
  23. package/fab/index.js +4 -4
  24. package/file-picker/index.js +5 -5
  25. package/focus/index.js +1 -1
  26. package/header/index.js +2 -2
  27. package/icon/index.js +1 -1
  28. package/index.js +59 -59
  29. package/layout/index.js +1 -1
  30. package/lib/calendar/calendar.d.ts +1 -1
  31. package/lib/date-picker/calendar/dateStr.d.ts +1 -0
  32. package/lib/date-picker/calendar/month.d.ts +1 -0
  33. package/lib/date-picker/calendar/year.d.ts +2 -0
  34. package/lib/date-picker/date-picker.d.ts +2 -0
  35. package/lib/icon/icon.d.ts +0 -1
  36. package/lib/listbox/listbox.d.ts +9 -1
  37. package/lib/text-field/text-field.d.ts +1 -0
  38. package/listbox/index.js +20 -16
  39. package/locales/en-GB.js +48 -14
  40. package/locales/en-US.js +48 -14
  41. package/locales/ja-JP.js +48 -14
  42. package/locales/zh-CN.js +48 -14
  43. package/menu/index.js +8 -8
  44. package/menu-item/index.js +4 -4
  45. package/nav/index.js +1 -1
  46. package/nav-disclosure/index.js +3 -3
  47. package/nav-item/index.js +3 -3
  48. package/note/index.js +2 -3
  49. package/number-field/index.js +6 -6
  50. package/option/index.js +3 -3
  51. package/package.json +2 -16
  52. package/pagination/index.js +5 -5
  53. package/popup/index.js +6 -6
  54. package/progress/index.js +1 -1
  55. package/progress-ring/index.js +1 -1
  56. package/radio/index.js +2 -2
  57. package/radio-group/index.js +1 -1
  58. package/select/index.js +8 -8
  59. package/shared/affix.js +25 -9
  60. package/shared/apply-mixins.js +1 -1
  61. package/shared/breadcrumb-item.js +5 -5
  62. package/shared/button.js +13 -13
  63. package/shared/calendar-event.js +36 -16
  64. package/shared/definition.js +133 -194
  65. package/shared/definition10.js +225 -40
  66. package/shared/definition11.js +36 -32
  67. package/shared/definition12.js +763 -98
  68. package/shared/definition13.js +125 -89
  69. package/shared/definition14.js +207 -27
  70. package/shared/definition15.js +710 -731
  71. package/shared/definition16.js +1289 -47
  72. package/shared/definition17.js +6113 -93
  73. package/shared/definition18.js +242 -164
  74. package/shared/definition19.js +47 -692
  75. package/shared/definition2.js +199 -117
  76. package/shared/definition20.js +59 -1671
  77. package/shared/definition21.js +95 -255
  78. package/shared/definition22.js +2218 -1167
  79. package/shared/definition23.js +61 -5784
  80. package/shared/definition24.js +28 -117
  81. package/shared/definition25.js +52 -66
  82. package/shared/definition26.js +391 -214
  83. package/shared/definition27.js +441 -34
  84. package/shared/definition28.js +85 -73
  85. package/shared/definition29.js +21 -2283
  86. package/shared/definition3.js +61 -24
  87. package/shared/definition30.js +13 -49
  88. package/shared/definition31.js +54 -39
  89. package/shared/definition32.js +413 -375
  90. package/shared/definition33.js +223 -304
  91. package/shared/definition34.js +197 -13
  92. package/shared/definition35.js +88 -73
  93. package/shared/definition36.js +75 -25
  94. package/shared/definition37.js +434 -34
  95. package/shared/definition38.js +32 -432
  96. package/shared/definition39.js +677 -187
  97. package/shared/definition4.js +157 -12
  98. package/shared/definition40.js +95 -48
  99. package/shared/definition41.js +577 -31
  100. package/shared/definition42.js +126 -424
  101. package/shared/definition43.js +114 -618
  102. package/shared/definition44.js +24 -80
  103. package/shared/definition45.js +71 -543
  104. package/shared/definition46.js +499 -92
  105. package/shared/definition47.js +19 -133
  106. package/shared/definition48.js +129 -52
  107. package/shared/definition49.js +281 -17
  108. package/shared/definition5.js +71 -36
  109. package/shared/definition50.js +153 -484
  110. package/shared/definition51.js +131 -98
  111. package/shared/definition52.js +131 -16
  112. package/shared/definition53.js +80 -264
  113. package/shared/definition54.js +293 -118
  114. package/shared/definition55.js +12 -117
  115. package/shared/definition56.js +39 -68
  116. package/shared/definition57.js +166 -288
  117. package/shared/definition6.js +56 -111
  118. package/shared/definition7.js +120 -195
  119. package/shared/definition8.js +58 -23
  120. package/shared/definition9.js +92 -66
  121. package/shared/focus.js +2 -1
  122. package/shared/focus2.js +1 -1
  123. package/shared/form-associated.js +2 -2
  124. package/shared/icon.js +48 -27
  125. package/shared/index.js +7 -27
  126. package/shared/index2.js +108 -80
  127. package/shared/key-codes.js +1 -1
  128. package/shared/listbox.js +88 -11
  129. package/shared/patterns/form-elements/form-elements.d.ts +4 -4
  130. package/shared/radio.js +23 -7
  131. package/shared/repeat.js +1 -1
  132. package/shared/text-anchor.js +21 -4
  133. package/shared/text-anchor.template.js +37 -40
  134. package/shared/text-field.js +2 -2
  135. package/shared/text-field2.js +15 -15
  136. package/shared/tree-item.js +12 -12
  137. package/side-drawer/index.js +1 -1
  138. package/slider/index.js +2 -2
  139. package/split-button/index.js +3 -3
  140. package/style.css +6097 -0
  141. package/styles/core/all.css +1 -1
  142. package/styles/core/theme.css +1 -1
  143. package/styles/core/typography.css +1 -1
  144. package/styles/tokens/theme-dark.css +4 -4
  145. package/styles/tokens/theme-light.css +4 -4
  146. package/styles/tokens/vivid-2-compat.css +1 -1
  147. package/switch/index.js +3 -3
  148. package/tab/index.js +3 -3
  149. package/tab-panel/index.js +1 -1
  150. package/tabs/index.js +5 -5
  151. package/tag/index.js +3 -3
  152. package/tag-group/index.js +1 -1
  153. package/text-anchor/index.js +1 -1
  154. package/text-area/index.js +3 -3
  155. package/text-field/index.js +3 -3
  156. package/toggletip/index.js +7 -7
  157. package/tooltip/index.js +7 -7
  158. package/tree-item/index.js +3 -3
  159. package/tree-view/index.js +1 -1
  160. package/lib/accordion/index.d.ts +0 -1
  161. package/lib/accordion-item/index.d.ts +0 -1
  162. package/lib/action-group/index.d.ts +0 -1
  163. package/lib/alert/index.d.ts +0 -1
  164. package/lib/avatar/index.d.ts +0 -1
  165. package/lib/badge/index.d.ts +0 -1
  166. package/lib/banner/index.d.ts +0 -1
  167. package/lib/breadcrumb/index.d.ts +0 -1
  168. package/lib/breadcrumb-item/index.d.ts +0 -1
  169. package/lib/button/index.d.ts +0 -1
  170. package/lib/calendar/index.d.ts +0 -1
  171. package/lib/calendar-event/index.d.ts +0 -1
  172. package/lib/card/index.d.ts +0 -1
  173. package/lib/checkbox/index.d.ts +0 -1
  174. package/lib/combobox/index.d.ts +0 -1
  175. package/lib/data-grid/index.d.ts +0 -1
  176. package/lib/date-picker/index.d.ts +0 -1
  177. package/lib/dialog/index.d.ts +0 -1
  178. package/lib/divider/index.d.ts +0 -1
  179. package/lib/elevation/index.d.ts +0 -1
  180. package/lib/empty-state/index.d.ts +0 -1
  181. package/lib/fab/index.d.ts +0 -1
  182. package/lib/file-picker/index.d.ts +0 -1
  183. package/lib/focus/index.d.ts +0 -1
  184. package/lib/header/index.d.ts +0 -1
  185. package/lib/icon/index.d.ts +0 -1
  186. package/lib/layout/index.d.ts +0 -1
  187. package/lib/listbox/index.d.ts +0 -1
  188. package/lib/menu/index.d.ts +0 -1
  189. package/lib/menu-item/index.d.ts +0 -1
  190. package/lib/nav/index.d.ts +0 -1
  191. package/lib/nav-disclosure/index.d.ts +0 -1
  192. package/lib/nav-item/index.d.ts +0 -1
  193. package/lib/note/index.d.ts +0 -1
  194. package/lib/number-field/index.d.ts +0 -1
  195. package/lib/option/index.d.ts +0 -1
  196. package/lib/pagination/index.d.ts +0 -1
  197. package/lib/popup/index.d.ts +0 -1
  198. package/lib/progress/index.d.ts +0 -1
  199. package/lib/progress-ring/index.d.ts +0 -1
  200. package/lib/radio/index.d.ts +0 -1
  201. package/lib/radio-group/index.d.ts +0 -1
  202. package/lib/select/index.d.ts +0 -1
  203. package/lib/side-drawer/index.d.ts +0 -1
  204. package/lib/slider/index.d.ts +0 -1
  205. package/lib/split-button/index.d.ts +0 -1
  206. package/lib/switch/index.d.ts +0 -1
  207. package/lib/tab/index.d.ts +0 -1
  208. package/lib/tab-panel/index.d.ts +0 -1
  209. package/lib/tabs/index.d.ts +0 -1
  210. package/lib/tag/index.d.ts +0 -1
  211. package/lib/tag-group/index.d.ts +0 -1
  212. package/lib/text-anchor/index.d.ts +0 -1
  213. package/lib/text-area/index.d.ts +0 -1
  214. package/lib/text-field/index.d.ts +0 -1
  215. package/lib/toggletip/index.d.ts +0 -1
  216. package/lib/tooltip/index.d.ts +0 -1
  217. package/lib/tree-item/index.d.ts +0 -1
  218. package/lib/tree-view/index.d.ts +0 -1
@@ -1,46 +1,453 @@
1
- import { F as FoundationElement, _ as __decorate, a as attr, b as __metadata, o as observable, h as html, r as registerFactory } from './index.js';
2
- import { i as iconRegistries } from './definition3.js';
3
- import { I as Icon } from './icon.js';
4
- import { w as when } from './when.js';
1
+ import { F as FoundationElement, D as DOM, _ as __decorate, o as observable, a as attr, h as html, r as registerFactory } from './index.js';
2
+ import { P as Popup, p as popupRegistries } from './definition57.js';
3
+ import { M as MenuItem$1, b as MenuItemRole, c as roleForMenuItem, a as menuItemRegistries } from './definition26.js';
4
+ import { i as isHTMLElement } from './dom.js';
5
+ import { c as keyHome, b as keyEnd, e as keyArrowUp, d as keyArrowDown } from './key-codes.js';
5
6
  import { s as slotted } from './slotted.js';
6
7
  import { c as classNames } from './class-names.js';
7
8
 
8
- var css_248z = "/**\n * Do not edit directly\n * Generated on Tue, 22 Aug 2023 13:37:39 GMT\n */\n:host {\n display: block;\n}\n\n.base {\n display: flex;\n box-sizing: border-box;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n block-size: 100%;\n gap: 24px;\n}\n\n.icon-container {\n display: flex;\n align-items: center;\n justify-content: center;\n background-color: var(--vvd-color-neutral-100);\n block-size: 120px;\n border-radius: 50%;\n inline-size: 120px;\n}\n\n.content {\n display: flex;\n flex-direction: column;\n font: var(--vvd-typography-base);\n gap: 8px;\n text-align: center;\n}\n\nheader {\n font: var(--vvd-typography-base-bold);\n}\n\n.actions {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n justify-content: center;\n gap: 8px;\n}\n.base.no-actions .actions {\n display: none;\n}";
9
+ /**
10
+ * A Menu Custom HTML Element.
11
+ * Implements the {@link https://www.w3.org/TR/wai-aria-1.1/#menu | ARIA menu }.
12
+ *
13
+ * @slot - The default slot for the menu items
14
+ *
15
+ * @public
16
+ */
17
+ let Menu$1 = class Menu extends FoundationElement {
18
+ constructor() {
19
+ super(...arguments);
20
+ this.expandedItem = null;
21
+ /**
22
+ * The index of the focusable element in the items array
23
+ * defaults to -1
24
+ */
25
+ this.focusIndex = -1;
26
+ /**
27
+ * @internal
28
+ */
29
+ this.isNestedMenu = () => {
30
+ return (this.parentElement !== null &&
31
+ isHTMLElement(this.parentElement) &&
32
+ this.parentElement.getAttribute("role") === "menuitem");
33
+ };
34
+ /**
35
+ * if focus is moving out of the menu, reset to a stable initial state
36
+ * @internal
37
+ */
38
+ this.handleFocusOut = (e) => {
39
+ if (!this.contains(e.relatedTarget) && this.menuItems !== undefined) {
40
+ this.collapseExpandedItem();
41
+ // find our first focusable element
42
+ const focusIndex = this.menuItems.findIndex(this.isFocusableElement);
43
+ // set the current focus index's tabindex to -1
44
+ this.menuItems[this.focusIndex].setAttribute("tabindex", "-1");
45
+ // set the first focusable element tabindex to 0
46
+ this.menuItems[focusIndex].setAttribute("tabindex", "0");
47
+ // set the focus index
48
+ this.focusIndex = focusIndex;
49
+ }
50
+ };
51
+ this.handleItemFocus = (e) => {
52
+ const targetItem = e.target;
53
+ if (this.menuItems !== undefined &&
54
+ targetItem !== this.menuItems[this.focusIndex]) {
55
+ this.menuItems[this.focusIndex].setAttribute("tabindex", "-1");
56
+ this.focusIndex = this.menuItems.indexOf(targetItem);
57
+ targetItem.setAttribute("tabindex", "0");
58
+ }
59
+ };
60
+ this.handleExpandedChanged = (e) => {
61
+ if (e.defaultPrevented ||
62
+ e.target === null ||
63
+ this.menuItems === undefined ||
64
+ this.menuItems.indexOf(e.target) < 0) {
65
+ return;
66
+ }
67
+ e.preventDefault();
68
+ const changedItem = e.target;
69
+ // closing an expanded item without opening another
70
+ if (this.expandedItem !== null &&
71
+ changedItem === this.expandedItem &&
72
+ changedItem.expanded === false) {
73
+ this.expandedItem = null;
74
+ return;
75
+ }
76
+ if (changedItem.expanded) {
77
+ if (this.expandedItem !== null && this.expandedItem !== changedItem) {
78
+ this.expandedItem.expanded = false;
79
+ }
80
+ this.menuItems[this.focusIndex].setAttribute("tabindex", "-1");
81
+ this.expandedItem = changedItem;
82
+ this.focusIndex = this.menuItems.indexOf(changedItem);
83
+ changedItem.setAttribute("tabindex", "0");
84
+ }
85
+ };
86
+ this.removeItemListeners = () => {
87
+ if (this.menuItems !== undefined) {
88
+ this.menuItems.forEach((item) => {
89
+ item.removeEventListener("expanded-change", this.handleExpandedChanged);
90
+ item.removeEventListener("focus", this.handleItemFocus);
91
+ });
92
+ }
93
+ };
94
+ this.setItems = () => {
95
+ const newItems = this.domChildren();
96
+ this.removeItemListeners();
97
+ this.menuItems = newItems;
98
+ const menuItems = this.menuItems.filter(this.isMenuItemElement);
99
+ // if our focus index is not -1 we have items
100
+ if (menuItems.length) {
101
+ this.focusIndex = 0;
102
+ }
103
+ function elementIndent(el) {
104
+ const role = el.getAttribute("role");
105
+ const startSlot = el.querySelector("[slot=start]");
106
+ if (role !== MenuItemRole.menuitem && startSlot === null) {
107
+ return 1;
108
+ }
109
+ else if (role === MenuItemRole.menuitem && startSlot !== null) {
110
+ return 1;
111
+ }
112
+ else if (role !== MenuItemRole.menuitem && startSlot !== null) {
113
+ return 2;
114
+ }
115
+ else {
116
+ return 0;
117
+ }
118
+ }
119
+ const indent = menuItems.reduce((accum, current) => {
120
+ const elementValue = elementIndent(current);
121
+ return accum > elementValue ? accum : elementValue;
122
+ }, 0);
123
+ menuItems.forEach((item, index) => {
124
+ item.setAttribute("tabindex", index === 0 ? "0" : "-1");
125
+ item.addEventListener("expanded-change", this.handleExpandedChanged);
126
+ item.addEventListener("focus", this.handleItemFocus);
127
+ if (item instanceof MenuItem$1) {
128
+ item.startColumnCount = indent;
129
+ }
130
+ });
131
+ };
132
+ /**
133
+ * handle change from child element
134
+ */
135
+ this.changeHandler = (e) => {
136
+ if (this.menuItems === undefined) {
137
+ return;
138
+ }
139
+ const changedMenuItem = e.target;
140
+ const changeItemIndex = this.menuItems.indexOf(changedMenuItem);
141
+ if (changeItemIndex === -1) {
142
+ return;
143
+ }
144
+ if (changedMenuItem.role === "menuitemradio" &&
145
+ changedMenuItem.checked === true) {
146
+ for (let i = changeItemIndex - 1; i >= 0; --i) {
147
+ const item = this.menuItems[i];
148
+ const role = item.getAttribute("role");
149
+ if (role === MenuItemRole.menuitemradio) {
150
+ item.checked = false;
151
+ }
152
+ if (role === "separator") {
153
+ break;
154
+ }
155
+ }
156
+ const maxIndex = this.menuItems.length - 1;
157
+ for (let i = changeItemIndex + 1; i <= maxIndex; ++i) {
158
+ const item = this.menuItems[i];
159
+ const role = item.getAttribute("role");
160
+ if (role === MenuItemRole.menuitemradio) {
161
+ item.checked = false;
162
+ }
163
+ if (role === "separator") {
164
+ break;
165
+ }
166
+ }
167
+ }
168
+ };
169
+ /**
170
+ * check if the item is a menu item
171
+ */
172
+ this.isMenuItemElement = (el) => {
173
+ return (isHTMLElement(el) &&
174
+ Menu.focusableElementRoles.hasOwnProperty(el.getAttribute("role")));
175
+ };
176
+ /**
177
+ * check if the item is focusable
178
+ */
179
+ this.isFocusableElement = (el) => {
180
+ return this.isMenuItemElement(el);
181
+ };
182
+ }
183
+ itemsChanged(oldValue, newValue) {
184
+ // only update children after the component is connected and
185
+ // the setItems has run on connectedCallback
186
+ // (menuItems is undefined until then)
187
+ if (this.$fastController.isConnected && this.menuItems !== undefined) {
188
+ this.setItems();
189
+ }
190
+ }
191
+ /**
192
+ * @internal
193
+ */
194
+ connectedCallback() {
195
+ super.connectedCallback();
196
+ DOM.queueUpdate(() => {
197
+ // wait until children have had a chance to
198
+ // connect before setting/checking their props/attributes
199
+ this.setItems();
200
+ });
201
+ this.addEventListener("change", this.changeHandler);
202
+ }
203
+ /**
204
+ * @internal
205
+ */
206
+ disconnectedCallback() {
207
+ super.disconnectedCallback();
208
+ this.removeItemListeners();
209
+ this.menuItems = undefined;
210
+ this.removeEventListener("change", this.changeHandler);
211
+ }
212
+ /**
213
+ * Focuses the first item in the menu.
214
+ *
215
+ * @public
216
+ */
217
+ focus() {
218
+ this.setFocus(0, 1);
219
+ }
220
+ /**
221
+ * Collapses any expanded menu items.
222
+ *
223
+ * @public
224
+ */
225
+ collapseExpandedItem() {
226
+ if (this.expandedItem !== null) {
227
+ this.expandedItem.expanded = false;
228
+ this.expandedItem = null;
229
+ }
230
+ }
231
+ /**
232
+ * @internal
233
+ */
234
+ handleMenuKeyDown(e) {
235
+ if (e.defaultPrevented || this.menuItems === undefined) {
236
+ return;
237
+ }
238
+ switch (e.key) {
239
+ case keyArrowDown:
240
+ // go forward one index
241
+ this.setFocus(this.focusIndex + 1, 1);
242
+ return;
243
+ case keyArrowUp:
244
+ // go back one index
245
+ this.setFocus(this.focusIndex - 1, -1);
246
+ return;
247
+ case keyEnd:
248
+ // set focus on last item
249
+ this.setFocus(this.menuItems.length - 1, -1);
250
+ return;
251
+ case keyHome:
252
+ // set focus on first item
253
+ this.setFocus(0, 1);
254
+ return;
255
+ default:
256
+ // if we are not handling the event, do not prevent default
257
+ return true;
258
+ }
259
+ }
260
+ /**
261
+ * get an array of valid DOM children
262
+ */
263
+ domChildren() {
264
+ return Array.from(this.children).filter(child => !child.hasAttribute("hidden"));
265
+ }
266
+ setFocus(focusIndex, adjustment) {
267
+ if (this.menuItems === undefined) {
268
+ return;
269
+ }
270
+ while (focusIndex >= 0 && focusIndex < this.menuItems.length) {
271
+ const child = this.menuItems[focusIndex];
272
+ if (this.isFocusableElement(child)) {
273
+ // change the previous index to -1
274
+ if (this.focusIndex > -1 &&
275
+ this.menuItems.length >= this.focusIndex - 1) {
276
+ this.menuItems[this.focusIndex].setAttribute("tabindex", "-1");
277
+ }
278
+ // update the focus index
279
+ this.focusIndex = focusIndex;
280
+ // update the tabindex of next focusable element
281
+ child.setAttribute("tabindex", "0");
282
+ // focus the element
283
+ child.focus();
284
+ break;
285
+ }
286
+ focusIndex += adjustment;
287
+ }
288
+ }
289
+ };
290
+ Menu$1.focusableElementRoles = roleForMenuItem;
291
+ __decorate([
292
+ observable
293
+ ], Menu$1.prototype, "items", void 0);
9
294
 
10
- class EmptyState extends FoundationElement {}
11
- __decorate([attr, __metadata("design:type", String)], EmptyState.prototype, "headline", void 0);
12
- __decorate([attr, __metadata("design:type", String)], EmptyState.prototype, "icon", void 0);
13
- __decorate([observable, __metadata("design:type", Array)], EmptyState.prototype, "slottedActionItems", void 0);
295
+ const styles = "/**\n * Do not edit directly\n * Generated on Mon, 04 Sep 2023 12:44:18 GMT\n */\n.base {\n display: flex;\n box-sizing: border-box;\n flex-direction: column;\n gap: 8px;\n inline-size: max-content;\n max-block-size: var(--menu-block-size, 408px);\n max-inline-size: var(--menu-max-inline-size);\n min-inline-size: var(--menu-min-inline-size);\n overflow-x: hidden;\n overflow-y: auto;\n padding-block: 8px;\n}\n\n::slotted(a) {\n color: var(--vvd-color-canvas-text);\n text-decoration: none;\n}\n\n::slotted(a[role=menuitem]:focus) {\n display: block;\n border-radius: 6px;\n box-shadow: inset 0 0 0 3px currentColor;\n outline: 2px solid currentColor;\n outline-offset: -2px;\n}\n\n.header {\n padding-block-start: 8px;\n padding-inline: 16px;\n}\n.hide-header .header {\n display: none;\n}\n\n.hide-body .body {\n display: none;\n}\n\n.action-items {\n display: flex;\n justify-content: flex-end;\n gap: 8px;\n padding-inline: 8px;\n}\n.hide-actions .action-items {\n display: none;\n}";
14
296
 
15
- const getClasses = x => {
16
- var _a;
17
- return classNames('base', ['no-actions', ((_a = x.slottedActionItems) === null || _a === void 0 ? void 0 : _a.length) === 0]);
297
+ var __defProp = Object.defineProperty;
298
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
299
+ var __decorateClass = (decorators, target, key, kind) => {
300
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
301
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
302
+ if (decorator = decorators[i])
303
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
304
+ if (kind && result)
305
+ __defProp(target, key, result);
306
+ return result;
18
307
  };
19
- const EmptyStateTemplate = context => {
20
- const iconTag = context.tagFor(Icon);
308
+ class Menu extends Menu$1 {
309
+ constructor() {
310
+ super(...arguments);
311
+ this.#anchorEl = null;
312
+ this.#observeMissingAnchor = (anchorId) => {
313
+ this.#observer = new MutationObserver(() => {
314
+ const anchor = document.getElementById(anchorId);
315
+ if (anchor) {
316
+ this.#anchorEl = anchor;
317
+ this.#setupAnchor(this.#anchorEl);
318
+ this.#observer.disconnect();
319
+ this.#observer = void 0;
320
+ }
321
+ });
322
+ this.#observer.observe(document.body, { childList: true, subtree: true });
323
+ };
324
+ this.placement = "bottom";
325
+ this.anchor = "";
326
+ this.autoDismiss = false;
327
+ this.open = false;
328
+ this.#openIfClosed = () => {
329
+ if (!this.open)
330
+ DOM.queueUpdate(() => this.open = true);
331
+ };
332
+ this.#closeOnClickOutside = (e) => {
333
+ if (!this.contains(e.target))
334
+ this.open = false;
335
+ };
336
+ }
337
+ #observer;
338
+ #anchorEl;
339
+ #observeMissingAnchor;
340
+ anchorChanged(_, newValue) {
341
+ if (this.#anchorEl)
342
+ this.#cleanupAnchor(this.#anchorEl);
343
+ this.#observer?.disconnect();
344
+ this.#anchorEl = newValue instanceof HTMLElement ? newValue : document.getElementById(newValue);
345
+ if (this.#anchorEl) {
346
+ this.#setupAnchor(this.#anchorEl);
347
+ } else {
348
+ this.#observeMissingAnchor(newValue);
349
+ }
350
+ }
351
+ autoDismissChanged(oldValue, newValue) {
352
+ if (oldValue === void 0)
353
+ return;
354
+ if (newValue) {
355
+ document.addEventListener("click", this.#closeOnClickOutside);
356
+ } else {
357
+ document.removeEventListener("click", this.#closeOnClickOutside);
358
+ }
359
+ }
360
+ openChanged(_, newValue) {
361
+ newValue ? this.$emit("open", void 0, { bubbles: false }) : this.$emit("close", void 0, { bubbles: false });
362
+ if (this.#anchorEl) {
363
+ this.#anchorEl.ariaExpanded = this.open.toString();
364
+ }
365
+ }
366
+ disconnectedCallback() {
367
+ super.disconnectedCallback();
368
+ if (this.#anchorEl)
369
+ this.#cleanupAnchor(this.#anchorEl);
370
+ this.#observer?.disconnect();
371
+ document.removeEventListener("click", this.#closeOnClickOutside);
372
+ }
373
+ #setupAnchor(a) {
374
+ a.addEventListener("click", this.#openIfClosed, true);
375
+ a.setAttribute("aria-haspopup", "menu");
376
+ }
377
+ #cleanupAnchor(a) {
378
+ a.removeEventListener("click", this.#openIfClosed, true);
379
+ a.removeAttribute("aria-hasPopup");
380
+ }
381
+ #openIfClosed;
382
+ #closeOnClickOutside;
383
+ }
384
+ __decorateClass([
385
+ attr({ mode: "fromView" })
386
+ ], Menu.prototype, "placement", 2);
387
+ __decorateClass([
388
+ attr({ mode: "fromView" })
389
+ ], Menu.prototype, "anchor", 2);
390
+ __decorateClass([
391
+ attr({ mode: "boolean", attribute: "auto-dismiss" })
392
+ ], Menu.prototype, "autoDismiss", 2);
393
+ __decorateClass([
394
+ attr({ mode: "boolean" })
395
+ ], Menu.prototype, "open", 2);
396
+ __decorateClass([
397
+ observable
398
+ ], Menu.prototype, "headerSlottedContent", 2);
399
+ __decorateClass([
400
+ observable
401
+ ], Menu.prototype, "actionItemsSlottedContent", 2);
402
+
403
+ const getClasses = ({
404
+ headerSlottedContent,
405
+ actionItemsSlottedContent,
406
+ items
407
+ }) => classNames(
408
+ "base",
409
+ ["hide-header", !headerSlottedContent?.length],
410
+ ["hide-actions", !actionItemsSlottedContent?.length],
411
+ ["hide-body", items && !items.length]
412
+ );
413
+ const MenuTemplate = (context) => {
414
+ const popupTag = context.tagFor(Popup);
415
+ function handlePopupEvents(x, state) {
416
+ x.open = state;
417
+ }
21
418
  return html`
22
- <div class="${getClasses}">
23
- <slot name="graphic">
24
- ${when(x => x.icon, html`<div class="icon-container">
25
- <${iconTag} class="icon" name="${x => x.icon}" size="5"></${iconTag}>
26
- </div>`)}
27
- </slot>
28
- <div class="content">
29
- ${when(x => x.headline, html`<header>${x => x.headline}</header>`)}
30
- <slot></slot>
31
- </div>
32
- <div class="actions">
33
- <slot name="action-items" ${slotted('slottedActionItems')}></slot>
419
+ <template>
420
+ <${popupTag}
421
+ :placement=${(x) => x.placement}
422
+ :open=${(x) => x.open}
423
+ :anchor=${(x) => x.anchor}
424
+ @vwc-popup:open="${(x) => handlePopupEvents(x, true)}"
425
+ @vwc-popup:close="${(x) => handlePopupEvents(x, false)}"
426
+ >
427
+ <div class="${getClasses}">
428
+ <div class="header">
429
+ <slot name="header" ${slotted("headerSlottedContent")}></slot>
430
+ </div>
431
+ <div
432
+ class="body"
433
+ role="menu"
434
+ @keydown="${(x, c) => x.handleMenuKeyDown(c.event)}"
435
+ @focusout="${(x, c) => x.handleFocusOut(c.event)}"
436
+ >
437
+ <slot ${slotted("items")}></slot>
438
+ </div>
439
+ <footer class="action-items"><slot name="action-items" ${slotted("actionItemsSlottedContent")}></slot></footer>
34
440
  </div>
35
- </div>`;
441
+ </${popupTag}>
442
+ </template>`;
36
443
  };
37
444
 
38
- const emptyStateDefinition = EmptyState.compose({
39
- baseName: 'empty-state',
40
- template: EmptyStateTemplate,
41
- styles: css_248z
445
+ const menuDefinition = Menu.compose({
446
+ baseName: "menu",
447
+ template: MenuTemplate,
448
+ styles
42
449
  });
43
- const emptyStateRegistries = [emptyStateDefinition(), ...iconRegistries];
44
- const registerEmptyState = registerFactory(emptyStateRegistries);
450
+ const menuRegistries = [menuDefinition(), ...popupRegistries, ...menuItemRegistries];
451
+ const registerMenu = registerFactory(menuRegistries);
45
452
 
46
- export { emptyStateRegistries as a, emptyStateDefinition as e, registerEmptyState as r };
453
+ export { menuRegistries as a, menuDefinition as m, registerMenu as r };