@vonage/vivid 3.52.0 → 3.54.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 (299) hide show
  1. package/README.md +1 -1
  2. package/accordion/index.cjs +1 -1
  3. package/accordion/index.js +1 -1
  4. package/accordion-item/index.cjs +1 -1
  5. package/accordion-item/index.js +1 -1
  6. package/alert/index.cjs +3 -3
  7. package/alert/index.js +3 -3
  8. package/appearance-ui/index.cjs +1 -1
  9. package/appearance-ui/index.js +1 -1
  10. package/audio-player/index.cjs +3 -3
  11. package/audio-player/index.js +3 -3
  12. package/avatar/index.cjs +1 -1
  13. package/avatar/index.js +1 -1
  14. package/badge/index.cjs +1 -1
  15. package/badge/index.js +1 -1
  16. package/banner/index.cjs +2 -2
  17. package/banner/index.js +2 -2
  18. package/breadcrumb-item/index.cjs +1 -1
  19. package/breadcrumb-item/index.js +1 -1
  20. package/button/index.cjs +2 -2
  21. package/button/index.js +2 -2
  22. package/card/index.cjs +2 -2
  23. package/card/index.js +2 -2
  24. package/checkbox/index.cjs +3 -2
  25. package/checkbox/index.js +3 -2
  26. package/combobox/index.cjs +5 -5
  27. package/combobox/index.js +5 -5
  28. package/custom-elements.json +1162 -99
  29. package/data-grid/index.cjs +1 -1
  30. package/data-grid/index.js +1 -1
  31. package/date-picker/index.cjs +7 -6
  32. package/date-picker/index.js +7 -6
  33. package/date-range-picker/index.cjs +7 -6
  34. package/date-range-picker/index.js +7 -6
  35. package/dial-pad/index.cjs +33 -0
  36. package/dial-pad/index.js +31 -0
  37. package/dialog/index.cjs +4 -4
  38. package/dialog/index.js +4 -4
  39. package/divider/index.cjs +1 -1
  40. package/divider/index.js +1 -1
  41. package/elevation/index.cjs +1 -1
  42. package/elevation/index.js +1 -1
  43. package/empty-state/index.cjs +2 -2
  44. package/empty-state/index.js +2 -2
  45. package/fab/index.cjs +2 -2
  46. package/fab/index.js +2 -2
  47. package/file-picker/index.cjs +4 -3
  48. package/file-picker/index.js +4 -3
  49. package/header/index.cjs +2 -2
  50. package/header/index.js +2 -2
  51. package/icon/index.cjs +1 -1
  52. package/icon/index.js +1 -1
  53. package/index.cjs +132 -122
  54. package/index.js +46 -43
  55. package/layout/index.cjs +1 -1
  56. package/layout/index.js +1 -1
  57. package/lib/appearance-ui/appearance-ui.d.ts +1 -1
  58. package/lib/audio-player/audio-player.d.ts +4 -0
  59. package/lib/audio-player/locale.d.ts +2 -0
  60. package/lib/components.d.ts +2 -0
  61. package/lib/dial-pad/definition.d.ts +3 -0
  62. package/lib/dial-pad/dial-pad.d.ts +17 -0
  63. package/lib/dial-pad/dial-pad.template.d.ts +4 -0
  64. package/lib/dial-pad/locale.d.ts +18 -0
  65. package/lib/enums.d.ts +7 -0
  66. package/lib/menu/menu.d.ts +1 -0
  67. package/lib/nav-disclosure/nav-disclosure.d.ts +5 -0
  68. package/lib/text-anchor/definition.d.ts +1 -0
  69. package/lib/text-anchor/text-anchor.d.ts +5 -0
  70. package/lib/video-player/definition.d.ts +3 -0
  71. package/lib/video-player/locale.d.ts +1 -0
  72. package/lib/video-player/video-player.d.ts +17 -0
  73. package/lib/video-player/video-player.template.d.ts +4 -0
  74. package/lib/video-player/vivid-video-svg.d.ts +1 -0
  75. package/listbox/index.cjs +2 -2
  76. package/listbox/index.js +2 -2
  77. package/locales/en-GB.cjs +33 -1
  78. package/locales/en-GB.js +33 -1
  79. package/locales/en-US.cjs +201 -1
  80. package/locales/en-US.js +201 -1
  81. package/locales/ja-JP.cjs +200 -1
  82. package/locales/ja-JP.js +200 -1
  83. package/locales/zh-CN.cjs +202 -1
  84. package/locales/zh-CN.js +202 -1
  85. package/menu/index.cjs +6 -6
  86. package/menu/index.js +6 -6
  87. package/menu-item/index.cjs +2 -2
  88. package/menu-item/index.js +2 -2
  89. package/nav/index.cjs +1 -1
  90. package/nav/index.js +1 -1
  91. package/nav-disclosure/index.cjs +2 -2
  92. package/nav-disclosure/index.js +2 -2
  93. package/nav-item/index.cjs +2 -2
  94. package/nav-item/index.js +2 -2
  95. package/note/index.cjs +2 -2
  96. package/note/index.js +2 -2
  97. package/number-field/index.cjs +5 -4
  98. package/number-field/index.js +5 -4
  99. package/option/index.cjs +2 -2
  100. package/option/index.js +2 -2
  101. package/package.json +1 -1
  102. package/pagination/index.cjs +3 -3
  103. package/pagination/index.js +3 -3
  104. package/popup/index.cjs +4 -4
  105. package/popup/index.js +4 -4
  106. package/progress/index.cjs +1 -1
  107. package/progress/index.js +1 -1
  108. package/progress-ring/index.cjs +1 -1
  109. package/progress-ring/index.js +1 -1
  110. package/radio/index.cjs +1 -1
  111. package/radio/index.js +1 -1
  112. package/radio-group/index.cjs +1 -1
  113. package/radio-group/index.js +1 -1
  114. package/range-slider/index.cjs +2 -2
  115. package/range-slider/index.js +2 -2
  116. package/select/index.cjs +7 -6
  117. package/select/index.js +7 -6
  118. package/selectable-box/index.cjs +5 -4
  119. package/selectable-box/index.js +5 -4
  120. package/shared/applyMixinsWithObservables.cjs +15 -0
  121. package/shared/applyMixinsWithObservables.js +13 -0
  122. package/shared/definition.cjs +1 -1
  123. package/shared/definition.js +1 -1
  124. package/shared/definition11.cjs +3 -3
  125. package/shared/definition11.js +3 -3
  126. package/shared/definition14.cjs +2 -2
  127. package/shared/definition14.js +2 -2
  128. package/shared/definition15.cjs +8 -9
  129. package/shared/definition15.js +8 -9
  130. package/shared/definition16.cjs +3 -3
  131. package/shared/definition16.js +3 -3
  132. package/shared/definition17.cjs +2 -2
  133. package/shared/definition17.js +3 -3
  134. package/shared/definition18.cjs +3 -3
  135. package/shared/definition18.js +3 -3
  136. package/shared/definition19.cjs +3 -3
  137. package/shared/definition19.js +3 -3
  138. package/shared/definition20.cjs +196 -224
  139. package/shared/definition20.js +191 -219
  140. package/shared/definition21.cjs +264 -67
  141. package/shared/definition21.js +263 -65
  142. package/shared/definition22.cjs +66 -57
  143. package/shared/definition22.js +64 -56
  144. package/shared/definition23.cjs +42 -76
  145. package/shared/definition23.js +41 -75
  146. package/shared/definition24.cjs +70 -2402
  147. package/shared/definition24.js +69 -2401
  148. package/shared/definition25.cjs +2402 -46
  149. package/shared/definition25.js +2401 -45
  150. package/shared/definition26.cjs +63 -30
  151. package/shared/definition26.js +62 -29
  152. package/shared/definition27.cjs +28 -56
  153. package/shared/definition27.js +27 -55
  154. package/shared/definition28.cjs +35 -881
  155. package/shared/definition28.js +34 -879
  156. package/shared/definition29.cjs +922 -60
  157. package/shared/definition29.js +922 -61
  158. package/shared/definition30.cjs +68 -86
  159. package/shared/definition30.js +67 -85
  160. package/shared/definition31.cjs +98 -21
  161. package/shared/definition31.js +98 -21
  162. package/shared/definition32.cjs +24 -12
  163. package/shared/definition32.js +23 -11
  164. package/shared/definition33.cjs +11 -50
  165. package/shared/definition33.js +10 -49
  166. package/shared/definition34.cjs +26 -515
  167. package/shared/definition34.js +26 -515
  168. package/shared/definition35.cjs +448 -194
  169. package/shared/definition35.js +448 -192
  170. package/shared/definition36.cjs +256 -202
  171. package/shared/definition36.js +253 -201
  172. package/shared/definition37.cjs +204 -65
  173. package/shared/definition37.js +203 -63
  174. package/shared/definition38.cjs +63 -57
  175. package/shared/definition38.js +60 -55
  176. package/shared/definition39.cjs +65 -432
  177. package/shared/definition39.js +64 -431
  178. package/shared/definition4.cjs +2 -2
  179. package/shared/definition4.js +2 -2
  180. package/shared/definition40.cjs +441 -34
  181. package/shared/definition40.js +438 -31
  182. package/shared/definition41.cjs +34 -576
  183. package/shared/definition41.js +33 -575
  184. package/shared/definition42.cjs +531 -654
  185. package/shared/definition42.js +531 -654
  186. package/shared/definition43.cjs +690 -114
  187. package/shared/definition43.js +689 -113
  188. package/shared/definition44.cjs +124 -79
  189. package/shared/definition44.js +122 -77
  190. package/shared/definition45.cjs +78 -520
  191. package/shared/definition45.js +77 -518
  192. package/shared/definition46.cjs +520 -119
  193. package/shared/definition46.js +518 -118
  194. package/shared/definition47.cjs +118 -135
  195. package/shared/definition47.js +117 -134
  196. package/shared/definition48.cjs +151 -19
  197. package/shared/definition48.js +150 -18
  198. package/shared/definition49.cjs +21 -84
  199. package/shared/definition49.js +20 -83
  200. package/shared/definition5.cjs +100 -19
  201. package/shared/definition5.js +100 -19
  202. package/shared/definition50.cjs +52 -505
  203. package/shared/definition50.js +51 -504
  204. package/shared/definition51.cjs +526 -28
  205. package/shared/definition51.js +525 -27
  206. package/shared/definition52.cjs +28 -123
  207. package/shared/definition52.js +26 -122
  208. package/shared/definition53.cjs +110 -309
  209. package/shared/definition53.js +110 -308
  210. package/shared/definition54.cjs +255 -271
  211. package/shared/definition54.js +255 -271
  212. package/shared/definition55.cjs +315 -776
  213. package/shared/definition55.js +314 -775
  214. package/shared/definition56.cjs +818 -107
  215. package/shared/definition56.js +817 -106
  216. package/shared/definition57.cjs +85 -55
  217. package/shared/definition57.js +84 -54
  218. package/shared/definition58.cjs +125 -72
  219. package/shared/definition58.js +124 -71
  220. package/shared/definition59.cjs +72 -285
  221. package/shared/definition59.js +73 -286
  222. package/shared/definition6.cjs +1 -1
  223. package/shared/definition6.js +1 -1
  224. package/shared/definition60.cjs +298 -39
  225. package/shared/definition60.js +297 -38
  226. package/shared/definition61.cjs +66044 -1687
  227. package/shared/definition61.js +66043 -1686
  228. package/shared/definition62.cjs +50 -0
  229. package/shared/definition62.js +46 -0
  230. package/shared/definition63.cjs +1828 -0
  231. package/shared/definition63.js +1824 -0
  232. package/shared/definition7.cjs +2 -2
  233. package/shared/definition7.js +2 -2
  234. package/shared/definition8.cjs +2 -2
  235. package/shared/definition8.js +2 -2
  236. package/shared/definition9.cjs +1 -1
  237. package/shared/definition9.js +1 -1
  238. package/shared/enums.cjs +9 -0
  239. package/shared/enums.js +9 -1
  240. package/shared/icon.cjs +20 -2
  241. package/shared/icon.js +21 -3
  242. package/shared/index2.cjs +73 -37
  243. package/shared/index2.js +73 -37
  244. package/shared/key-codes2.js +1 -1
  245. package/shared/listbox.cjs +1 -1
  246. package/shared/listbox.js +1 -1
  247. package/shared/localization/Locale.d.ts +4 -0
  248. package/shared/patterns/form-elements/form-elements.d.ts +2 -3
  249. package/shared/presentationDate.cjs +16 -5
  250. package/shared/presentationDate.js +16 -5
  251. package/shared/text-anchor.cjs +6 -0
  252. package/shared/text-anchor.js +6 -0
  253. package/shared/text-anchor.template.cjs +6 -1
  254. package/shared/text-anchor.template.js +6 -1
  255. package/shared/text-field.cjs +1 -1
  256. package/shared/text-field.js +1 -1
  257. package/shared/utils/applyMixinsWithObservables.d.ts +1 -0
  258. package/shared/utils/numberConverter.d.ts +2 -0
  259. package/side-drawer/index.cjs +1 -1
  260. package/side-drawer/index.js +1 -1
  261. package/slider/index.cjs +1 -1
  262. package/slider/index.js +1 -1
  263. package/split-button/index.cjs +2 -2
  264. package/split-button/index.js +2 -2
  265. package/styles/core/all.css +1 -1
  266. package/styles/core/theme.css +1 -1
  267. package/styles/core/typography.css +1 -1
  268. package/styles/tokens/theme-dark.css +4 -4
  269. package/styles/tokens/theme-light.css +4 -4
  270. package/styles/tokens/vivid-2-compat.css +1 -1
  271. package/switch/index.cjs +2 -2
  272. package/switch/index.js +2 -2
  273. package/tab/index.cjs +2 -2
  274. package/tab/index.js +2 -2
  275. package/tab-panel/index.cjs +1 -1
  276. package/tab-panel/index.js +1 -1
  277. package/tabs/index.cjs +4 -4
  278. package/tabs/index.js +4 -4
  279. package/tag/index.cjs +2 -2
  280. package/tag/index.js +2 -2
  281. package/tag-group/index.cjs +1 -1
  282. package/tag-group/index.js +1 -1
  283. package/text-area/index.cjs +4 -3
  284. package/text-area/index.js +4 -3
  285. package/text-field/index.cjs +4 -3
  286. package/text-field/index.js +4 -3
  287. package/time-picker/index.cjs +8 -7
  288. package/time-picker/index.js +8 -7
  289. package/toggletip/index.cjs +5 -5
  290. package/toggletip/index.js +5 -5
  291. package/tooltip/index.cjs +5 -5
  292. package/tooltip/index.js +5 -5
  293. package/tree-item/index.cjs +2 -2
  294. package/tree-item/index.js +2 -2
  295. package/tree-view/index.cjs +1 -1
  296. package/tree-view/index.js +1 -1
  297. package/video-player/index.cjs +17 -0
  298. package/video-player/index.js +15 -0
  299. package/vivid.api.json +332 -0
