@vonage/vivid 3.0.0-next.119 → 3.0.0-next.120

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 (201) hide show
  1. package/README.md +11 -6
  2. package/accordion/index.js +4 -51
  3. package/accordion-item/index.js +11 -109
  4. package/action-group/index.js +4 -36
  5. package/avatar/index.js +8 -64
  6. package/badge/index.js +9 -48
  7. package/banner/index.js +15 -117
  8. package/breadcrumb/index.js +5 -97
  9. package/breadcrumb-item/index.js +14 -53
  10. package/button/index.js +14 -92
  11. package/calendar/index.js +5 -1520
  12. package/calendar-event/index.js +7 -107
  13. package/card/index.js +10 -117
  14. package/checkbox/index.js +13 -175
  15. package/custom-elements.json +1827 -8
  16. package/dialog/index.js +14 -227
  17. package/divider/index.js +4 -25
  18. package/elevation/index.js +4 -24
  19. package/fab/index.js +13 -89
  20. package/focus/index.js +4 -17
  21. package/header/index.js +7 -12
  22. package/icon/index.js +7 -28
  23. package/index.js +49 -55
  24. package/layout/index.js +4 -42
  25. package/lib/accordion/definition.d.ts +3 -0
  26. package/lib/accordion/index.d.ts +1 -2
  27. package/lib/accordion-item/definition.d.ts +3 -0
  28. package/lib/accordion-item/index.d.ts +1 -2
  29. package/lib/action-group/definition.d.ts +3 -0
  30. package/lib/action-group/index.d.ts +1 -2
  31. package/lib/avatar/definition.d.ts +3 -0
  32. package/lib/avatar/index.d.ts +1 -2
  33. package/lib/badge/definition.d.ts +3 -0
  34. package/lib/badge/index.d.ts +1 -2
  35. package/lib/banner/definition.d.ts +3 -0
  36. package/lib/banner/index.d.ts +1 -2
  37. package/lib/breadcrumb/definition.d.ts +3 -0
  38. package/lib/breadcrumb/index.d.ts +1 -2
  39. package/lib/breadcrumb-item/definition.d.ts +3 -0
  40. package/lib/breadcrumb-item/index.d.ts +1 -2
  41. package/lib/button/definition.d.ts +3 -0
  42. package/lib/calendar/definition.d.ts +3 -0
  43. package/lib/calendar/index.d.ts +1 -2
  44. package/lib/calendar-event/definition.d.ts +3 -0
  45. package/lib/calendar-event/index.d.ts +1 -2
  46. package/lib/card/definition.d.ts +3 -0
  47. package/lib/card/index.d.ts +1 -2
  48. package/lib/checkbox/definition.d.ts +3 -0
  49. package/lib/checkbox/index.d.ts +1 -2
  50. package/lib/components.d.ts +38 -38
  51. package/lib/dialog/definition.d.ts +3 -0
  52. package/lib/dialog/index.d.ts +1 -2
  53. package/lib/divider/definition.d.ts +3 -0
  54. package/lib/divider/index.d.ts +1 -2
  55. package/lib/elevation/definition.d.ts +3 -0
  56. package/lib/elevation/index.d.ts +1 -2
  57. package/lib/fab/definition.d.ts +3 -0
  58. package/lib/fab/index.d.ts +1 -2
  59. package/lib/focus/definition.d.ts +3 -0
  60. package/lib/focus/index.d.ts +1 -2
  61. package/lib/header/definition.d.ts +3 -0
  62. package/lib/header/index.d.ts +1 -2
  63. package/lib/icon/definition.d.ts +3 -0
  64. package/lib/icon/index.d.ts +1 -2
  65. package/lib/layout/definition.d.ts +3 -0
  66. package/lib/layout/index.d.ts +1 -2
  67. package/lib/listbox/definition.d.ts +3 -0
  68. package/lib/menu/definition.d.ts +7 -0
  69. package/lib/menu/index.d.ts +1 -10
  70. package/lib/menu-item/definition.d.ts +3 -0
  71. package/lib/menu-item/index.d.ts +1 -2
  72. package/lib/nav/definition.d.ts +3 -0
  73. package/lib/nav/index.d.ts +1 -2
  74. package/lib/nav-disclosure/definition.d.ts +3 -0
  75. package/lib/nav-disclosure/index.d.ts +1 -2
  76. package/lib/nav-item/definition.d.ts +3 -0
  77. package/lib/nav-item/index.d.ts +1 -2
  78. package/lib/note/definition.d.ts +3 -0
  79. package/lib/note/index.d.ts +1 -2
  80. package/lib/number-field/definition.d.ts +3 -0
  81. package/lib/number-field/index.d.ts +1 -2
  82. package/lib/option/definition.d.ts +3 -0
  83. package/lib/option/index.d.ts +1 -2
  84. package/lib/popup/definition.d.ts +4 -0
  85. package/lib/popup/index.d.ts +1 -2
  86. package/lib/progress/definition.d.ts +3 -0
  87. package/lib/progress/index.d.ts +1 -2
  88. package/lib/progress-ring/definition.d.ts +3 -0
  89. package/lib/progress-ring/index.d.ts +1 -2
  90. package/lib/radio/definition.d.ts +3 -0
  91. package/lib/radio/index.d.ts +1 -2
  92. package/lib/radio-group/definition.d.ts +7 -0
  93. package/lib/radio-group/index.d.ts +1 -10
  94. package/lib/side-drawer/definition.d.ts +3 -0
  95. package/lib/side-drawer/index.d.ts +1 -2
  96. package/lib/slider/definition.d.ts +3 -0
  97. package/lib/slider/index.d.ts +1 -2
  98. package/lib/switch/definition.d.ts +3 -0
  99. package/lib/switch/index.d.ts +1 -2
  100. package/lib/text-anchor/definition.d.ts +3 -0
  101. package/lib/text-anchor/index.d.ts +1 -2
  102. package/lib/text-area/definition.d.ts +3 -0
  103. package/lib/text-area/index.d.ts +1 -2
  104. package/lib/text-field/definition.d.ts +3 -0
  105. package/lib/text-field/index.d.ts +1 -2
  106. package/lib/tooltip/definition.d.ts +3 -0
  107. package/lib/tooltip/index.d.ts +1 -2
  108. package/listbox/index.js +18 -1080
  109. package/menu/index.js +27 -354
  110. package/menu-item/index.js +11 -81
  111. package/nav/index.js +3 -16
  112. package/nav-disclosure/index.js +13 -77
  113. package/nav-item/index.js +13 -35
  114. package/note/index.js +13 -60
  115. package/number-field/index.js +14 -16
  116. package/option/index.js +13 -68
  117. package/package.json +2 -2
  118. package/popup/index.js +17 -55
  119. package/progress/index.js +6 -92
  120. package/progress-ring/index.js +6 -75
  121. package/radio/index.js +8 -48
  122. package/radio-group/index.js +9 -433
  123. package/shared/anchor.js +1 -1
  124. package/shared/apply-mixins.js +1 -1
  125. package/shared/base-progress.js +1 -1
  126. package/shared/breadcrumb-item.js +1 -1
  127. package/shared/button.js +195 -18
  128. package/shared/calendar-event.js +1 -1
  129. package/shared/definition.js +53 -0
  130. package/shared/definition10.js +99 -0
  131. package/shared/definition11.js +48 -0
  132. package/shared/definition12.js +1523 -0
  133. package/shared/definition13.js +111 -0
  134. package/shared/definition14.js +114 -0
  135. package/shared/definition15.js +32 -0
  136. package/shared/definition16.js +172 -0
  137. package/shared/definition17.js +223 -0
  138. package/shared/{divider.js → definition18.js} +25 -2
  139. package/shared/definition19.js +87 -0
  140. package/shared/definition2.js +106 -0
  141. package/shared/definition20.js +44 -0
  142. package/shared/definition21.js +1078 -0
  143. package/shared/{listbox-option.js → definition22.js} +71 -11
  144. package/shared/definition23.js +348 -0
  145. package/shared/{popup.js → definition24.js} +46 -3
  146. package/shared/{menu-item.js → definition25.js} +87 -13
  147. package/shared/definition26.js +18 -0
  148. package/shared/definition27.js +75 -0
  149. package/shared/definition28.js +31 -0
  150. package/shared/definition29.js +56 -0
  151. package/shared/definition3.js +29 -0
  152. package/shared/definition30.js +94 -0
  153. package/shared/definition31.js +77 -0
  154. package/shared/definition32.js +45 -0
  155. package/shared/definition33.js +435 -0
  156. package/shared/definition34.js +86 -0
  157. package/shared/definition35.js +592 -0
  158. package/shared/definition36.js +147 -0
  159. package/shared/definition37.js +279 -0
  160. package/shared/definition38.js +119 -0
  161. package/shared/definition39.js +77 -0
  162. package/shared/definition4.js +19 -0
  163. package/shared/definition5.js +38 -0
  164. package/shared/definition6.js +60 -0
  165. package/shared/definition7.js +45 -0
  166. package/shared/definition8.js +113 -0
  167. package/shared/definition9.js +107 -0
  168. package/shared/design-system/index.d.ts +1 -2
  169. package/shared/es.object.assign.js +58 -1
  170. package/shared/es.regexp.to-string.js +2 -1
  171. package/shared/focus.js +3 -9
  172. package/shared/focus2.js +9 -3
  173. package/shared/form-associated.js +1 -1
  174. package/shared/form-elements.js +2 -2
  175. package/shared/icon.js +1096 -9
  176. package/shared/index.js +385 -2501
  177. package/shared/patterns/form-elements/form-elements.d.ts +2 -2
  178. package/shared/radio.js +1 -1
  179. package/shared/ref.js +1 -1
  180. package/shared/slotted.js +1 -1
  181. package/shared/string-trim.js +2 -1
  182. package/shared/text-anchor.template.js +1 -1
  183. package/shared/to-string.js +51 -0
  184. package/side-drawer/index.js +5 -84
  185. package/slider/index.js +14 -593
  186. package/styles/core/all.css +1 -1
  187. package/styles/core/theme.css +1 -1
  188. package/styles/core/typography.css +1 -1
  189. package/styles/tokens/theme-dark.css +4 -4
  190. package/styles/tokens/theme-light.css +4 -4
  191. package/switch/index.js +13 -149
  192. package/text-anchor/index.js +8 -7
  193. package/text-area/index.js +16 -282
  194. package/text-field/index.js +14 -121
  195. package/tooltip/index.js +24 -82
  196. package/vivid.api.json +1640 -850
  197. package/shared/button2.js +0 -200
  198. package/shared/elevation.js +0 -10
  199. package/shared/es.promise.resolve.js +0 -944
  200. package/shared/index2.js +0 -9
  201. package/shared/utils/index.d.ts +0 -1
