@vonage/vivid 3.0.0-next.12 → 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 (291) hide show
  1. package/README.md +170 -4
  2. package/accordion/index.js +4 -60
  3. package/accordion-item/index.js +14 -118
  4. package/action-group/index.js +5 -0
  5. package/avatar/index.js +11 -0
  6. package/badge/index.js +9 -53
  7. package/banner/index.js +20 -210
  8. package/breadcrumb/index.js +7 -96
  9. package/breadcrumb-item/index.js +15 -46
  10. package/button/index.js +19 -751
  11. package/calendar/index.js +5 -1520
  12. package/calendar-event/index.js +9 -0
  13. package/card/index.js +13 -0
  14. package/checkbox/index.js +16 -0
  15. package/custom-elements.json +5784 -0
  16. package/dialog/index.js +24 -0
  17. package/divider/index.js +6 -0
  18. package/elevation/index.js +4 -30
  19. package/fab/index.js +22 -0
  20. package/focus/index.js +4 -2
  21. package/header/index.js +58 -0
  22. package/icon/index.js +8 -36
  23. package/index.js +65 -26
  24. package/layout/index.js +4 -52
  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 -3
  29. package/lib/action-group/action-group.d.ts +10 -0
  30. package/lib/{sidenav-item/sidenav-item.template.d.ts → action-group/action-group.template.d.ts} +2 -2
  31. package/lib/action-group/definition.d.ts +3 -0
  32. package/lib/action-group/index.d.ts +1 -0
  33. package/lib/avatar/avatar.d.ts +15 -0
  34. package/lib/avatar/avatar.template.d.ts +4 -0
  35. package/lib/avatar/definition.d.ts +3 -0
  36. package/lib/avatar/index.d.ts +1 -0
  37. package/lib/badge/badge.d.ts +2 -4
  38. package/lib/badge/definition.d.ts +3 -0
  39. package/lib/badge/index.d.ts +1 -3
  40. package/lib/banner/banner.d.ts +1 -1
  41. package/lib/banner/banner.template.d.ts +0 -2
  42. package/lib/banner/definition.d.ts +3 -0
  43. package/lib/banner/index.d.ts +1 -2
  44. package/lib/breadcrumb/breadcrumb.template.d.ts +4 -0
  45. package/lib/breadcrumb/definition.d.ts +3 -0
  46. package/lib/breadcrumb/index.d.ts +1 -2
  47. package/lib/breadcrumb-item/definition.d.ts +3 -0
  48. package/lib/breadcrumb-item/index.d.ts +1 -3
  49. package/lib/button/button.d.ts +3 -2
  50. package/lib/button/definition.d.ts +3 -0
  51. package/lib/button/index.d.ts +1 -21
  52. package/lib/calendar/calendar.d.ts +3 -1
  53. package/lib/calendar/definition.d.ts +3 -0
  54. package/lib/calendar/index.d.ts +1 -3
  55. package/lib/calendar-event/calendar-event.d.ts +14 -0
  56. package/lib/calendar-event/calendar-event.template.d.ts +4 -0
  57. package/lib/calendar-event/definition.d.ts +3 -0
  58. package/lib/calendar-event/index.d.ts +1 -0
  59. package/lib/card/card.d.ts +10 -0
  60. package/lib/{text/text.template.d.ts → card/card.template.d.ts} +2 -2
  61. package/lib/card/definition.d.ts +3 -0
  62. package/lib/card/index.d.ts +1 -0
  63. package/lib/checkbox/checkbox.d.ts +5 -0
  64. package/lib/checkbox/checkbox.template.d.ts +4 -0
  65. package/lib/checkbox/definition.d.ts +3 -0
  66. package/lib/checkbox/index.d.ts +1 -0
  67. package/lib/components.d.ts +38 -16
  68. package/lib/dialog/definition.d.ts +3 -0
  69. package/lib/dialog/dialog.d.ts +23 -0
  70. package/lib/dialog/dialog.template.d.ts +4 -0
  71. package/lib/dialog/index.d.ts +1 -0
  72. package/lib/divider/definition.d.ts +3 -0
  73. package/lib/divider/divider.d.ts +3 -0
  74. package/lib/divider/divider.template.d.ts +4 -0
  75. package/lib/divider/index.d.ts +1 -0
  76. package/lib/elevation/definition.d.ts +3 -0
  77. package/lib/elevation/elevation.d.ts +1 -0
  78. package/lib/elevation/index.d.ts +1 -2
  79. package/lib/enums.d.ts +19 -6
  80. package/lib/fab/definition.d.ts +3 -0
  81. package/lib/fab/fab.d.ts +13 -0
  82. package/lib/fab/fab.template.d.ts +4 -0
  83. package/lib/fab/index.d.ts +1 -0
  84. package/lib/focus/definition.d.ts +3 -0
  85. package/lib/focus/index.d.ts +1 -2
  86. package/lib/header/definition.d.ts +3 -0
  87. package/lib/header/header.d.ts +5 -0
  88. package/lib/header/header.template.d.ts +4 -0
  89. package/lib/header/index.d.ts +1 -0
  90. package/lib/icon/definition.d.ts +3 -0
  91. package/lib/icon/icon.d.ts +5 -6
  92. package/lib/icon/index.d.ts +1 -2
  93. package/lib/layout/definition.d.ts +3 -0
  94. package/lib/layout/index.d.ts +1 -2
  95. package/lib/layout/layout.d.ts +4 -4
  96. package/lib/listbox/definition.d.ts +3 -0
  97. package/lib/listbox/index.d.ts +1 -0
  98. package/lib/listbox/listbox.d.ts +9 -0
  99. package/lib/listbox/listbox.template.d.ts +4 -0
  100. package/lib/menu/definition.d.ts +7 -0
  101. package/lib/menu/index.d.ts +1 -0
  102. package/lib/menu/menu.d.ts +10 -0
  103. package/lib/menu/menu.template.d.ts +3 -0
  104. package/lib/menu-item/definition.d.ts +3 -0
  105. package/lib/menu-item/index.d.ts +1 -0
  106. package/lib/menu-item/menu-item.d.ts +7 -0
  107. package/lib/menu-item/menu-item.template.d.ts +5 -0
  108. package/lib/nav/definition.d.ts +3 -0
  109. package/lib/nav/index.d.ts +1 -0
  110. package/lib/nav/nav.d.ts +3 -0
  111. package/lib/nav/nav.template.d.ts +4 -0
  112. package/lib/nav-disclosure/definition.d.ts +3 -0
  113. package/lib/nav-disclosure/index.d.ts +1 -0
  114. package/lib/nav-disclosure/nav-disclosure.d.ts +10 -0
  115. package/lib/nav-disclosure/nav-disclosure.template.d.ts +4 -0
  116. package/lib/nav-item/definition.d.ts +3 -0
  117. package/lib/nav-item/index.d.ts +1 -0
  118. package/lib/{sidenav-item/sidenav-item.d.ts → nav-item/nav-item.d.ts} +2 -2
  119. package/lib/nav-item/nav-item.template.d.ts +4 -0
  120. package/lib/note/definition.d.ts +3 -0
  121. package/lib/note/index.d.ts +1 -0
  122. package/lib/note/note.d.ts +10 -0
  123. package/lib/note/note.template.d.ts +4 -0
  124. package/lib/number-field/definition.d.ts +3 -0
  125. package/lib/number-field/index.d.ts +1 -0
  126. package/lib/number-field/number-field.d.ts +14 -0
  127. package/lib/number-field/number-field.template.d.ts +4 -0
  128. package/lib/option/definition.d.ts +3 -0
  129. package/lib/option/index.d.ts +1 -0
  130. package/lib/option/option.d.ts +9 -0
  131. package/lib/option/option.template.d.ts +4 -0
  132. package/lib/popup/definition.d.ts +4 -0
  133. package/lib/popup/index.d.ts +1 -4
  134. package/lib/popup/popup.d.ts +6 -4
  135. package/lib/progress/definition.d.ts +3 -0
  136. package/lib/progress/index.d.ts +1 -2
  137. package/lib/progress/progress.d.ts +1 -1
  138. package/lib/progress-ring/definition.d.ts +3 -0
  139. package/lib/progress-ring/index.d.ts +1 -2
  140. package/lib/progress-ring/progress-ring.d.ts +2 -1
  141. package/lib/radio/definition.d.ts +3 -0
  142. package/lib/radio/index.d.ts +1 -0
  143. package/lib/radio/radio.d.ts +4 -0
  144. package/lib/radio/radio.template.d.ts +4 -0
  145. package/lib/radio-group/definition.d.ts +7 -0
  146. package/lib/radio-group/index.d.ts +1 -0
  147. package/lib/radio-group/radio-group.d.ts +4 -0
  148. package/lib/radio-group/radio-group.template.d.ts +4 -0
  149. package/lib/side-drawer/definition.d.ts +3 -0
  150. package/lib/side-drawer/index.d.ts +1 -2
  151. package/lib/side-drawer/side-drawer.d.ts +3 -2
  152. package/lib/slider/definition.d.ts +3 -0
  153. package/lib/slider/index.d.ts +1 -0
  154. package/lib/slider/slider.d.ts +4 -0
  155. package/lib/slider/slider.template.d.ts +4 -0
  156. package/lib/switch/definition.d.ts +3 -0
  157. package/lib/switch/index.d.ts +1 -0
  158. package/lib/switch/switch.d.ts +7 -0
  159. package/lib/switch/switch.template.d.ts +4 -0
  160. package/lib/text-anchor/definition.d.ts +3 -0
  161. package/lib/text-anchor/index.d.ts +1 -2
  162. package/lib/text-area/definition.d.ts +3 -0
  163. package/lib/text-area/index.d.ts +1 -0
  164. package/lib/text-area/text-area.d.ts +9 -0
  165. package/lib/text-area/text-area.template.d.ts +4 -0
  166. package/lib/text-field/definition.d.ts +3 -0
  167. package/lib/text-field/index.d.ts +1 -0
  168. package/lib/text-field/text-field.d.ts +14 -0
  169. package/lib/text-field/text-field.template.d.ts +4 -0
  170. package/lib/tooltip/definition.d.ts +3 -0
  171. package/lib/tooltip/index.d.ts +1 -3
  172. package/lib/tooltip/tooltip.d.ts +6 -6
  173. package/listbox/index.js +24 -0
  174. package/menu/index.js +30 -0
  175. package/menu-item/index.js +20 -0
  176. package/nav/index.js +4 -0
  177. package/nav-disclosure/index.js +17 -0
  178. package/nav-item/index.js +22 -0
  179. package/note/index.js +15 -0
  180. package/number-field/index.js +458 -0
  181. package/option/index.js +20 -0
  182. package/package.json +62 -10
  183. package/popup/index.js +21 -2062
  184. package/progress/index.js +6 -98
  185. package/progress-ring/index.js +6 -75
  186. package/radio/index.js +12 -0
  187. package/radio-group/index.js +11 -0
  188. package/shared/affix.js +2 -8
  189. package/shared/anchor.js +11 -3
  190. package/shared/apply-mixins.js +5 -4
  191. package/shared/aria-global.js +2 -86
  192. package/shared/aria.js +9 -0
  193. package/shared/base-progress.js +6 -1
  194. package/shared/breadcrumb-item.js +2 -2
  195. package/shared/button.js +200 -0
  196. package/shared/calendar-event.js +19 -0
  197. package/shared/definition.js +53 -0
  198. package/shared/definition10.js +99 -0
  199. package/shared/definition11.js +48 -0
  200. package/shared/definition12.js +1523 -0
  201. package/shared/definition13.js +111 -0
  202. package/shared/definition14.js +114 -0
  203. package/shared/definition15.js +32 -0
  204. package/shared/definition16.js +172 -0
  205. package/shared/definition17.js +223 -0
  206. package/shared/definition18.js +78 -0
  207. package/shared/definition19.js +87 -0
  208. package/shared/definition2.js +106 -0
  209. package/shared/definition20.js +44 -0
  210. package/shared/definition21.js +1078 -0
  211. package/shared/definition22.js +261 -0
  212. package/shared/definition23.js +348 -0
  213. package/shared/definition24.js +1529 -0
  214. package/shared/definition25.js +351 -0
  215. package/shared/definition26.js +18 -0
  216. package/shared/definition27.js +75 -0
  217. package/shared/definition28.js +31 -0
  218. package/shared/definition29.js +56 -0
  219. package/shared/definition3.js +29 -0
  220. package/shared/definition30.js +94 -0
  221. package/shared/definition31.js +77 -0
  222. package/shared/definition32.js +45 -0
  223. package/shared/definition33.js +435 -0
  224. package/shared/definition34.js +86 -0
  225. package/shared/definition35.js +592 -0
  226. package/shared/definition36.js +147 -0
  227. package/shared/definition37.js +279 -0
  228. package/shared/definition38.js +119 -0
  229. package/shared/definition39.js +77 -0
  230. package/shared/definition4.js +19 -0
  231. package/shared/definition5.js +38 -0
  232. package/shared/definition6.js +60 -0
  233. package/shared/definition7.js +45 -0
  234. package/shared/definition8.js +113 -0
  235. package/shared/definition9.js +107 -0
  236. package/shared/design-system/index.d.ts +1 -2
  237. package/shared/dialog-polyfill.esm.js +858 -0
  238. package/shared/direction.js +20 -0
  239. package/shared/dom.js +8 -0
  240. package/shared/enums.js +70 -0
  241. package/shared/es.object.assign.js +2 -3
  242. package/shared/es.regexp.to-string.js +59 -0
  243. package/shared/focus.js +5 -0
  244. package/shared/focus2.js +11 -0
  245. package/shared/form-associated.js +466 -0
  246. package/shared/form-elements.js +343 -0
  247. package/shared/icon.js +538 -567
  248. package/shared/index.js +1664 -83
  249. package/shared/key-codes.js +97 -0
  250. package/shared/numbers.js +25 -0
  251. package/shared/patterns/affix.d.ts +1 -1
  252. package/shared/patterns/focus.d.ts +3 -0
  253. package/shared/patterns/form-elements/form-elements.d.ts +31 -0
  254. package/shared/patterns/form-elements/index.d.ts +1 -0
  255. package/shared/patterns/index.d.ts +2 -0
  256. package/shared/radio.js +127 -0
  257. package/shared/ref.js +41 -0
  258. package/shared/slotted.js +1 -1
  259. package/shared/start-end.js +50 -0
  260. package/shared/string-trim.js +40 -0
  261. package/shared/text-anchor.js +0 -2
  262. package/shared/text-anchor.template.js +6 -5
  263. package/shared/to-string.js +51 -0
  264. package/side-drawer/index.js +5 -81
  265. package/slider/index.js +17 -0
  266. package/styles/core/all.css +86 -0
  267. package/styles/core/theme.css +11 -0
  268. package/styles/core/typography.css +80 -0
  269. package/styles/fonts/SpeziaCompleteVariableItalicWeb.woff2 +0 -0
  270. package/styles/fonts/SpeziaCompleteVariableUprightWeb.woff2 +0 -0
  271. package/styles/fonts/SpeziaMonoCompleteVariableWeb.woff2 +0 -0
  272. package/styles/fonts/spezia.css +9 -12
  273. package/styles/tokens/theme-dark.css +230 -0
  274. package/styles/tokens/theme-light.css +230 -0
  275. package/switch/index.js +17 -0
  276. package/text-anchor/index.js +12 -7
  277. package/text-area/index.js +22 -0
  278. package/text-field/index.js +22 -0
  279. package/tooltip/index.js +18 -55
  280. package/vivid.api.json +3769 -0
  281. package/lib/sidenav-item/index.d.ts +0 -3
  282. package/lib/text/index.d.ts +0 -2
  283. package/lib/text/text.d.ts +0 -10
  284. package/shared/index2.js +0 -21
  285. package/shared/object-set-prototype-of.js +0 -1009
  286. package/shared/style-inject.es.js +0 -28
  287. package/shared/web.dom-collections.iterator.js +0 -473
  288. package/sidenav-item/index.js +0 -39
  289. package/styles/themes/dark.css +0 -205
  290. package/styles/themes/light.css +0 -205
  291. package/text/index.js +0 -46