@@ -1,77 +1,938 @@
1
- import { h as html, r as registerFactory } from './index.js';
2
- import { P as Popup, p as popupRegistries } from './definition61.js';
3
- import { b as Menu, a as menuItemRegistries } from './definition28.js';
4
- import { a as anchorSlotTemplateFactory } from './anchored.js';
5
- import { s as slotted } from './slotted.js';
1
+ import { F as FoundationElement, D as DOM, _ as __decorate, a as attr, o as observable, h as html, r as registerFactory } from './index.js';
2
+ import { a as iconRegistries } from './definition27.js';
3
+ import { A as AffixIcon, a as affixIconTemplateFactory } from './affix.js';
4
+ import { b as anchored } from './anchored.js';
5
+ import { S as StartEnd } from './start-end.js';
6
+ import { D as Direction, g as getDirection } from './direction.js';
7
+ import { a as applyMixins } from './apply-mixins.js';
8
+ import { i as keyArrowLeft, h as keyArrowRight, a as keySpace, k as keyEnter, g as keyHome, d as keyEnd, e as keyArrowUp, f as keyArrowDown } from './key-codes.js';
9
+ import { i as isHTMLElement } from './dom.js';
10
+ import { I as Icon } from './icon.js';
11
+ import { s as slotted, e as elements } from './slotted.js';
12
+ import { w as when } from './when.js';
6
13
  import { c as classNames } from './class-names.js';