@@ -1,8 +1,15 @@
1
- import { F as FoundationElement, a2 as Observable, _ as __decorate, V as observable, a as attr } from './index.js';
1
+ import { F as FoundationElement, V as Observable, _ as __decorate, N as observable, a as attr, b as __metadata, h as html, r as registerFactorial } from './index.js';
2
+ import { i as iconElements } from './definition3.js';
3
+ import { f as focusElements } from './definition4.js';
4
+ import { A as AffixIconWithTrailing, a as affixIconTemplateFactory } from './affix.js';
2
5
  import { A as ARIAGlobalStatesAndProperties } from './aria-global.js';
3
6
  import { S as StartEnd } from './start-end.js';
4
7
  import { a as applyMixins } from './apply-mixins.js';
5
8
  import { i as isHTMLElement } from './dom.js';
9
+ import { f as focusTemplateFactory } from './focus2.js';
10
+ import './icon.js';
11
+ import { w as when } from './when.js';
12
+ import { c as classNames } from './class-names.js';
6
13
 
7
14
  /**
8
15
  * Determines if the element is a {@link (ListboxOption:class)}
@@ -26,7 +33,7 @@ function isListboxOption(el) {
26
33
  *
27
34
  * @public
28
35
  */
29
- class ListboxOption extends FoundationElement {
36
+ class ListboxOption$1 extends FoundationElement {
30
37
  constructor(text, value, defaultSelected, selected) {
31
38
  super();
32
39
  /**
@@ -157,25 +164,25 @@ class ListboxOption extends FoundationElement {
157
164
  }
158
165
  __decorate([
159
166
  observable
160
- ], ListboxOption.prototype, "checked", void 0);
167
+ ], ListboxOption$1.prototype, "checked", void 0);
161
168
  __decorate([
162
169
  observable
163
- ], ListboxOption.prototype, "content", void 0);
170
+ ], ListboxOption$1.prototype, "content", void 0);
164
171
  __decorate([
165
172
  observable
166
- ], ListboxOption.prototype, "defaultSelected", void 0);
173
+ ], ListboxOption$1.prototype, "defaultSelected", void 0);
167
174
  __decorate([
168
175
  attr({ mode: "boolean" })
169
- ], ListboxOption.prototype, "disabled", void 0);
176
+ ], ListboxOption$1.prototype, "disabled", void 0);
170
177
  __decorate([
171
178
  attr({ attribute: "selected", mode: "boolean" })
172
- ], ListboxOption.prototype, "selectedAttribute", void 0);
179
+ ], ListboxOption$1.prototype, "selectedAttribute", void 0);
173
180
  __decorate([
174
181
  observable
175
- ], ListboxOption.prototype, "selected", void 0);
182
+ ], ListboxOption$1.prototype, "selected", void 0);
176
183
  __decorate([
177
184
  attr({ attribute: "value", mode: "fromView" })
178
- ], ListboxOption.prototype, "initialValue", void 0);
185
+ ], ListboxOption$1.prototype, "initialValue", void 0);
179
186
  /**
180
187
  * States and properties relating to the ARIA `option` role.
181
188
  *
@@ -196,6 +203,59 @@ __decorate([
196
203
  observable
197
204
  ], DelegatesARIAListboxOption.prototype, "ariaSetSize", void 0);
198
205
  applyMixins(DelegatesARIAListboxOption, ARIAGlobalStatesAndProperties);
199
- applyMixins(ListboxOption, StartEnd, DelegatesARIAListboxOption);
206
+ applyMixins(ListboxOption$1, StartEnd, DelegatesARIAListboxOption);
200
207
 
201
- export { ListboxOption as L, isListboxOption as i };
208
+ class ListboxOption extends ListboxOption$1 {
209
+ set text(value) {
210
+ this._text = value;
211
+ }
212
+ get text() {
213
+ var _a;
214
+ return (_a = this._text) !== null && _a !== void 0 ? _a : '';
215
+ }
216
+ }
217
+ __decorate([attr({
218
+ attribute: 'text'
219
+ }), __metadata("design:type", String)], ListboxOption.prototype, "_text", void 0);
220
+ applyMixins(ListboxOption, AffixIconWithTrailing);
221
+
222
+ let _ = t => t,
223
+ _t,
224
+ _t2;
225
+ const getClasses = ({
226
+ icon,
227
+ disabled,
228
+ selected,
229
+ checked
230
+ }) => classNames('base', ['disabled', disabled], ['selected', Boolean(selected)], ['active', Boolean(checked)], ['icon', Boolean(icon)]);
231
+ const ListboxOptionTemplate = context => {
232
+ const affixIconTemplate = affixIconTemplateFactory(context);
233
+ const focusTemplate = focusTemplateFactory(context);
234
+ return html(_t || (_t = _`
235
+ <template
236
+ aria-checked="${0}"
237
+ aria-disabled="${0}"
238
+ aria-posinset="${0}"
239
+ aria-selected="${0}"
240
+ aria-setsize="${0}"
241
+ role="option">
242
+ <div class="${0}">
243
+ ${0}
244
+ ${0}
245
+ ${0}
246
+ </div>
247
+ </template>
248
+ `), x => x.ariaChecked, x => x.ariaDisabled, x => x.ariaPosInSet, x => x.ariaSelected, x => x.ariaSetSize, getClasses, () => focusTemplate, x => affixIconTemplate(x.icon), when(x => x.text, html(_t2 || (_t2 = _`<div class="text">${0}</div>`), x => x.text)));
249
+ };
250
+
251
+ var css_248z = "/**\n * Do not edit directly\n * Generated on Wed, 14 Dec 2022 16:38:57 GMT\n */\n.base {\n position: relative; /* this is needed for the focus */\n display: flex;\n box-sizing: border-box;\n align-items: center;\n background-color: var(--_appearance-color-fill);\n border-radius: 6px;\n box-shadow: inset 0 0 0 1px var(--_appearance-color-outline);\n color: var(--_appearance-color-text);\n font: var(--vvd-typography-base);\n gap: 12px;\n hyphens: auto;\n inline-size: 100%;\n min-block-size: calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2)));\n padding-block: 10px;\n padding-inline: 16px;\n vertical-align: middle;\n word-break: break-word;\n}\n.base {\n --_connotation-color-primary: var(--vvd-color-canvas-text);\n --_connotation-color-primary-text: var(--vvd-color-canvas);\n --_connotation-color-primary-increment: var(--vvd-color-neutral-800);\n --_connotation-color-faint: var(--vvd-color-neutral-50);\n --_connotation-color-soft: var(--vvd-color-neutral-100);\n}\n.base {\n --_appearance-color-text: var(--_connotation-color-primary);\n --_appearance-color-fill: transparent;\n --_appearance-color-outline: transparent;\n}\n.base:where(:hover, .hover):where(:not(:disabled, .disabled, .readonly)) {\n --_appearance-color-text: var(--_connotation-color-primary);\n --_appearance-color-fill: var(--_connotation-color-faint);\n --_appearance-color-outline: transparent;\n}\n.base:where(:disabled, .disabled) {\n --_appearance-color-text: var(--vvd-color-neutral-400);\n --_appearance-color-fill: transparent;\n --_appearance-color-outline: transparent;\n}\n.base:where(:active, .active):where(:not(:disabled, .disabled)) {\n --_appearance-color-text: var(--_connotation-color-primary);\n --_appearance-color-fill: var(--_connotation-color-soft);\n --_appearance-color-outline: transparent;\n}\n.base:where(.selected, [aria-current]):where(:not(:disabled, .disabled, :hover, .hover)) {\n --_appearance-color-text: var(--_connotation-color-primary-text);\n --_appearance-color-fill: var(--_connotation-color-primary);\n --_appearance-color-outline: transparent;\n}\n.base:where(.selected, [aria-current]):where(:hover, .hover) {\n --_appearance-color-text: var(--_connotation-color-primary-text);\n --_appearance-color-fill: var(--_connotation-color-primary-increment);\n --_appearance-color-outline: transparent;\n}\n@supports (user-select: none) {\n .base {\n user-select: none;\n }\n}\n.base:not(.disabled) {\n cursor: pointer;\n}\n.base.disabled {\n cursor: not-allowed;\n}\n.base .text {\n font: var(--vvd-typography-base);\n}\n\n.icon {\n font-size: 20px;\n}\n.base:not(.disabled, .selected) .icon {\n color: var(--vvd-color-neutral-600);\n}\n\n.focus-indicator {\n --focus-stroke-color: var(--vvd-color-neutral-500);\n --focus-stroke-gap-color: transparent;\n}\n:host(:not([aria-checked=true])) .focus-indicator {\n display: none;\n}";
252
+
253
+ const listboxOption = ListboxOption.compose({
254
+ baseName: 'option',
255
+ template: ListboxOptionTemplate,
256
+ styles: css_248z
257
+ })();
258
+ const listboxOptionElements = [listboxOption, ...iconElements, ...focusElements];
259
+ const registerOption = registerFactorial(listboxOptionElements);
260
+
261
+ export { listboxOption as a, isListboxOption as i, listboxOptionElements as l, registerOption as r };
@@ -0,0 +1,348 @@
1
+ import { F as FoundationElement, U as DOM, _ as __decorate, N as observable, a as attr, b as __metadata, h as html, r as registerFactorial } from './index.js';
2
+ import { P as Popup, p as popupElements } from './definition24.js';
3
+ import { M as MenuItem, a as MenuItemRole, r as roleForMenuItem, m as menuItemElements } from './definition25.js';
4
+ import { i as isHTMLElement } from './dom.js';
5
+ import { g as keyHome, d as keyEnd, e as keyArrowUp, f as keyArrowDown } from './key-codes.js';
6
+ import { s as slotted } from './slotted.js';
7
+ import { r as ref } from './ref.js';
8
+
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
+ class Menu$1 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) {
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$1.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);
294
+
295
+ var css_248z = ".base {\n max-inline-size: var(--menu-max-inline-size, 100%);\n min-inline-size: var(--menu-max-inline-size);\n padding-block: 8px;\n}";
296
+
297
+ class Menu extends Menu$1 {
298
+ constructor() {
299
+ super(...arguments);
300
+ this.open = false;
301
+ this.popupOpenChanged = () => {
302
+ this.open = this._popup.open;
303
+ };
304
+ }
305
+ }
306
+ __decorate([attr({
307
+ mode: 'boolean'
308
+ }), __metadata("design:type", Object)], Menu.prototype, "open", void 0);
309
+ __decorate([attr, __metadata("design:type", String)], Menu.prototype, "placement", void 0);
310
+ __decorate([attr, __metadata("design:type", String)], Menu.prototype, "anchor", void 0);
311
+
312
+ let _ = t => t,
313
+ _t;
314
+ const MenuTemplate = context => {
315
+ const popupTag = context.tagFor(Popup);
316
+ return html(_t || (_t = _`
317
+ <template
318
+ slot="${0}"
319
+ >
320
+ <${0}
321
+ :placement=${0}
322
+ :open=${0}
323
+ :anchor=${0}
324
+ @open="${0}"
325
+ @close="${0}"
326
+ ${0}
327
+ >
328
+ <div
329
+ class="base"
330
+ role="menu"
331
+ @keydown="${0}"
332
+ @focusout="${0}"
333
+ >
334
+ <slot ${0}></slot>
335
+ </div>
336
+ </${0}>
337
+ </template>`), x => x.slot || x.isNestedMenu() ? 'submenu' : void 0, popupTag, x => x.placement, x => x.open, x => x.anchor, x => x.popupOpenChanged(), x => x.popupOpenChanged(), ref('_popup'), (x, c) => x.handleMenuKeyDown(c.event), (x, c) => x.handleFocusOut(c.event), slotted('items'), popupTag);
338
+ };
339
+
340
+ const menu = Menu.compose({
341
+ baseName: 'menu',
342
+ template: MenuTemplate,
343
+ styles: css_248z
344
+ })();
345
+ const menuElements = [menu, ...popupElements, ...menuItemElements];
346
+ const registerMenu = registerFactorial(menuElements);
347
+
348
+ export { menuElements as a, menu as m, registerMenu as r };
@@ -1,7 +1,12 @@
1
- import { F as FoundationElement, Y as __classPrivateFieldGet, a9 as __classPrivateFieldSet, _ as __decorate, a as attr, b as __metadata } from './index.js';
2
- import './es.promise.resolve.js';
1
+ import { F as FoundationElement, Q as __classPrivateFieldGet, a5 as __classPrivateFieldSet, _ as __decorate, a as attr, b as __metadata, h as html, r as registerFactorial } from './index.js';
2
+ import { B as Button, b as buttonElements } from './definition9.js';
3
+ import { E as Elevation, e as elevationElements } from './definition15.js';
4
+ import './icon.js';
3
5
  import './es.object.assign.js';