@@ -0,0 +1,261 @@
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';
5
+ import { A as ARIAGlobalStatesAndProperties } from './aria-global.js';
6
+ import { S as StartEnd } from './start-end.js';
7
+ import { a as applyMixins } from './apply-mixins.js';
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';
13
+
14
+ /**
15
+ * Determines if the element is a {@link (ListboxOption:class)}
16
+ *
17
+ * @param element - the element to test.
18
+ * @public
19
+ */
20
+ function isListboxOption(el) {
21
+ return (isHTMLElement(el) &&
22
+ (el.getAttribute("role") === "option" ||
23
+ el instanceof HTMLOptionElement));
24
+ }
25
+ /**
26
+ * An Option Custom HTML Element.
27
+ * Implements {@link https://www.w3.org/TR/wai-aria-1.1/#option | ARIA option }.
28
+ *
29
+ * @slot start - Content which can be provided before the listbox option content
30
+ * @slot end - Content which can be provided after the listbox option content
31
+ * @slot - The default slot for listbox option content
32
+ * @csspart content - Wraps the listbox option content
33
+ *
34
+ * @public
35
+ */
36
+ class ListboxOption$1 extends FoundationElement {
37
+ constructor(text, value, defaultSelected, selected) {
38
+ super();
39
+ /**
40
+ * The defaultSelected state of the option.
41
+ * @public
42
+ */
43
+ this.defaultSelected = false;
44
+ /**
45
+ * Tracks whether the "selected" property has been changed.
46
+ * @internal
47
+ */
48
+ this.dirtySelected = false;
49
+ /**
50
+ * The checked state of the control.
51
+ *
52
+ * @public
53
+ */
54
+ this.selected = this.defaultSelected;
55
+ /**
56
+ * Track whether the value has been changed from the initial value
57
+ */
58
+ this.dirtyValue = false;
59
+ if (text) {
60
+ this.textContent = text;
61
+ }
62
+ if (value) {
63
+ this.initialValue = value;
64
+ }
65
+ if (defaultSelected) {
66
+ this.defaultSelected = defaultSelected;
67
+ }
68
+ if (selected) {
69
+ this.selected = selected;
70
+ }
71
+ this.proxy = new Option(`${this.textContent}`, this.initialValue, this.defaultSelected, this.selected);
72
+ this.proxy.disabled = this.disabled;
73
+ }
74
+ /**
75
+ * Updates the ariaChecked property when the checked property changes.
76
+ *
77
+ * @param prev - the previous checked value
78
+ * @param next - the current checked value
79
+ *
80
+ * @public
81
+ */
82
+ checkedChanged(prev, next) {
83
+ if (typeof next === "boolean") {
84
+ this.ariaChecked = next ? "true" : "false";
85
+ return;
86
+ }
87
+ this.ariaChecked = null;
88
+ }
89
+ /**
90
+ * Updates the proxy's text content when the default slot changes.
91
+ * @param prev - the previous content value
92
+ * @param next - the current content value
93
+ *
94
+ * @internal
95
+ */
96
+ contentChanged(prev, next) {
97
+ if (this.proxy instanceof HTMLOptionElement) {
98
+ this.proxy.textContent = this.textContent;
99
+ }
100
+ this.$emit("contentchange", null, { bubbles: true });
101
+ }
102
+ defaultSelectedChanged() {
103
+ if (!this.dirtySelected) {
104
+ this.selected = this.defaultSelected;
105
+ if (this.proxy instanceof HTMLOptionElement) {
106
+ this.proxy.selected = this.defaultSelected;
107
+ }
108
+ }
109
+ }
110
+ disabledChanged(prev, next) {
111
+ this.ariaDisabled = this.disabled ? "true" : "false";
112
+ if (this.proxy instanceof HTMLOptionElement) {
113
+ this.proxy.disabled = this.disabled;
114
+ }
115
+ }
116
+ selectedAttributeChanged() {
117
+ this.defaultSelected = this.selectedAttribute;
118
+ if (this.proxy instanceof HTMLOptionElement) {
119
+ this.proxy.defaultSelected = this.defaultSelected;
120
+ }
121
+ }
122
+ selectedChanged() {
123
+ this.ariaSelected = this.selected ? "true" : "false";
124
+ if (!this.dirtySelected) {
125
+ this.dirtySelected = true;
126
+ }
127
+ if (this.proxy instanceof HTMLOptionElement) {
128
+ this.proxy.selected = this.selected;
129
+ }
130
+ }
131
+ initialValueChanged(previous, next) {
132
+ // If the value is clean and the component is connected to the DOM
133
+ // then set value equal to the attribute value.
134
+ if (!this.dirtyValue) {
135
+ this.value = this.initialValue;
136
+ this.dirtyValue = false;
137
+ }
138
+ }
139
+ get label() {
140
+ var _a;
141
+ return (_a = this.value) !== null && _a !== void 0 ? _a : this.text;
142
+ }
143
+ get text() {
144
+ var _a, _b;
145
+ return (_b = (_a = this.textContent) === null || _a === void 0 ? void 0 : _a.replace(/\s+/g, " ").trim()) !== null && _b !== void 0 ? _b : "";
146
+ }
147
+ set value(next) {
148
+ const newValue = `${next !== null && next !== void 0 ? next : ""}`;
149
+ this._value = newValue;
150
+ this.dirtyValue = true;
151
+ if (this.proxy instanceof HTMLOptionElement) {
152
+ this.proxy.value = newValue;
153
+ }
154
+ Observable.notify(this, "value");
155
+ }
156
+ get value() {
157
+ var _a;
158
+ Observable.track(this, "value");
159
+ return (_a = this._value) !== null && _a !== void 0 ? _a : this.text;
160
+ }
161
+ get form() {
162
+ return this.proxy ? this.proxy.form : null;
163
+ }
164
+ }
165
+ __decorate([
166
+ observable
167
+ ], ListboxOption$1.prototype, "checked", void 0);
168
+ __decorate([
169
+ observable
170
+ ], ListboxOption$1.prototype, "content", void 0);
171
+ __decorate([
172
+ observable
173
+ ], ListboxOption$1.prototype, "defaultSelected", void 0);
174
+ __decorate([
175
+ attr({ mode: "boolean" })
176
+ ], ListboxOption$1.prototype, "disabled", void 0);
177
+ __decorate([
178
+ attr({ attribute: "selected", mode: "boolean" })
179
+ ], ListboxOption$1.prototype, "selectedAttribute", void 0);
180
+ __decorate([
181
+ observable
182
+ ], ListboxOption$1.prototype, "selected", void 0);
183
+ __decorate([
184
+ attr({ attribute: "value", mode: "fromView" })
185
+ ], ListboxOption$1.prototype, "initialValue", void 0);
186
+ /**
187
+ * States and properties relating to the ARIA `option` role.
188
+ *
189
+ * @public
190
+ */
191
+ class DelegatesARIAListboxOption {
192
+ }
193
+ __decorate([
194
+ observable
195
+ ], DelegatesARIAListboxOption.prototype, "ariaChecked", void 0);
196
+ __decorate([
197
+ observable
198
+ ], DelegatesARIAListboxOption.prototype, "ariaPosInSet", void 0);
199
+ __decorate([
200
+ observable
201
+ ], DelegatesARIAListboxOption.prototype, "ariaSelected", void 0);
202
+ __decorate([
203
+ observable
204
+ ], DelegatesARIAListboxOption.prototype, "ariaSetSize", void 0);
205
+ applyMixins(DelegatesARIAListboxOption, ARIAGlobalStatesAndProperties);
206
+ applyMixins(ListboxOption$1, StartEnd, DelegatesARIAListboxOption);
207
+
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 };