7
14
 
8
- const styles = ":host{display:var(--_popup-display, inline)}:host([slotted-anchor]){--_popup-display: contents}.base{display:flex;overflow:hidden auto;box-sizing:border-box;flex-direction:column;gap:8px;inline-size:max-content;max-block-size:var(--menu-block-size, 408px);max-inline-size:var(--menu-max-inline-size);min-inline-size:var(--menu-min-inline-size);padding-block:8px}::slotted(a){color:var(--vvd-color-canvas-text);text-decoration:none}::slotted(a[role=menuitem]:focus-visible){box-shadow:inset 0 0 0 3px var(--focus-stroke-gap-color, currentColor);outline:2px solid var(--focus-stroke-color, var(--vvd-color-canvas-text));outline-offset:calc(-2px - var(--focus-inset, 0px));--focus-stroke-gap-color: transparent;display:block;border-radius:8px}.header{padding-block-start:8px;padding-inline:16px}.hide-header .header{display:none}.body{display:flex;flex-direction:column;row-gap:1px}.hide-body .body{display:none}.action-items{display:flex;justify-content:flex-end;gap:8px;padding-inline:8px}.hide-actions .action-items{display:none}\n";
15
+ /**
16
+ * Menu items roles.
17
+ * @public
18
+ */
19
+ const MenuItemRole$1 = {
20
+ /**
21
+ * The menu item has a "menuitem" role
22
+ */
23
+ menuitem: "menuitem",
24
+ /**
25
+ * The menu item has a "menuitemcheckbox" role
26
+ */
27
+ menuitemcheckbox: "menuitemcheckbox",
28
+ /**
29
+ * The menu item has a "menuitemradio" role
30
+ */
31
+ menuitemradio: "menuitemradio",
32
+ };
33
+ /**
34
+ * @internal
35
+ */
36
+ const roleForMenuItem = {
37
+ [MenuItemRole$1.menuitem]: "menuitem",
38
+ [MenuItemRole$1.menuitemcheckbox]: "menuitemcheckbox",
39
+ [MenuItemRole$1.menuitemradio]: "menuitemradio",
40
+ };
41
+
42
+ /**
43
+ * A Switch Custom HTML Element.
44
+ * Implements {@link https://www.w3.org/TR/wai-aria-1.1/#menuitem | ARIA menuitem }, {@link https://www.w3.org/TR/wai-aria-1.1/#menuitemcheckbox | ARIA menuitemcheckbox}, or {@link https://www.w3.org/TR/wai-aria-1.1/#menuitemradio | ARIA menuitemradio }.
45
+ *
46
+ * @slot checked-indicator - The checked indicator
47
+ * @slot radio-indicator - The radio indicator
48
+ * @slot start - Content which can be provided before the menu item content
49
+ * @slot end - Content which can be provided after the menu item content
50
+ * @slot - The default slot for menu item content
51
+ * @slot expand-collapse-indicator - The expand/collapse indicator
52
+ * @slot submenu - Used to nest menu's within menu items
53
+ * @csspart input-container - The element representing the visual checked or radio indicator
54
+ * @csspart checkbox - The element wrapping the `menuitemcheckbox` indicator
55
+ * @csspart radio - The element wrapping the `menuitemradio` indicator
56
+ * @csspart content - The element wrapping the menu item content
57
+ * @csspart expand-collapse-glyph-container - The element wrapping the expand collapse element
58
+ * @csspart expand-collapse - The expand/collapse element
59
+ * @csspart submenu-region - The container for the submenu, used for positioning
60
+ * @fires expanded-change - Fires a custom 'expanded-change' event when the expanded state changes
61
+ * @fires change - Fires a custom 'change' event when a non-submenu item with a role of `menuitemcheckbox`, `menuitemradio`, or `menuitem` is invoked
62
+ *
63
+ * @public
64
+ */
65
+ let MenuItem$1 = class MenuItem extends FoundationElement {
66
+ constructor() {
67
+ super(...arguments);
68
+ /**
69
+ * The role of the element.
70
+ *
71
+ * @public
72
+ * @remarks
73
+ * HTML Attribute: role
74
+ */
75
+ this.role = MenuItemRole$1.menuitem;
76
+ /**
77
+ * @internal
78
+ */
79
+ this.hasSubmenu = false;
80
+ /**
81
+ * Track current direction to pass to the anchored region
82
+ *
83
+ * @internal
84
+ */
85
+ this.currentDirection = Direction.ltr;
86
+ this.focusSubmenuOnLoad = false;
87
+ /**
88
+ * @internal
89
+ */
90
+ this.handleMenuItemKeyDown = (e) => {
91
+ if (e.defaultPrevented) {
92
+ return false;
93
+ }
94
+ switch (e.key) {
95
+ case keyEnter:
96
+ case keySpace:
97
+ this.invoke();
98
+ return false;
99
+ case keyArrowRight:
100
+ //open/focus on submenu
101
+ this.expandAndFocus();
102
+ return false;
103
+ case keyArrowLeft:
104
+ //close submenu
105
+ if (this.expanded) {
106
+ this.expanded = false;
107
+ this.focus();
108
+ return false;
109
+ }
110
+ }
111
+ return true;
112
+ };
113
+ /**
114
+ * @internal
115
+ */
116
+ this.handleMenuItemClick = (e) => {
117
+ if (e.defaultPrevented || this.disabled) {
118
+ return false;
119
+ }
120
+ this.invoke();
121
+ return false;
122
+ };
123
+ /**
124
+ * @internal
125
+ */
126
+ this.submenuLoaded = () => {
127
+ if (!this.focusSubmenuOnLoad) {
128
+ return;
129
+ }
130
+ this.focusSubmenuOnLoad = false;
131
+ if (this.hasSubmenu) {
132
+ this.submenu.focus();
133
+ this.setAttribute("tabindex", "-1");
134
+ }
135
+ };
136
+ /**
137
+ * @internal
138
+ */
139
+ this.handleMouseOver = (e) => {
140
+ if (this.disabled || !this.hasSubmenu || this.expanded) {
141
+ return false;
142
+ }
143
+ this.expanded = true;
144
+ return false;
145
+ };
146
+ /**
147
+ * @internal
148
+ */
149
+ this.handleMouseOut = (e) => {
150
+ if (!this.expanded || this.contains(document.activeElement)) {
151
+ return false;
152
+ }
153
+ this.expanded = false;
154
+ return false;
155
+ };
156
+ /**
157
+ * @internal
158
+ */
159
+ this.expandAndFocus = () => {
160
+ if (!this.hasSubmenu) {
161
+ return;
162
+ }
163
+ this.focusSubmenuOnLoad = true;
164
+ this.expanded = true;
165
+ };
166
+ /**
167
+ * @internal
168
+ */
169
+ this.invoke = () => {
170
+ if (this.disabled) {
171
+ return;
172
+ }
173
+ switch (this.role) {
174
+ case MenuItemRole$1.menuitemcheckbox:
175
+ this.checked = !this.checked;
176
+ break;
177
+ case MenuItemRole$1.menuitem:
178
+ // update submenu
179
+ this.updateSubmenu();
180
+ if (this.hasSubmenu) {
181
+ this.expandAndFocus();
182
+ }
183
+ else {
184
+ this.$emit("change");
185
+ }
186
+ break;
187
+ case MenuItemRole$1.menuitemradio:
188
+ if (!this.checked) {
189
+ this.checked = true;
190
+ }
191
+ break;
192
+ }
193
+ };
194
+ /**
195
+ * Gets the submenu element if any
196
+ *
197
+ * @internal
198
+ */
199
+ this.updateSubmenu = () => {
200
+ this.submenu = this.domChildren().find((element) => {
201
+ return element.getAttribute("role") === "menu";
202
+ });
203
+ this.hasSubmenu = this.submenu === undefined ? false : true;
204
+ };
205
+ }
206
+ expandedChanged(oldValue) {
207
+ if (this.$fastController.isConnected) {
208
+ if (this.submenu === undefined) {
209
+ return;
210
+ }
211
+ if (this.expanded === false) {
212
+ this.submenu.collapseExpandedItem();
213
+ }
214
+ else {
215
+ this.currentDirection = getDirection(this);
216
+ }
217
+ this.$emit("expanded-change", this, { bubbles: false });
218
+ }
219
+ }
220
+ checkedChanged(oldValue, newValue) {
221
+ if (this.$fastController.isConnected) {
222
+ this.$emit("change");
223
+ }
224
+ }
225
+ /**
226
+ * @internal
227
+ */
228
+ connectedCallback() {
229
+ super.connectedCallback();
230
+ DOM.queueUpdate(() => {
231
+ this.updateSubmenu();
232
+ });
233
+ if (!this.startColumnCount) {
234
+ this.startColumnCount = 1;
235
+ }
236
+ this.observer = new MutationObserver(this.updateSubmenu);
237
+ }
238
+ /**
239
+ * @internal
240
+ */
241
+ disconnectedCallback() {
242
+ super.disconnectedCallback();
243
+ this.submenu = undefined;
244
+ if (this.observer !== undefined) {
245
+ this.observer.disconnect();
246
+ this.observer = undefined;
247
+ }
248
+ }
249
+ /**
250
+ * get an array of valid DOM children
251
+ */
252
+ domChildren() {
253
+ return Array.from(this.children).filter(child => !child.hasAttribute("hidden"));
254
+ }
255
+ };
256
+ __decorate([
257
+ attr({ mode: "boolean" })
258
+ ], MenuItem$1.prototype, "disabled", void 0);
259
+ __decorate([
260
+ attr({ mode: "boolean" })
261
+ ], MenuItem$1.prototype, "expanded", void 0);
262
+ __decorate([
263
+ observable
264
+ ], MenuItem$1.prototype, "startColumnCount", void 0);
265
+ __decorate([
266
+ attr
267
+ ], MenuItem$1.prototype, "role", void 0);
268
+ __decorate([
269
+ attr({ mode: "boolean" })
270
+ ], MenuItem$1.prototype, "checked", void 0);
271
+ __decorate([
272
+ observable
273
+ ], MenuItem$1.prototype, "submenuRegion", void 0);
274
+ __decorate([
275
+ observable
276
+ ], MenuItem$1.prototype, "hasSubmenu", void 0);
277
+ __decorate([
278
+ observable
279
+ ], MenuItem$1.prototype, "currentDirection", void 0);
280
+ __decorate([
281
+ observable
282
+ ], MenuItem$1.prototype, "submenu", void 0);
283
+ applyMixins(MenuItem$1, StartEnd);
284
+
285
+ /**
286
+ * A Menu Custom HTML Element.
287
+ * Implements the {@link https://www.w3.org/TR/wai-aria-1.1/#menu | ARIA menu }.
288
+ *
289
+ * @slot - The default slot for the menu items
290
+ *
291
+ * @public
292
+ */
293
+ let Menu$1 = class Menu extends FoundationElement {
294
+ constructor() {
295
+ super(...arguments);
296
+ this.expandedItem = null;
297
+ /**
298
+ * The index of the focusable element in the items array
299
+ * defaults to -1
300
+ */
301
+ this.focusIndex = -1;
302
+ /**
303
+ * @internal
304
+ */
305
+ this.isNestedMenu = () => {
306
+ return (this.parentElement !== null &&
307
+ isHTMLElement(this.parentElement) &&
308
+ this.parentElement.getAttribute("role") === "menuitem");
309
+ };
310
+ /**
311
+ * if focus is moving out of the menu, reset to a stable initial state
312
+ * @internal
313
+ */
314
+ this.handleFocusOut = (e) => {
315
+ if (!this.contains(e.relatedTarget) && this.menuItems !== undefined) {
316
+ this.collapseExpandedItem();
317
+ // find our first focusable element
318
+ const focusIndex = this.menuItems.findIndex(this.isFocusableElement);
319
+ // set the current focus index's tabindex to -1
320
+ this.menuItems[this.focusIndex].setAttribute("tabindex", "-1");
321
+ // set the first focusable element tabindex to 0
322
+ this.menuItems[focusIndex].setAttribute("tabindex", "0");
323
+ // set the focus index
324
+ this.focusIndex = focusIndex;
325
+ }
326
+ };
327
+ this.handleItemFocus = (e) => {
328
+ const targetItem = e.target;
329
+ if (this.menuItems !== undefined &&
330
+ targetItem !== this.menuItems[this.focusIndex]) {
331
+ this.menuItems[this.focusIndex].setAttribute("tabindex", "-1");
332
+ this.focusIndex = this.menuItems.indexOf(targetItem);
333
+ targetItem.setAttribute("tabindex", "0");
334
+ }
335
+ };
336
+ this.handleExpandedChanged = (e) => {
337
+ if (e.defaultPrevented ||
338
+ e.target === null ||
339
+ this.menuItems === undefined ||
340
+ this.menuItems.indexOf(e.target) < 0) {
341
+ return;
342
+ }
343
+ e.preventDefault();
344
+ const changedItem = e.target;
345
+ // closing an expanded item without opening another
346
+ if (this.expandedItem !== null &&
347
+ changedItem === this.expandedItem &&
348
+ changedItem.expanded === false) {
349
+ this.expandedItem = null;
350
+ return;
351
+ }
352
+ if (changedItem.expanded) {
353
+ if (this.expandedItem !== null && this.expandedItem !== changedItem) {
354
+ this.expandedItem.expanded = false;
355
+ }
356
+ this.menuItems[this.focusIndex].setAttribute("tabindex", "-1");
357
+ this.expandedItem = changedItem;
358
+ this.focusIndex = this.menuItems.indexOf(changedItem);
359
+ changedItem.setAttribute("tabindex", "0");
360
+ }
361
+ };
362
+ this.removeItemListeners = () => {
363
+ if (this.menuItems !== undefined) {
364
+ this.menuItems.forEach((item) => {
365
+ item.removeEventListener("expanded-change", this.handleExpandedChanged);
366
+ item.removeEventListener("focus", this.handleItemFocus);
367
+ });
368
+ }
369
+ };
370
+ this.setItems = () => {
371
+ const newItems = this.domChildren();
372
+ this.removeItemListeners();
373
+ this.menuItems = newItems;
374
+ const menuItems = this.menuItems.filter(this.isMenuItemElement);
375
+ // if our focus index is not -1 we have items
376
+ if (menuItems.length) {
377
+ this.focusIndex = 0;
378
+ }
379
+ function elementIndent(el) {
380
+ const role = el.getAttribute("role");
381
+ const startSlot = el.querySelector("[slot=start]");
382
+ if (role !== MenuItemRole$1.menuitem && startSlot === null) {
383
+ return 1;
384
+ }
385
+ else if (role === MenuItemRole$1.menuitem && startSlot !== null) {
386
+ return 1;
387
+ }
388
+ else if (role !== MenuItemRole$1.menuitem && startSlot !== null) {
389
+ return 2;
390
+ }
391
+ else {
392
+ return 0;
393
+ }
394
+ }
395
+ const indent = menuItems.reduce((accum, current) => {
396
+ const elementValue = elementIndent(current);
397
+ return accum > elementValue ? accum : elementValue;
398
+ }, 0);
399
+ menuItems.forEach((item, index) => {
400
+ item.setAttribute("tabindex", index === 0 ? "0" : "-1");
401
+ item.addEventListener("expanded-change", this.handleExpandedChanged);
402
+ item.addEventListener("focus", this.handleItemFocus);
403
+ if (item instanceof MenuItem$1) {
404
+ item.startColumnCount = indent;
405
+ }
406
+ });
407
+ };
408
+ /**
409
+ * handle change from child element
410
+ */
411
+ this.changeHandler = (e) => {
412
+ if (this.menuItems === undefined) {
413
+ return;
414
+ }
415
+ const changedMenuItem = e.target;
416
+ const changeItemIndex = this.menuItems.indexOf(changedMenuItem);
417
+ if (changeItemIndex === -1) {
418
+ return;
419
+ }
420
+ if (changedMenuItem.role === "menuitemradio" &&
421
+ changedMenuItem.checked === true) {
422
+ for (let i = changeItemIndex - 1; i >= 0; --i) {
423
+ const item = this.menuItems[i];
424
+ const role = item.getAttribute("role");
425
+ if (role === MenuItemRole$1.menuitemradio) {
426
+ item.checked = false;
427
+ }
428
+ if (role === "separator") {
429
+ break;
430
+ }
431
+ }
432
+ const maxIndex = this.menuItems.length - 1;
433
+ for (let i = changeItemIndex + 1; i <= maxIndex; ++i) {
434
+ const item = this.menuItems[i];
435
+ const role = item.getAttribute("role");
436
+ if (role === MenuItemRole$1.menuitemradio) {
437
+ item.checked = false;
438
+ }
439
+ if (role === "separator") {
440
+ break;
441
+ }
442
+ }
443
+ }
444
+ };
445
+ /**
446
+ * check if the item is a menu item
447
+ */
448
+ this.isMenuItemElement = (el) => {
449
+ return (isHTMLElement(el) &&
450
+ Menu.focusableElementRoles.hasOwnProperty(el.getAttribute("role")));
451
+ };
452
+ /**
453
+ * check if the item is focusable
454
+ */
455
+ this.isFocusableElement = (el) => {
456
+ return this.isMenuItemElement(el);
457
+ };
458
+ }
459
+ itemsChanged(oldValue, newValue) {
460
+ // only update children after the component is connected and
461
+ // the setItems has run on connectedCallback
462
+ // (menuItems is undefined until then)
463
+ if (this.$fastController.isConnected && this.menuItems !== undefined) {
464
+ this.setItems();
465
+ }
466
+ }
467
+ /**
468
+ * @internal
469
+ */
470
+ connectedCallback() {
471
+ super.connectedCallback();
472
+ DOM.queueUpdate(() => {
473
+ // wait until children have had a chance to
474
+ // connect before setting/checking their props/attributes
475
+ this.setItems();
476
+ });
477
+ this.addEventListener("change", this.changeHandler);
478
+ }
479
+ /**
480
+ * @internal
481
+ */
482
+ disconnectedCallback() {
483
+ super.disconnectedCallback();
484
+ this.removeItemListeners();
485
+ this.menuItems = undefined;
486
+ this.removeEventListener("change", this.changeHandler);
487
+ }
488
+ /**
489
+ * Focuses the first item in the menu.
490
+ *
491
+ * @public
492
+ */
493
+ focus() {
494
+ this.setFocus(0, 1);
495
+ }
496
+ /**
497
+ * Collapses any expanded menu items.
498
+ *
499
+ * @public
500
+ */
501
+ collapseExpandedItem() {
502
+ if (this.expandedItem !== null) {
503
+ this.expandedItem.expanded = false;
504
+ this.expandedItem = null;
505
+ }
506
+ }
507
+ /**
508
+ * @internal
509
+ */
510
+ handleMenuKeyDown(e) {
511
+ if (e.defaultPrevented || this.menuItems === undefined) {
512
+ return;
513
+ }
514
+ switch (e.key) {
515
+ case keyArrowDown:
516
+ // go forward one index
517
+ this.setFocus(this.focusIndex + 1, 1);
518
+ return;
519
+ case keyArrowUp:
520
+ // go back one index
521
+ this.setFocus(this.focusIndex - 1, -1);
522
+ return;
523
+ case keyEnd:
524
+ // set focus on last item
525
+ this.setFocus(this.menuItems.length - 1, -1);
526
+ return;
527
+ case keyHome:
528
+ // set focus on first item
529
+ this.setFocus(0, 1);
530
+ return;
531
+ default:
532
+ // if we are not handling the event, do not prevent default
533
+ return true;
534
+ }
535
+ }
536
+ /**
537
+ * get an array of valid DOM children
538
+ */
539
+ domChildren() {
540
+ return Array.from(this.children).filter(child => !child.hasAttribute("hidden"));
541
+ }
542
+ setFocus(focusIndex, adjustment) {
543
+ if (this.menuItems === undefined) {
544
+ return;
545
+ }
546
+ while (focusIndex >= 0 && focusIndex < this.menuItems.length) {
547
+ const child = this.menuItems[focusIndex];
548
+ if (this.isFocusableElement(child)) {
549
+ // change the previous index to -1
550
+ if (this.focusIndex > -1 &&
551
+ this.menuItems.length >= this.focusIndex - 1) {
552
+ this.menuItems[this.focusIndex].setAttribute("tabindex", "-1");
553
+ }
554
+ // update the focus index
555
+ this.focusIndex = focusIndex;
556
+ // update the tabindex of next focusable element
557
+ child.setAttribute("tabindex", "0");
558
+ // focus the element
559
+ child.focus();
560
+ break;
561
+ }
562
+ focusIndex += adjustment;
563
+ }
564
+ }
565
+ };
566
+ Menu$1.focusableElementRoles = roleForMenuItem;
567
+ __decorate([
568
+ observable
569
+ ], Menu$1.prototype, "items", void 0);
570
+
571
+ const styles = ":host(:focus-visible){outline:none}:host([disabled]){pointer-events:none}.base{display:flex;box-sizing:border-box;align-items:center;background-color:var(--_appearance-color-fill);box-shadow:inset 0 0 0 1px var(--_appearance-color-outline);inline-size:100%}.base{--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: transparent;--_appearance-color-outline: transparent}.base:where(.hover,:hover):where(:not(.disabled,:disabled,.readonly)){--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: var(--_connotation-color-faint);--_appearance-color-outline: transparent}.base:where(.disabled,:disabled){--_appearance-color-text: var(--vvd-color-neutral-300);--_appearance-color-fill: transparent;--_appearance-color-outline: transparent}.base:where(.active,:active):where(:not(.disabled,:disabled)){--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: var(--_connotation-color-soft);--_appearance-color-outline: transparent}.base:where(.selected):where(:not(.disabled,:disabled)){--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: var(--_connotation-color-soft);--_appearance-color-outline: transparent}.base:where(.selected):where(.hover,:hover):where(:not(.disabled,:disabled,.readonly)){--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: var(--_connotation-color-dim);--_appearance-color-outline: transparent}.base.connotation-cta{--_connotation-color-primary: var(--vvd-menu-item-cta-primary, var(--vvd-color-cta-500));--_connotation-color-primary-text: var(--vvd-menu-item-cta-primary-text, var(--vvd-color-canvas));--_connotation-color-primary-increment: var(--vvd-menu-item-cta-primary-increment, var(--vvd-color-cta-600));--_connotation-color-firm: var(--vvd-menu-item-cta-firm, var(--vvd-color-cta-600));--_connotation-color-faint: var(--vvd-menu-item-cta-faint, var(--vvd-color-cta-50));--_connotation-color-soft: var(--vvd-menu-item-cta-soft, var(--vvd-color-cta-100));--_connotation-color-pale: var(--vvd-menu-item-cta-pale, var(--vvd-color-cta-300));--_connotation-color-dim: var(--vvd-menu-item-cta-dim, var(--vvd-color-cta-200))}.base:not(.connotation-cta){--_connotation-color-primary: var(--vvd-menu-item-accent-primary, var(--vvd-color-canvas-text));--_connotation-color-primary-text: var(--vvd-menu-item-accent-primary-text, var(--vvd-color-canvas));--_connotation-color-primary-increment: var(--vvd-menu-item-accent-primary-increment, var(--vvd-color-neutral-800));--_connotation-color-firm: var(--vvd-menu-item-accent-firm, var(--vvd-color-canvas-text));--_connotation-color-faint: var(--vvd-menu-item-accent-faint, var(--vvd-color-neutral-50));--_connotation-color-soft: var(--vvd-menu-item-accent-soft, var(--vvd-color-neutral-100));--_connotation-color-pale: var(--vvd-menu-item-accent-pale, var(--vvd-color-neutral-300));--_connotation-color-dim: var(--vvd-menu-item-accent-dim, var(--vvd-color-neutral-200))}.base:not(.two-lines){gap:12px;min-block-size:calc(1px*(40 + 4*clamp(-1,var(--vvd-size-density, 0),2)));padding-block:8px;padding-inline:12px}.base.two-lines{padding:12px;gap:16px;min-block-size:calc(1px*(40 + 4*clamp(-1,var(--vvd-size-density, 0),2)) + 1px*(24 + 4*clamp(-1,var(--vvd-size-density, 0),2)))}@supports (user-select: none){.base{user-select:none}}.base:not(.disabled){cursor:pointer}:host(:not([role=presentation]):focus-visible) .base{box-shadow:inset 0 0 0 3px var(--focus-stroke-gap-color, currentColor);outline:2px solid var(--focus-stroke-color, var(--vvd-color-canvas-text));outline-offset:calc(-2px - var(--focus-inset, 0px));--focus-stroke-gap-color: transparent;border-radius:8px}.icon{flex-shrink:0;font-size:calc(1px*(40 + 4*clamp(-1,var(--vvd-size-density, 0),2))/2);line-height:1}.action,.decorative{display:flex;place-content:center}.action{color:var(--_appearance-color-text)}:host(:not([check-appearance],[aria-checked=true])) .action{color:var(--vvd-color-neutral-500)}.base.trailing .action,.base.has-meta .action{order:2}.base:not(.disabled) .decorative{color:var(--vvd-color-neutral-600)}.base.disabled .decorative{color:var(--vvd-color-neutral-200)}.base.has-meta .decorative{order:1}.chevron{order:3}.text{display:flex;overflow:hidden;flex-direction:column;gap:4px;margin-inline-end:auto}.text-primary,.text-secondary{display:-webkit-box;overflow:hidden;-webkit-box-orient:vertical;color:var(--vvd-color-canvas-text);font:var(--vvd-typography-base)}.text-primary{font:var(--vvd-typography-base);-webkit-line-clamp:var(--text-primary-line-clamp, 1)}.base.two-lines .text-primary{font:var(--vvd-typography-base-bold)}.text-secondary{font:var(--vvd-typography-base-condensed);-webkit-line-clamp:var(--text-secondary-line-clamp, 1)}.base.two-lines:not(.disabled) .text-secondary{color:var(--vvd-color-neutral-600)}.base.two-lines:not(.disabled).selected .text-secondary{color:var(--vvd-color-neutral-800)}\n";
572
+
573
+ var __defProp$1 = Object.defineProperty;
574
+ var __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor;
575
+ var __decorateClass$1 = (decorators, target, key, kind) => {
576
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target;
577
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
578
+ if (decorator = decorators[i])
579
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
580
+ if (kind && result)
581
+ __defProp$1(target, key, result);
582
+ return result;
583
+ };
584
+ var __accessCheck = (obj, member, msg) => {
585
+ if (!member.has(obj))
586
+ throw TypeError("Cannot " + msg);
587
+ };
588
+ var __privateGet = (obj, member, getter) => {
589
+ __accessCheck(obj, member, "read from private field");
590
+ return getter ? getter.call(obj) : member.get(obj);
591
+ };
592
+ var __privateAdd = (obj, member, value) => {
593
+ if (member.has(obj))
594
+ throw TypeError("Cannot add the same private member more than once");
595
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
596
+ };
597
+ var __privateMethod = (obj, member, method) => {
598
+ __accessCheck(obj, member, "access private method");
599
+ return method;
600
+ };
601
+ var _triggerBehaviour, triggerBehaviour_get, _setupAnchor, setupAnchor_fn, _updateAnchor, updateAnchor_fn, _cleanupAnchor, cleanupAnchor_fn, _onAnchorClick, _updateClickOutsideListeners, _wasOpenBeforeClick, _onClickOutsideCapture, _onClickOutside;
602
+ let Menu = class extends Menu$1 {
603
+ constructor() {
604
+ super();
605
+ __privateAdd(this, _triggerBehaviour);
606
+ __privateAdd(this, _setupAnchor);
607
+ __privateAdd(this, _updateAnchor);
608
+ __privateAdd(this, _cleanupAnchor);
609
+ this.ariaLabel = null;
610
+ this.placement = "bottom";
611
+ this.autoDismiss = false;
612
+ this.open = false;
613
+ __privateAdd(this, _onAnchorClick, () => {
614
+ if (__privateGet(this, _triggerBehaviour, triggerBehaviour_get) === "off") {
615
+ return;
616
+ }
617
+ if (__privateGet(this, _triggerBehaviour, triggerBehaviour_get) === "legacy" && this.open) {
618
+ return;
619
+ }
620
+ const newValue = !this.open;
621
+ DOM.queueUpdate(() => this.open = newValue);
622
+ });
623
+ __privateAdd(this, _updateClickOutsideListeners, () => {
624
+ document.removeEventListener("click", __privateGet(this, _onClickOutsideCapture), true);
625
+ document.removeEventListener("click", __privateGet(this, _onClickOutside));
626
+ if (this.autoDismiss && this.isConnected) {
627
+ document.addEventListener("click", __privateGet(this, _onClickOutsideCapture), true);
628
+ document.addEventListener("click", __privateGet(this, _onClickOutside));
629
+ }
630
+ });
631
+ __privateAdd(this, _wasOpenBeforeClick, /* @__PURE__ */ new WeakMap());
632
+ __privateAdd(this, _onClickOutsideCapture, (e) => {
633
+ __privateGet(this, _wasOpenBeforeClick).set(e, this.open);
634
+ });
635
+ __privateAdd(this, _onClickOutside, (e) => {
636
+ if (!this.contains(e.target) && __privateGet(this, _wasOpenBeforeClick).get(e)) {
637
+ this.open = false;
638
+ }
639
+ });
640
+ const handleFocusOut = this.handleFocusOut;
641
+ this.handleFocusOut = (e) => {
642
+ const privates2 = this;
643
+ const isSafeToCallSuper = privates2.menuItems.some(
644
+ privates2.isFocusableElement
645
+ );
646
+ if (!isSafeToCallSuper) {
647
+ return;
648
+ }
649
+ handleFocusOut(e);
650
+ };
651
+ const privates = this;
652
+ const domChildren = privates.domChildren;
653
+ privates.domChildren = () => {
654
+ return domChildren.call(this).filter((child) => !child.hasAttribute("slot"));
655
+ };
656
+ }
657
+ autoDismissChanged(oldValue) {
658
+ if (oldValue === void 0)
659
+ return;
660
+ __privateGet(this, _updateClickOutsideListeners).call(this);
661
+ }
662
+ openChanged(_, newValue) {
663
+ newValue ? this.$emit("open", void 0, { bubbles: false }) : this.$emit("close", void 0, { bubbles: false });
664
+ if (this._anchorEl) {
665
+ __privateMethod(this, _updateAnchor, updateAnchor_fn).call(this, this._anchorEl);
666
+ }
667
+ }
668
+ connectedCallback() {
669
+ super.connectedCallback();
670
+ __privateGet(this, _updateClickOutsideListeners).call(this);
671
+ }
672
+ disconnectedCallback() {
673
+ super.disconnectedCallback();
674
+ __privateGet(this, _updateClickOutsideListeners).call(this);
675
+ }
676
+ /**
677
+ * @internal
678
+ */
679
+ _anchorElChanged(oldValue, newValue) {
680
+ if (oldValue)
681
+ __privateMethod(this, _cleanupAnchor, cleanupAnchor_fn).call(this, oldValue);
682
+ if (newValue)
683
+ __privateMethod(this, _setupAnchor, setupAnchor_fn).call(this, newValue);
684
+ }
685
+ /**
686
+ * @internal
687
+ */
688
+ _onChange(e) {
689
+ const clickedOnNonCheckboxMenuItem = e.target instanceof HTMLElement && (e.target.role === "menuitem" || e.target.role === "menuitemradio");
690
+ if (__privateGet(this, _triggerBehaviour, triggerBehaviour_get) === "auto" && clickedOnNonCheckboxMenuItem) {
691
+ this.open = false;
692
+ }
693
+ return true;
694
+ }
695
+ };
696
+ _triggerBehaviour = new WeakSet();
697
+ triggerBehaviour_get = function() {
698
+ return this.trigger ?? "legacy";
699
+ };
700
+ _setupAnchor = new WeakSet();
701
+ setupAnchor_fn = function(a) {
702
+ a.addEventListener("click", __privateGet(this, _onAnchorClick), true);
703
+ a.setAttribute("aria-haspopup", "menu");
704
+ __privateMethod(this, _updateAnchor, updateAnchor_fn).call(this, a);
705
+ };
706
+ _updateAnchor = new WeakSet();
707
+ updateAnchor_fn = function(a) {
708
+ a.setAttribute("aria-expanded", this.open.toString());
709
+ };
710
+ _cleanupAnchor = new WeakSet();
711
+ cleanupAnchor_fn = function(a) {
712
+ a.removeEventListener("click", __privateGet(this, _onAnchorClick), true);
713
+ a.removeAttribute("aria-hasPopup");
714
+ a.removeAttribute("aria-expanded");
715
+ };
716
+ _onAnchorClick = new WeakMap();
717
+ _updateClickOutsideListeners = new WeakMap();
718
+ _wasOpenBeforeClick = new WeakMap();
719
+ _onClickOutsideCapture = new WeakMap();
720
+ _onClickOutside = new WeakMap();
721
+ __decorateClass$1([
722
+ attr({ attribute: "aria-label" })
723
+ ], Menu.prototype, "ariaLabel", 2);
724
+ __decorateClass$1([
725
+ attr({ mode: "fromView" })
726
+ ], Menu.prototype, "placement", 2);
727
+ __decorateClass$1([
728
+ attr
729
+ ], Menu.prototype, "trigger", 2);
730
+ __decorateClass$1([
731
+ attr({ mode: "boolean", attribute: "auto-dismiss" })
732
+ ], Menu.prototype, "autoDismiss", 2);
733
+ __decorateClass$1([
734
+ attr({ mode: "boolean" })
735
+ ], Menu.prototype, "open", 2);
736
+ __decorateClass$1([
737
+ observable
738
+ ], Menu.prototype, "headerSlottedContent", 2);
739
+ __decorateClass$1([
740
+ observable
741
+ ], Menu.prototype, "actionItemsSlottedContent", 2);
742
+ Menu = __decorateClass$1([
743
+ anchored
744
+ ], Menu);
745
+
746
+ var __defProp = Object.defineProperty;
747
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
748
+ var __decorateClass = (decorators, target, key, kind) => {
749
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
750
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
751
+ if (decorator = decorators[i])
752
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
753
+ if (kind && result)
754
+ __defProp(target, key, result);
755
+ return result;
756
+ };
757
+ const MenuItemRole = {
758
+ ...MenuItemRole$1,
759
+ presentation: "presentation"
760
+ };
761
+ var CheckAppearance = /* @__PURE__ */ ((CheckAppearance2) => {
762
+ CheckAppearance2["Normal"] = "normal";
763
+ CheckAppearance2["TickOnly"] = "tick-only";
764
+ return CheckAppearance2;
765
+ })(CheckAppearance || {});
766
+ class MenuItem extends MenuItem$1 {
767
+ constructor() {
768
+ super();
769
+ this.checkTrailing = false;
770
+ this.#submenuArray = [];
771
+ this.updateSubmenu = () => this.#updateSubmenu();
772
+ this.addEventListener("expanded-change", this.#expandedChange);
773
+ }
774
+ #submenuArray;
775
+ /**
776
+ *
777
+ *
778
+ * @internal
779
+ */
780
+ slottedSubmenuChanged(_oldValue, newValue) {
781
+ this.#submenuArray = newValue;
782
+ }
783
+ #updateSubmenu() {
784
+ for (const submenu of this.#submenuArray) {
785
+ this.submenu = submenu;
786
+ this.submenu.anchor = this;
787
+ this.submenu.placement = "right-start";
788
+ this.submenu.collapseExpandedItem = () => this.#collapseExpandedItem();
789
+ }
790
+ this.hasSubmenu = this.submenu === void 0 ? false : true;
791
+ }
792
+ #collapseExpandedItem() {
793
+ this.expanded = false;
794
+ }
795
+ #expandedChange() {
796
+ if (this.hasSubmenu) {
797
+ this.submenu.open = this.expanded;
798
+ }
799
+ }
800
+ }
801
+ __decorateClass([
802
+ attr
803
+ ], MenuItem.prototype, "text", 2);
804
+ __decorateClass([
805
+ attr({ attribute: "text-secondary" })
806
+ ], MenuItem.prototype, "textSecondary", 2);
807
+ __decorateClass([
808
+ attr
809
+ ], MenuItem.prototype, "connotation", 2);
810
+ __decorateClass([
811
+ attr({ mode: "boolean", attribute: "check-trailing" })
812
+ ], MenuItem.prototype, "checkTrailing", 2);
813
+ __decorateClass([
814
+ attr({ attribute: "check-appearance" })
815
+ ], MenuItem.prototype, "checkedAppearance", 2);
816
+ __decorateClass([
817
+ observable
818
+ ], MenuItem.prototype, "metaSlottedContent", 2);
819
+ __decorateClass([
820
+ observable
821
+ ], MenuItem.prototype, "trailingMetaSlottedContent", 2);
822
+ __decorateClass([
823
+ observable
824
+ ], MenuItem.prototype, "slottedSubmenu", 2);
825
+ applyMixins(MenuItem, AffixIcon);
9
826
 