4
6
  import { b as keyEscape } from './key-codes.js';
7
+ import { w as when } from './when.js';
8
+ import { r as ref } from './ref.js';
9
+ import { c as classNames } from './class-names.js';
5
10
 
6
11
  function getSide(placement) {
7
12
  return placement.split('-')[0];
@@ -1483,4 +1488,42 @@ __decorate([attr({
1483
1488
  }), __metadata("design:type", String)], Popup.prototype, "strategy", void 0);
1484
1489
  __decorate([attr, __metadata("design:type", Object)], Popup.prototype, "anchor", void 0);
1485
1490
 
1486
- export { Popup as P };
1491
+ var css_248z = ".control {\n background: var(--vvd-color-surface-4dp);\n border-radius: inherit;\n contain: layout;\n inline-size: var(--_popup-width, fit-content);\n}\n.control:not(.open) {\n display: none;\n}\n\n.popup-wrapper {\n border-radius: 6px;\n}\n.popup-wrapper:not(.absolute) {\n position: fixed;\n}\n.popup-wrapper.absolute {\n position: absolute;\n inline-size: var(--_popup-width);\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}";
1492
+
1493
+ let _ = t => t,
1494
+ _t,
1495
+ _t2,
1496
+ _t3;
1497
+ const getClasses = ({
1498
+ open,
1499
+ dismissible,
1500
+ alternate
1501
+ }) => classNames('control', ['open', Boolean(open)], ['dismissible', Boolean(dismissible)], ['alternate', Boolean(alternate)]);
1502
+ const popupTemplate = context => {
1503
+ const elevationTag = context.tagFor(Elevation);
1504
+ const buttonTag = context.tagFor(Button);
1505
+ return html(_t || (_t = _`
1506
+ <${0}>
1507
+ <div class="popup-wrapper ${0}" ${0}>
1508
+ <div class="${0}" aria-hidden="${0}"
1509
+ part="${0}">
1510
+ <div class="popup-content">
1511
+ <slot></slot>
1512
+ ${0}
1513
+ </div>
1514
+ ${0}
1515
+ </div>
1516
+ </div>
1517
+ </${0}>`), elevationTag, x => x.strategy, ref('popupEl'), getClasses, x => x.open ? 'false' : 'true', x => x.alternate ? 'vvd-theme-alternate' : '', when(x => x.dismissible, html(_t2 || (_t2 = _`<${0} size="condensed" @click="${0}"
1518
+ class="dismissible-button" icon="close-small-solid" shape="pill"></${0}>`), buttonTag, x => x.open = false, buttonTag)), when(x => x.arrow, html(_t3 || (_t3 = _`<div class="arrow" ${0}></div>`), ref('arrowEl'))), elevationTag);
1519
+ };
1520
+
1521
+ const popup = Popup.compose({
1522
+ baseName: 'popup',
1523
+ template: popupTemplate,
1524
+ styles: css_248z
1525
+ })();
1526
+ const popupElements = [popup, ...elevationElements, ...buttonElements];
1527
+ const registerPopup = registerFactorial(popupElements);
1528
+
1529
+ export { Popup as P, popup as a, popupElements as p, registerPopup as r };
@@ -1,8 +1,14 @@
1
- import { F as FoundationElement, a0 as DOM, _ as __decorate, a as attr, V as observable } from './index.js';
1
+ import { F as FoundationElement, U as DOM, _ as __decorate, a as attr, N as observable, b as __metadata, h as html, r as registerFactorial } from './index.js';
2
+ import { i as iconElements } from './definition3.js';
3
+ import { f as focusElements } from './definition4.js';
4
+ import { b as AffixIcon, a as affixIconTemplateFactory } from './affix.js';
2
5
  import { S as StartEnd } from './start-end.js';
3
6
  import { D as Direction, g as getDirection } from './direction.js';
4
7
  import { a as applyMixins } from './apply-mixins.js';
5
8
  import { h as keyArrowLeft, i as keyArrowRight, a as keySpace, k as keyEnter } from './key-codes.js';
9
+ import { f as focusTemplateFactory } from './focus2.js';
10
+ import { w as when } from './when.js';
11
+ import { c as classNames } from './class-names.js';
6
12
 
7
13
  /**
8
14
  * Menu items roles.
@@ -54,7 +60,7 @@ const roleForMenuItem = {
54
60
  *
55
61
  * @public
56
62
  */
57
- class MenuItem extends FoundationElement {
63
+ class MenuItem$1 extends FoundationElement {
58
64
  constructor() {
59
65
  super(...arguments);
60
66
  /**
@@ -247,31 +253,99 @@ class MenuItem extends FoundationElement {
247
253
  }
248
254
  __decorate([
249
255
  attr({ mode: "boolean" })
250
- ], MenuItem.prototype, "disabled", void 0);
256
+ ], MenuItem$1.prototype, "disabled", void 0);
251
257
  __decorate([
252
258
  attr({ mode: "boolean" })
253
- ], MenuItem.prototype, "expanded", void 0);
259
+ ], MenuItem$1.prototype, "expanded", void 0);
254
260
  __decorate([
255
261
  observable
256
- ], MenuItem.prototype, "startColumnCount", void 0);
262
+ ], MenuItem$1.prototype, "startColumnCount", void 0);
257
263
  __decorate([
258
264
  attr
259
- ], MenuItem.prototype, "role", void 0);
265
+ ], MenuItem$1.prototype, "role", void 0);
260
266
  __decorate([
261
267
  attr({ mode: "boolean" })
262
- ], MenuItem.prototype, "checked", void 0);
268
+ ], MenuItem$1.prototype, "checked", void 0);
263
269
  __decorate([
264
270
  observable
265
- ], MenuItem.prototype, "submenuRegion", void 0);
271
+ ], MenuItem$1.prototype, "submenuRegion", void 0);
266
272
  __decorate([
267
273
  observable
268
- ], MenuItem.prototype, "hasSubmenu", void 0);
274
+ ], MenuItem$1.prototype, "hasSubmenu", void 0);
269
275
  __decorate([
270
276
  observable
271
- ], MenuItem.prototype, "currentDirection", void 0);
277
+ ], MenuItem$1.prototype, "currentDirection", void 0);
272
278
  __decorate([
273
279
  observable
274
- ], MenuItem.prototype, "submenu", void 0);
275
- applyMixins(MenuItem, StartEnd);
280
+ ], MenuItem$1.prototype, "submenu", void 0);
281
+ applyMixins(MenuItem$1, StartEnd);
276
282
 
277
- export { MenuItem as M, MenuItemRole as a, roleForMenuItem as r };
283
+ var css_248z = "/**\n * Do not edit directly\n * Generated on Wed, 14 Dec 2022 16:38:57 GMT\n */\n@supports selector(:focus-visible) {\n :host(:focus) {\n outline: none;\n }\n}\n.base {\n position: relative;\n display: flex;\n box-sizing: border-box;\n align-items: center;\n background-color: var(--_appearance-color-fill);\n block-size: calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2)));\n box-shadow: inset 0 0 0 1px var(--_appearance-color-outline);\n color: var(--_appearance-color-text);\n font: var(--vvd-typography-base);\n gap: 12px;\n inline-size: 100%;\n padding-inline: 16px;\n}\n.base {\n --_appearance-color-text: var(--_connotation-color-primary);\n --_appearance-color-fill: transparent;\n --_appearance-color-outline: transparent;\n}\n.base:where(:hover, .hover):where(:not(:disabled, .disabled, .readonly)) {\n --_appearance-color-text: var(--_connotation-color-primary);\n --_appearance-color-fill: var(--_connotation-color-faint);\n --_appearance-color-outline: transparent;\n}\n.base:where(:disabled, .disabled) {\n --_appearance-color-text: var(--vvd-color-neutral-400);\n --_appearance-color-fill: transparent;\n --_appearance-color-outline: transparent;\n}\n.base:where(:active, .active):where(:not(:disabled, .disabled)) {\n --_appearance-color-text: var(--_connotation-color-primary);\n --_appearance-color-fill: var(--_connotation-color-soft);\n --_appearance-color-outline: transparent;\n}\n.base:where(.selected, [aria-current]):where(:not(:disabled, .disabled, :hover, .hover)) {\n --_appearance-color-text: var(--_connotation-color-primary-text);\n --_appearance-color-fill: var(--_connotation-color-primary);\n --_appearance-color-outline: transparent;\n}\n.base:where(.selected, [aria-current]):where(:hover, .hover) {\n --_appearance-color-text: var(--_connotation-color-primary-text);\n --_appearance-color-fill: var(--_connotation-color-primary-increment);\n --_appearance-color-outline: transparent;\n}\n.base {\n --_connotation-color-primary: var(--vvd-color-canvas-text);\n --_connotation-color-primary-text: var(--vvd-color-canvas);\n --_connotation-color-primary-increment: var(--vvd-color-neutral-800);\n --_connotation-color-faint: var(--vvd-color-neutral-50);\n --_connotation-color-soft: var(--vvd-color-neutral-100);\n}\n@supports (user-select: none) {\n .base {\n user-select: none;\n }\n}\n.base:not(.disabled) {\n cursor: pointer;\n}\n.base.disabled {\n cursor: not-allowed;\n}\n\n.focus-indicator {\n border-radius: 6px;\n}\n:host(:not(:focus-visible)) .focus-indicator {\n display: none;\n}\n\n.icon {\n font-size: 20px;\n}\n.base:not(.disabled, .item-checkbox, .item-radio) .icon {\n color: var(--vvd-color-neutral-600);\n}\n.base:is(.disabled, .item-checkbox, .item-radio) .icon {\n color: var(--_appearance-color-text);\n}\n\n.text {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}";
284
+
285
+ class MenuItem extends MenuItem$1 {}
286
+ __decorate([attr, __metadata("design:type", String)], MenuItem.prototype, "text", void 0);
287
+ applyMixins(MenuItem, AffixIcon);
288
+
289
+ let _ = t => t,
290
+ _t,
291
+ _t2,
292
+ _t3,
293
+ _t4,
294
+ _t5;
295
+ const getClasses = ({
296
+ disabled,
297
+ checked,
298
+ expanded,
299
+ role
300
+ }) => classNames('base', ['disabled', Boolean(disabled)], ['selected', role !== MenuItemRole.menuitem && Boolean(checked)], ['expanded', Boolean(expanded)], ['item-checkbox', role === MenuItemRole.menuitemcheckbox], ['item-radio', role === MenuItemRole.menuitemradio]);
301
+ const MenuItemTemplate = (context, definition) => {
302
+ const affixIconTemplate = affixIconTemplateFactory(context);
303
+ const focusTemplate = focusTemplateFactory(context);
304
+ return html(_t || (_t = _`
305
+ <template
306
+ aria-checked="${0}"
307
+ aria-disabled="${0}"
308
+ aria-expanded="${0}"
309
+ @keydown="${0}"
310
+ @click="${0}"
311
+ @mouseover="${0}"
312
+ @mouseout="${0}"
313
+ >
314
+ <div class="${0}">
315
+
316
+ ${0}
317
+ ${0}
318
+
319
+ ${0}
320
+
321
+ ${0}
322
+
323
+ ${0}
324
+
325
+ <span class="text">
326
+ ${0}
327
+ </span>
328
+ </div>
329
+ </template>
330
+ `), x => x.role !== MenuItemRole.menuitem ? x.checked : void 0, x => x.disabled, x => x.expanded, (x, c) => x.handleMenuItemKeyDown(c.event), (x, c) => x.handleMenuItemClick(c.event), (x, c) => x.handleMouseOver(c.event), (x, c) => x.handleMouseOut(c.event), getClasses, when(x => x.hasSubmenu, html(_t2 || (_t2 = _`
331
+ <div
332
+ class="expand-collapse-glyph-container"
333
+ >
334
+ <span class="expand-collapse">
335
+ <slot name="expand-collapse-indicator">
336
+ ${0}
337
+ </slot>
338
+ </span>
339
+ </div>
340
+ `), definition.expandCollapseGlyph || '')), () => focusTemplate, when(x => x.role === MenuItemRole.menuitemcheckbox, html(_t3 || (_t3 = _`${0}`), x => affixIconTemplate(x.checked ? 'checkbox-checked-line' : 'checkbox-unchecked-line'))), when(x => x.role === MenuItemRole.menuitemradio, html(_t4 || (_t4 = _`${0}`), x => affixIconTemplate(x.checked ? 'radio-checked-line' : 'radio-unchecked-line'))), when(x => x.role === MenuItemRole.menuitem && x.icon, html(_t5 || (_t5 = _`${0}`), x => affixIconTemplate(x.icon))), x => x.text);
341
+ };
342
+
343
+ const menuItem = MenuItem.compose({
344
+ baseName: 'menu-item',
345
+ template: MenuItemTemplate,
346
+ styles: css_248z
347
+ })();
348
+ const menuItemElements = [menuItem, ...iconElements, ...focusElements];
349
+ const registerMenuItem = registerFactorial(menuItemElements);
350
+
351
+ export { MenuItem$1 as M, MenuItemRole as a, registerMenuItem as b, menuItem as c, menuItemElements as m, roleForMenuItem as r };