827
+ const getIndicatorIcon = (x) => {
828
+ if (x.checkedAppearance === CheckAppearance.TickOnly) {
829
+ return x.checked ? "check-line" : "";
830
+ }
831
+ const iconType = x.role === MenuItemRole.menuitemcheckbox ? "checkbox" : "radio";
832
+ const iconStatus = x.checked ? "checked" : "unchecked";
833
+ return `${iconType}-${iconStatus}-2-line`;
834
+ };
10
835
  const getClasses = ({
11
- headerSlottedContent,
12
- actionItemsSlottedContent,
13
- items
836
+ connotation,
837
+ disabled,
838
+ checked,
839
+ role,
840
+ text: text2,
841
+ textSecondary,
842
+ icon,
843
+ metaSlottedContent,
844
+ checkTrailing
14
845
  }) => classNames(
15
846
  "base",
16
- ["hide-header", !headerSlottedContent?.length],
17
- ["hide-actions", !actionItemsSlottedContent?.length],
18
- ["hide-body", items && !items.length]
847
+ [`connotation-${connotation}`, Boolean(connotation)],
848
+ ["disabled", Boolean(disabled)],
849
+ ["selected", role !== MenuItemRole.menuitem && Boolean(checked)],
850
+ [
851
+ "trailing",
852
+ role !== MenuItemRole.menuitem && (checkTrailing || Boolean(icon))
853
+ ],
854
+ ["item-checkbox", role === MenuItemRole.menuitemcheckbox],
855
+ ["item-radio", role === MenuItemRole.menuitemradio],
856
+ ["two-lines", Boolean(text2?.length) && Boolean(textSecondary?.length)],
857
+ ["has-meta", Boolean(metaSlottedContent?.length)]
19
858
  );
20
- function handleEscapeKey(menu, event) {
21
- if (event.key === "Escape" && menu.open) {
22
- menu.open = false;
23
- }
24
- return true;
859
+ function handleClick(x, { event }) {
860
+ x.handleMenuItemClick(event);
861
+ return x.role === MenuItemRole.presentation;
25
862
  }
26
- const MenuTemplate = (context) => {
27
- const popupTag = context.tagFor(Popup);
28
- const anchorSlotTemplate = anchorSlotTemplateFactory();
29
- function handlePopupEvents(x, e, state) {
30
- e.stopPropagation();
31
- x.open = state;
32
- }
863
+ function checkIndicator(context) {
864
+ const iconTag = context.tagFor(Icon);
865
+ return html`${when(
866
+ (x) => x.role === MenuItemRole.menuitemcheckbox || x.role === MenuItemRole.menuitemradio,
867
+ html`<span class="action"><${iconTag} class="icon" name="${(x) => getIndicatorIcon(x)}"></${iconTag}></span>`
868
+ )}`;
869
+ }
870
+ function text() {
871
+ return html`${when(
872
+ (x) => x.text || x.textSecondary,
873
+ html`<span class="text">
874
+ ${when(
875
+ (x) => x.text,
876
+ html`<span class="text-primary">${(x) => x.text}</span>`
877
+ )}
878
+ ${when(
879
+ (x) => x.textSecondary,
880
+ html`<span class="text-secondary">${(x) => x.textSecondary}</span>`
881
+ )}
882
+ </span>`
883
+ )}`;
884
+ }
885
+ const MenuItemTemplate = (context) => {
886
+ const affixIconTemplate = affixIconTemplateFactory(context);
887
+ const iconTag = context.tagFor(Icon);
33
888
  return html`
34
- <template role="presentation">
35
- ${anchorSlotTemplate}
36
- <${popupTag}
37
- :placement=${(x) => x.placement}
38
- :open=${(x) => x.open}
39
- :anchor=${(x) => x._anchorEl}
40
- @keydown="${(x, c) => handleEscapeKey(x, c.event)}"
41
- @vwc-popup:open="${(x, c) => handlePopupEvents(x, c.event, true)}"
42
- @vwc-popup:close="${(x, c) => handlePopupEvents(x, c.event, false)}"
43
- >
889
+ <template
890
+ role="${(x) => x.role ? x.role : MenuItemRole.menuitem}"
891
+ aria-haspopup="${(x) => x.hasSubmenu ? "menu" : void 0}"
892
+ aria-checked="${(x) => x.role !== MenuItemRole.menuitem ? x.checked : void 0}"
893
+ aria-disabled="${(x) => x.disabled}"
894
+ aria-expanded="${(x) => x.expanded}"
895
+ @keydown="${(x, c) => x.handleMenuItemKeyDown(c.event)}"
896
+ @click="${handleClick}"
897
+ @mouseover="${(x, c) => x.handleMouseOver(c.event)}"
898
+ @mouseout="${(x, c) => x.handleMouseOut(c.event)}"
899
+ >
44
900
  <div class="${getClasses}">
45
- <div class="header">
46
- <slot name="header" ${slotted("headerSlottedContent")}></slot>
47
- </div>
48
- <div
49
- class="body"
50
- role="menu"
51
- aria-label="${(x) => x.ariaLabel}"
52
- @keydown="${(x, c) => x.handleMenuKeyDown(c.event)}"
53
- @focusout="${(x, c) => x.handleFocusOut(c.event)}"
54
- >
55
- <slot ${slotted("items")}></slot>
56
- </div>
57
- <footer class="action-items"><slot name="action-items" ${slotted(
58
- "actionItemsSlottedContent"
59
- )}></slot></footer>
901
+ <slot name="meta" ${slotted("metaSlottedContent")}></slot>
902
+ ${checkIndicator(context)}
903
+ ${when(
904
+ (x) => x.icon,
905
+ html`<span class="decorative"
906
+ >${(x) => affixIconTemplate(x.icon)}</span
907
+ >`
908
+ )}
909
+ ${text()}
910
+ <slot
911
+ name="trailing-meta"
912
+ ${slotted("trailingMetaSlottedContent")}
913
+ ></slot>
914
+ ${when(
915
+ (x) => x.hasSubmenu,
916
+ html`<${iconTag} class="chevron" name="chevron-right-line"></${iconTag}>`
917
+ )}
60
918
  </div>
61
- </${popupTag}>
62
- </template>`;
919
+ <slot
920
+ name="submenu"
921
+ ${slotted({
922
+ property: "slottedSubmenu",
923
+ filter: elements(context.tagFor(Menu))
924
+ })}
925
+ ></slot>
926
+ </template>
927
+ `;
63
928
  };
64
929
 
65
- const menuDefinition = Menu.compose({
66
- baseName: "menu",
67
- template: MenuTemplate,
930
+ const menuItemDefinition = MenuItem.compose({
931
+ baseName: "menu-item",
932
+ template: MenuItemTemplate,
68
933
  styles
69
934
  });
70
- const menuRegistries = [
71
- menuDefinition(),
72
- ...popupRegistries,
73
- ...menuItemRegistries
74
- ];
75
- const registerMenu = registerFactory(menuRegistries);
935
+ const menuItemRegistries = [menuItemDefinition(), ...iconRegistries];
936
+ const registerMenuItem = registerFactory(menuItemRegistries);
76
937
 
77
- export { menuRegistries as a, menuDefinition as m, registerMenu as r };
938
+ export { MenuItemRole as M, menuItemRegistries as a, Menu as b, menuItemDefinition as m, registerMenuItem as r };