@vonage/vivid 5.3.0 → 5.5.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 (263) hide show
  1. package/accordion-item/definition.js +1 -1
  2. package/alert/definition.cjs +1 -1
  3. package/alert/definition.js +2 -2
  4. package/badge/definition.js +1 -1
  5. package/banner/definition.js +1 -1
  6. package/bundled/base-color-picker.cjs +18 -13
  7. package/bundled/base-color-picker.js +98 -81
  8. package/bundled/calendar-picker.template.cjs +7 -7
  9. package/bundled/calendar-picker.template.js +102 -102
  10. package/bundled/char-count.cjs +1 -1
  11. package/bundled/char-count.js +1 -1
  12. package/bundled/definition10.cjs +1 -1
  13. package/bundled/definition10.js +2 -2
  14. package/bundled/definition11.cjs +12 -19
  15. package/bundled/definition11.js +87 -66
  16. package/bundled/definition12.cjs +19 -10
  17. package/bundled/definition12.js +217 -36
  18. package/bundled/definition13.cjs +10 -1
  19. package/bundled/definition13.js +38 -14
  20. package/bundled/definition14.cjs +1 -5
  21. package/bundled/definition14.js +15 -24
  22. package/bundled/definition15.cjs +5 -30
  23. package/bundled/definition15.js +22 -73
  24. package/bundled/definition16.cjs +30 -19
  25. package/bundled/definition16.js +74 -97
  26. package/bundled/definition17.cjs +19 -13
  27. package/bundled/definition17.js +83 -117
  28. package/bundled/definition18.cjs +13 -12
  29. package/bundled/definition18.js +114 -71
  30. package/bundled/definition19.cjs +26 -27
  31. package/bundled/definition19.js +171 -180
  32. package/bundled/definition2.cjs +9 -9
  33. package/bundled/definition2.js +84 -129
  34. package/bundled/definition3.cjs +1 -1
  35. package/bundled/definition3.js +1 -1
  36. package/bundled/definition6.cjs +3 -3
  37. package/bundled/definition6.js +19 -19
  38. package/bundled/definition9.cjs +5 -5
  39. package/bundled/definition9.js +394 -392
  40. package/bundled/listbox.cjs +1 -1
  41. package/bundled/listbox.js +82 -102
  42. package/bundled/localized.cjs +1 -1
  43. package/bundled/localized.js +48 -31
  44. package/bundled/mixins.cjs +1 -1
  45. package/bundled/mixins.js +1 -1
  46. package/bundled/picker-field.template.cjs +14 -14
  47. package/bundled/picker-field.template.js +35 -56
  48. package/bundled/time-selection-picker.template.cjs +12 -12
  49. package/bundled/time-selection-picker.template.js +13 -12
  50. package/bundled/trapped-focus.cjs +1 -0
  51. package/bundled/trapped-focus.js +26 -0
  52. package/bundled/vivid-element.cjs +5 -1
  53. package/bundled/vivid-element.js +401 -358
  54. package/calendar/index.cjs +13 -13
  55. package/calendar/index.js +171 -143
  56. package/card/definition.cjs +1 -1
  57. package/card/definition.js +1 -1
  58. package/color-picker/definition.cjs +209 -113
  59. package/color-picker/definition.js +209 -113
  60. package/color-picker/index.cjs +104 -75
  61. package/color-picker/index.js +412 -326
  62. package/combobox/definition.cjs +7 -27
  63. package/combobox/definition.js +8 -28
  64. package/combobox/index.cjs +6 -6
  65. package/combobox/index.js +57 -71
  66. package/contextual-help/index.cjs +1 -1
  67. package/contextual-help/index.js +1 -1
  68. package/custom-elements.json +354 -2
  69. package/data-grid/index.cjs +1 -1
  70. package/data-grid/index.js +1 -1
  71. package/date-picker/definition.cjs +1 -1
  72. package/date-picker/definition.js +1 -1
  73. package/date-picker/index.cjs +1 -1
  74. package/date-picker/index.js +2 -2
  75. package/date-range-picker/definition.cjs +1 -1
  76. package/date-range-picker/definition.js +1 -1
  77. package/date-range-picker/index.cjs +1 -1
  78. package/date-range-picker/index.js +2 -2
  79. package/date-time-picker/definition.cjs +1 -1
  80. package/date-time-picker/definition.js +1 -1
  81. package/date-time-picker/index.cjs +1 -1
  82. package/date-time-picker/index.js +2 -2
  83. package/dial-pad/definition.cjs +139 -0
  84. package/dial-pad/definition.js +139 -0
  85. package/dial-pad/index.cjs +27 -20
  86. package/dial-pad/index.js +177 -100
  87. package/dialog/definition.cjs +2 -2
  88. package/dialog/definition.js +2 -2
  89. package/dialog/index.cjs +7 -7
  90. package/dialog/index.js +6 -6
  91. package/divider/index.cjs +1 -1
  92. package/divider/index.js +1 -1
  93. package/elevation/definition.cjs +1 -1
  94. package/elevation/definition.js +1 -1
  95. package/fab/definition.js +1 -1
  96. package/header/definition.cjs +1 -1
  97. package/header/definition.js +1 -1
  98. package/icon/definition.cjs +56 -22
  99. package/icon/definition.js +56 -22
  100. package/index.cjs +3 -4
  101. package/index.js +2 -3
  102. package/lib/accordion/accordion.d.ts +1 -1
  103. package/lib/accordion/definition.d.ts +1 -1
  104. package/lib/audio-player/audio-player.d.ts +1 -1
  105. package/lib/color-picker/color-picker.d.ts +390 -12
  106. package/lib/color-picker/locale.d.ts +4 -0
  107. package/lib/combobox/combobox.d.ts +1 -0
  108. package/lib/combobox/combobox.options.d.ts +1 -1
  109. package/lib/date-picker/date-picker.d.ts +38 -38
  110. package/lib/date-range-picker/date-range-picker.d.ts +20 -20
  111. package/lib/date-time-picker/date-time-picker.d.ts +40 -40
  112. package/lib/dial-pad/dial-pad.d.ts +1 -0
  113. package/lib/divider/divider.d.ts +1 -1
  114. package/lib/icon/icon.d.ts +1 -0
  115. package/lib/menu-item/menu-item-role.d.ts +1 -1
  116. package/lib/popup/popup.d.ts +1 -1
  117. package/lib/searchable-select/locale.d.ts +4 -0
  118. package/lib/searchable-select/searchable-select.d.ts +3 -0
  119. package/lib/select/select.d.ts +3 -1
  120. package/lib/simple-color-picker/simple-color-picker.d.ts +2 -1
  121. package/lib/slider/slider.d.ts +1 -1
  122. package/lib/tabs/tabs.d.ts +2 -2
  123. package/lib/text-area/text-area.d.ts +1 -1
  124. package/lib/text-field/text-field.d.ts +1 -1
  125. package/lib/time-picker/time-picker.d.ts +20 -20
  126. package/locales/de-DE.cjs +20 -3
  127. package/locales/de-DE.js +20 -3
  128. package/locales/en-GB.cjs +21 -4
  129. package/locales/en-GB.js +21 -4
  130. package/locales/en-US.cjs +21 -4
  131. package/locales/en-US.js +21 -4
  132. package/locales/ja-JP.cjs +20 -3
  133. package/locales/ja-JP.js +20 -3
  134. package/locales/zh-CN.cjs +19 -2
  135. package/locales/zh-CN.js +19 -2
  136. package/menu/definition.cjs +4 -4
  137. package/menu/definition.js +4 -4
  138. package/nav-disclosure/definition.js +1 -1
  139. package/nav-item/definition.js +1 -1
  140. package/note/definition.js +1 -1
  141. package/number-field/definition.js +1 -1
  142. package/number-field/index.cjs +1 -1
  143. package/number-field/index.js +3 -3
  144. package/option/definition.cjs +6 -77
  145. package/option/definition.js +3 -78
  146. package/option/index.cjs +1 -1
  147. package/option/index.js +1 -1
  148. package/package.json +31 -5
  149. package/popup/definition.cjs +2 -2
  150. package/popup/definition.js +2 -2
  151. package/progress-ring/index.cjs +1 -1
  152. package/progress-ring/index.js +1 -1
  153. package/radio/index.cjs +1 -1
  154. package/radio/index.js +1 -1
  155. package/radio-group/index.cjs +1 -1
  156. package/radio-group/index.js +1 -1
  157. package/range-slider/definition.cjs +1 -1
  158. package/range-slider/definition.js +1 -1
  159. package/rich-text-editor/definition.cjs +2 -3
  160. package/rich-text-editor/definition.js +1 -2
  161. package/rich-text-editor/index.cjs +27 -27
  162. package/rich-text-editor/index.js +1209 -1199
  163. package/searchable-select/definition.cjs +103 -11
  164. package/searchable-select/definition.js +103 -11
  165. package/searchable-select/index.cjs +81 -69
  166. package/searchable-select/index.js +359 -273
  167. package/select/definition.cjs +30 -44
  168. package/select/definition.js +30 -44
  169. package/selectable-box/definition.cjs +1 -1
  170. package/selectable-box/definition.js +1 -1
  171. package/selectable-box/index.cjs +1 -1
  172. package/selectable-box/index.js +2 -2
  173. package/shared/aria/aria-mixin.d.ts +1 -1
  174. package/shared/color-picker/base-color-picker.d.ts +2 -1
  175. package/shared/foundation/listbox/listbox.d.ts +4 -0
  176. package/shared/picker-field/mixins/calendar-picker.d.ts +10 -10
  177. package/shared/picker-field/mixins/calendar-picker.template.d.ts +10 -10
  178. package/shared/picker-field/mixins/min-max-calendar-picker.d.ts +20 -20
  179. package/shared/picker-field/mixins/single-date-picker.d.ts +28 -28
  180. package/shared/picker-field/mixins/single-value-picker.d.ts +8 -8
  181. package/shared/picker-field/mixins/time-selection-picker.d.ts +20 -20
  182. package/shared/picker-field/mixins/time-selection-picker.template.d.ts +20 -20
  183. package/simple-color-picker/definition.cjs +9 -7
  184. package/simple-color-picker/definition.js +9 -7
  185. package/simple-color-picker/index.cjs +6 -6
  186. package/simple-color-picker/index.js +41 -39
  187. package/slider/definition.cjs +1 -1
  188. package/slider/definition.js +1 -1
  189. package/split-button/definition.js +1 -1
  190. package/styles/core/all.css +1 -1
  191. package/styles/core/theme.css +1 -1
  192. package/styles/core/typography.css +1 -1
  193. package/styles/tokens/theme-dark.css +4 -4
  194. package/styles/tokens/theme-light.css +4 -4
  195. package/styles/tokens/vivid-2-compat.css +1 -1
  196. package/tab/definition.js +1 -1
  197. package/tag/definition.cjs +34 -14
  198. package/tag/definition.js +35 -15
  199. package/tag/index.cjs +25 -12
  200. package/tag/index.js +64 -47
  201. package/tag-group/definition.cjs +1 -2
  202. package/tag-group/definition.js +1 -2
  203. package/tag-group/index.cjs +1 -1
  204. package/tag-group/index.js +11 -12
  205. package/text-area/index.cjs +1 -1
  206. package/text-area/index.js +2 -2
  207. package/text-field/definition.js +1 -1
  208. package/time-picker/definition.cjs +1 -1
  209. package/time-picker/definition.js +1 -1
  210. package/time-picker/index.cjs +1 -1
  211. package/time-picker/index.js +1 -1
  212. package/toggletip/definition.cjs +1 -1
  213. package/toggletip/definition.js +1 -1
  214. package/toggletip/index.cjs +1 -1
  215. package/toggletip/index.js +1 -1
  216. package/tooltip/definition.cjs +3 -3
  217. package/tooltip/definition.js +3 -3
  218. package/tooltip/index.cjs +1 -1
  219. package/tooltip/index.js +1 -1
  220. package/tree-item/definition.cjs +1 -1
  221. package/tree-item/definition.js +1 -1
  222. package/tree-view/definition.cjs +1 -1
  223. package/tree-view/definition.js +1 -1
  224. package/unbundled/affix.js +1 -1
  225. package/unbundled/base-color-picker.cjs +36 -18
  226. package/unbundled/base-color-picker.js +36 -18
  227. package/unbundled/calendar-picker.template.cjs +2 -2
  228. package/unbundled/calendar-picker.template.js +2 -2
  229. package/unbundled/definition.js +1 -1
  230. package/unbundled/definition2.js +1 -1
  231. package/unbundled/definition3.cjs +222 -141
  232. package/unbundled/definition3.js +220 -139
  233. package/unbundled/definition4.cjs +145 -235
  234. package/unbundled/definition4.js +143 -233
  235. package/unbundled/definition5.cjs +269 -27
  236. package/unbundled/definition5.js +267 -26
  237. package/unbundled/definition6.cjs +56 -0
  238. package/unbundled/definition6.js +52 -0
  239. package/unbundled/listbox.cjs +41 -63
  240. package/unbundled/listbox.js +39 -61
  241. package/unbundled/picker-field.template.cjs +3 -36
  242. package/unbundled/picker-field.template.js +3 -35
  243. package/unbundled/slider.template.cjs +1 -1
  244. package/unbundled/slider.template.js +1 -1
  245. package/unbundled/time-selection-picker.template.cjs +2 -1
  246. package/unbundled/time-selection-picker.template.js +2 -1
  247. package/unbundled/trapped-focus.cjs +37 -0
  248. package/unbundled/trapped-focus.js +34 -0
  249. package/unbundled/vivid-element.cjs +1 -1
  250. package/unbundled/vivid-element.js +1 -1
  251. package/video-player/definition.cjs +56 -16
  252. package/video-player/definition.js +56 -16
  253. package/video-player/index.cjs +36 -36
  254. package/video-player/index.js +2461 -2445
  255. package/visually-hidden/index.cjs +1 -1
  256. package/visually-hidden/index.js +1 -1
  257. package/vivid.api.json +285 -38
  258. package/bundled/_has.cjs +0 -1
  259. package/bundled/_has.js +0 -34
  260. package/bundled/option.cjs +0 -1
  261. package/bundled/option.js +0 -158
  262. package/unbundled/option.cjs +0 -217
  263. package/unbundled/option.js +0 -214
@@ -0,0 +1,56 @@
1
+ 'use strict';
2
+
3
+ const vividElement = require('./vivid-element.cjs');
4
+ const fastElement = require('@microsoft/fast-element');
5
+ const fastWebUtilities = require('@microsoft/fast-web-utilities');
6
+
7
+ var __defProp = Object.defineProperty;
8
+ var __decorateClass = (decorators, target, key, kind) => {
9
+ var result = void 0 ;
10
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
11
+ if (decorator = decorators[i])
12
+ result = (decorator(target, key, result) ) || result;
13
+ if (result) __defProp(target, key, result);
14
+ return result;
15
+ };
16
+ class Elevation extends vividElement.VividElement {
17
+ }
18
+ __decorateClass([
19
+ fastElement.attr
20
+ ], Elevation.prototype, "dp");
21
+ __decorateClass([
22
+ fastElement.attr({ attribute: "no-shadow", mode: "boolean" })
23
+ ], Elevation.prototype, "noShadow");
24
+ __decorateClass([
25
+ fastElement.attr({ attribute: "not-relative", mode: "boolean" })
26
+ ], Elevation.prototype, "notRelative");
27
+
28
+ const styles = ":host{display:contents}.control{display:contents}.control.dp-0{--_elevation-fill: var(--_vvd-tinted-color-surface-0dp, var(--vvd-color-surface-0dp));--_elevation-shadow: var(--_vvd-tinted-shadow-surface-0dp, var(--vvd-shadow-surface-0dp))}.control.dp-4{--_elevation-fill: var(--_vvd-tinted-color-surface-4dp, var(--vvd-color-surface-4dp));--_elevation-shadow: var(--_vvd-tinted-shadow-surface-4dp, var(--vvd-shadow-surface-4dp))}.control.dp-8{--_elevation-fill: var(--_vvd-tinted-color-surface-8dp, var(--vvd-color-surface-8dp));--_elevation-shadow: var(--_vvd-tinted-shadow-surface-8dp, var(--vvd-shadow-surface-8dp))}.control.dp-12{--_elevation-fill: var(--_vvd-tinted-color-surface-12dp, var(--vvd-color-surface-12dp));--_elevation-shadow: var(--_vvd-tinted-shadow-surface-12dp, var(--vvd-shadow-surface-12dp))}.control.dp-16{--_elevation-fill: var(--_vvd-tinted-color-surface-16dp, var(--vvd-color-surface-16dp));--_elevation-shadow: var(--_vvd-tinted-shadow-surface-16dp, var(--vvd-shadow-surface-16dp))}.control.dp-24{--_elevation-fill: var(--_vvd-tinted-color-surface-24dp, var(--vvd-color-surface-24dp));--_elevation-shadow: var(--_vvd-tinted-shadow-surface-24dp, var(--vvd-shadow-surface-24dp))}.control:not(.dp-0,.dp-4,.dp-8,.dp-12,.dp-16,.dp-24){--_elevation-fill: var(--_vvd-tinted-color-surface-2dp, var(--vvd-color-surface-2dp));--_elevation-shadow: var(--_vvd-tinted-shadow-surface-2dp, var(--vvd-shadow-surface-2dp))}.control ::slotted(*){isolation:isolate}.control ::slotted(*):before{position:absolute;z-index:-1;border-radius:inherit;background:var(--_elevation-fill);block-size:100%;content:\"\";filter:var(--_elevation-shadow);inline-size:100%;inset-block-start:0;inset-inline-start:0;transition:background-color .15s linear,filter .15s linear}.control:not(.not-relative) ::slotted(*){position:relative}.control.no-shadow ::slotted(*):before{filter:none}";
29
+
30
+ const getClasses = ({ dp, noShadow, notRelative }) => fastWebUtilities.classNames(
31
+ "control",
32
+ [`dp-${dp}`, Boolean(dp)],
33
+ ["no-shadow", Boolean(noShadow)],
34
+ ["not-relative", Boolean(notRelative)]
35
+ );
36
+ const elevationTemplate = fastElement.html` <div
37
+ class="${getClasses}"
38
+ part="base"
39
+ >
40
+ <slot></slot>
41
+ </div>`;
42
+
43
+ const elevationDefinition = vividElement.defineVividComponent(
44
+ "elevation",
45
+ Elevation,
46
+ elevationTemplate,
47
+ [],
48
+ {
49
+ styles
50
+ }
51
+ );
52
+ const registerElevation = vividElement.createRegisterFunction(elevationDefinition);
53
+
54
+ exports.Elevation = Elevation;
55
+ exports.elevationDefinition = elevationDefinition;
56
+ exports.registerElevation = registerElevation;
@@ -0,0 +1,52 @@
1
+ import { V as VividElement, d as defineVividComponent, c as createRegisterFunction } from './vivid-element.js';
2
+ import { attr, html } from '@microsoft/fast-element';
3
+ import { classNames } from '@microsoft/fast-web-utilities';
4
+
5
+ var __defProp = Object.defineProperty;
6
+ var __decorateClass = (decorators, target, key, kind) => {
7
+ var result = void 0 ;
8
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
9
+ if (decorator = decorators[i])
10
+ result = (decorator(target, key, result) ) || result;
11
+ if (result) __defProp(target, key, result);
12
+ return result;
13
+ };
14
+ class Elevation extends VividElement {
15
+ }
16
+ __decorateClass([
17
+ attr
18
+ ], Elevation.prototype, "dp");
19
+ __decorateClass([
20
+ attr({ attribute: "no-shadow", mode: "boolean" })
21
+ ], Elevation.prototype, "noShadow");
22
+ __decorateClass([
23
+ attr({ attribute: "not-relative", mode: "boolean" })
24
+ ], Elevation.prototype, "notRelative");
25
+
26
+ const styles = ":host{display:contents}.control{display:contents}.control.dp-0{--_elevation-fill: var(--_vvd-tinted-color-surface-0dp, var(--vvd-color-surface-0dp));--_elevation-shadow: var(--_vvd-tinted-shadow-surface-0dp, var(--vvd-shadow-surface-0dp))}.control.dp-4{--_elevation-fill: var(--_vvd-tinted-color-surface-4dp, var(--vvd-color-surface-4dp));--_elevation-shadow: var(--_vvd-tinted-shadow-surface-4dp, var(--vvd-shadow-surface-4dp))}.control.dp-8{--_elevation-fill: var(--_vvd-tinted-color-surface-8dp, var(--vvd-color-surface-8dp));--_elevation-shadow: var(--_vvd-tinted-shadow-surface-8dp, var(--vvd-shadow-surface-8dp))}.control.dp-12{--_elevation-fill: var(--_vvd-tinted-color-surface-12dp, var(--vvd-color-surface-12dp));--_elevation-shadow: var(--_vvd-tinted-shadow-surface-12dp, var(--vvd-shadow-surface-12dp))}.control.dp-16{--_elevation-fill: var(--_vvd-tinted-color-surface-16dp, var(--vvd-color-surface-16dp));--_elevation-shadow: var(--_vvd-tinted-shadow-surface-16dp, var(--vvd-shadow-surface-16dp))}.control.dp-24{--_elevation-fill: var(--_vvd-tinted-color-surface-24dp, var(--vvd-color-surface-24dp));--_elevation-shadow: var(--_vvd-tinted-shadow-surface-24dp, var(--vvd-shadow-surface-24dp))}.control:not(.dp-0,.dp-4,.dp-8,.dp-12,.dp-16,.dp-24){--_elevation-fill: var(--_vvd-tinted-color-surface-2dp, var(--vvd-color-surface-2dp));--_elevation-shadow: var(--_vvd-tinted-shadow-surface-2dp, var(--vvd-shadow-surface-2dp))}.control ::slotted(*){isolation:isolate}.control ::slotted(*):before{position:absolute;z-index:-1;border-radius:inherit;background:var(--_elevation-fill);block-size:100%;content:\"\";filter:var(--_elevation-shadow);inline-size:100%;inset-block-start:0;inset-inline-start:0;transition:background-color .15s linear,filter .15s linear}.control:not(.not-relative) ::slotted(*){position:relative}.control.no-shadow ::slotted(*):before{filter:none}";
27
+
28
+ const getClasses = ({ dp, noShadow, notRelative }) => classNames(
29
+ "control",
30
+ [`dp-${dp}`, Boolean(dp)],
31
+ ["no-shadow", Boolean(noShadow)],
32
+ ["not-relative", Boolean(notRelative)]
33
+ );
34
+ const elevationTemplate = html` <div
35
+ class="${getClasses}"
36
+ part="base"
37
+ >
38
+ <slot></slot>
39
+ </div>`;
40
+
41
+ const elevationDefinition = defineVividComponent(
42
+ "elevation",
43
+ Elevation,
44
+ elevationTemplate,
45
+ [],
46
+ {
47
+ styles
48
+ }
49
+ );
50
+ const registerElevation = createRegisterFunction(elevationDefinition);
51
+
52
+ export { Elevation as E, elevationDefinition as e, registerElevation as r };
@@ -2,7 +2,7 @@
2
2
 
3
3
  const fastElement = require('@microsoft/fast-element');
4
4
  const fastWebUtilities = require('@microsoft/fast-web-utilities');
5
- const option = require('./option.cjs');
5
+ const option_definition = require('./definition3.cjs');
6
6
  const vividElement = require('./vivid-element.cjs');
7
7
 
8
8
  var __defProp = Object.defineProperty;
@@ -55,14 +55,6 @@ const _Listbox = class _Listbox extends vividElement.VividElement {
55
55
  get firstSelectedOption() {
56
56
  return this.selectedOptions[0] ?? null;
57
57
  }
58
- /**
59
- * Returns true if there is one or more selectable option.
60
- *
61
- * @internal
62
- */
63
- get hasSelectableOptions() {
64
- return this.options.length > 0 && !this.options.every((o) => o.disabled);
65
- }
66
58
  /**
67
59
  * The number of options.
68
60
  *
@@ -81,8 +73,19 @@ const _Listbox = class _Listbox extends vividElement.VividElement {
81
73
  return this._options;
82
74
  }
83
75
  set options(value) {
76
+ const prev = this._options;
84
77
  this._options = value;
85
78
  fastElement.Observable.notify(this, "options");
79
+ if (this.$fastController.isConnected) {
80
+ const newSelectedIndex = this._newDefaultSelectedIndex(
81
+ prev,
82
+ value,
83
+ this.selectedIndex
84
+ );
85
+ if (newSelectedIndex !== null) {
86
+ this.selectedIndex = newSelectedIndex;
87
+ }
88
+ }
86
89
  }
87
90
  static {
88
91
  /**
@@ -91,7 +94,7 @@ const _Listbox = class _Listbox extends vividElement.VividElement {
91
94
  * @param n - element to filter
92
95
  * @public
93
96
  */
94
- this.slottedOptionFilter = (n) => option.isListboxOption(n) && !n.hidden;
97
+ this.slottedOptionFilter = (n) => option_definition.isListboxOption(n) && !n.hidden;
95
98
  }
96
99
  static {
97
100
  /**
@@ -156,34 +159,11 @@ const _Listbox = class _Listbox extends vividElement.VividElement {
156
159
  const re = new RegExp(`^${pattern}`, "gi");
157
160
  return this.options.filter((o) => o.text.trim().match(re));
158
161
  }
159
- /**
160
- * Determines the index of the next option which is selectable, if any.
161
- *
162
- * @param prev - the previous selected index
163
- * @param next - the next index to select
164
- *
165
- * @internal
166
- */
167
- getSelectableIndex(prev, next) {
168
- const direction = prev > next ? -1 : 1;
169
- const potentialDirection = prev + direction;
170
- let nextSelectableOption = null;
171
- switch (direction) {
172
- case -1: {
173
- nextSelectableOption = this.options.reduceRight(
174
- (nextSelectableOption2, thisOption, index) => !nextSelectableOption2 && !thisOption.disabled && index < potentialDirection ? thisOption : nextSelectableOption2,
175
- nextSelectableOption
176
- );
177
- break;
178
- }
179
- case 1: {
180
- nextSelectableOption = this.options.reduce(
181
- (nextSelectableOption2, thisOption, index) => !nextSelectableOption2 && !thisOption.disabled && index > potentialDirection ? thisOption : nextSelectableOption2,
182
- nextSelectableOption
183
- );
184
- break;
185
- }
186
- }
162
+ getNextSelectableIndex(fromIndex) {
163
+ const nextSelectableOption = this.options.reduce(
164
+ (nextSelectableOption2, thisOption, index) => !nextSelectableOption2 && !thisOption.disabled && index >= fromIndex ? thisOption : nextSelectableOption2,
165
+ null
166
+ );
187
167
  return this.options.indexOf(nextSelectableOption);
188
168
  }
189
169
  /**
@@ -301,18 +281,17 @@ const _Listbox = class _Listbox extends vividElement.VividElement {
301
281
  * @internal
302
282
  */
303
283
  selectedIndexChanged(prev, next) {
304
- if (!this.hasSelectableOptions) {
305
- this.selectedIndex = -1;
306
- return;
307
- }
308
- if (this.options[this.selectedIndex]?.disabled && typeof prev === "number") {
309
- const selectableIndex = this.getSelectableIndex(prev, next);
310
- const newNext = selectableIndex > -1 ? selectableIndex : prev;
311
- this.selectedIndex = newNext;
284
+ const validNext = this._validSelectedIndex(next);
285
+ if (next !== validNext) {
286
+ this.selectedIndex = validNext;
312
287
  return;
313
288
  }
314
289
  this.setSelectedOptions();
315
290
  }
291
+ _validSelectedIndex(index) {
292
+ const outOfRange = index > this.options.length - 1 || index < -1;
293
+ return outOfRange ? -1 : index;
294
+ }
316
295
  /**
317
296
  * Updates the selectedness of each option when the list of selected options changes.
318
297
  *
@@ -367,13 +346,18 @@ const _Listbox = class _Listbox extends vividElement.VividElement {
367
346
  this.selectedIndex = this.selectedIndex - 1;
368
347
  }
369
348
  }
370
- /**
371
- * Updates the selected index to match the first selected option.
372
- *
373
- * @internal
374
- */
375
- setDefaultSelectedOption() {
376
- this.selectedIndex = this.options.findIndex((el) => el.defaultSelected);
349
+ /// For this options change, determine if selectedIndex should change based on defaultSelected. Otherwise, returns null.
350
+ _newDefaultSelectedIndex(prev, next, currentSelectedIndex) {
351
+ for (const [index, newOption] of next.entries()) {
352
+ if (this._isDefaultSelected(newOption) && !prev.includes(newOption)) {
353
+ return index;
354
+ }
355
+ }
356
+ return null;
357
+ }
358
+ /// Whether an option should be considered defaultSelected
359
+ _isDefaultSelected(option) {
360
+ return option.defaultSelected;
377
361
  }
378
362
  /**
379
363
  * Sets an option as selected and gives it focus.
@@ -381,11 +365,9 @@ const _Listbox = class _Listbox extends vividElement.VividElement {
381
365
  * @public
382
366
  */
383
367
  setSelectedOptions() {
384
- if (this.options.length) {
385
- this.selectedOptions = [this.options[this.selectedIndex]];
386
- this._activeDescendant = this.firstSelectedOption?.id ?? "";
387
- this.focusAndScrollOptionIntoView();
388
- }
368
+ this.selectedOptions = this.selectedIndex !== -1 ? [this.options[this.selectedIndex]] : [];
369
+ this._activeDescendant = this.firstSelectedOption?.id ?? "";
370
+ this.focusAndScrollOptionIntoView();
389
371
  }
390
372
  /**
391
373
  * Updates the list of options and resets the selected option when the slotted option content changes.
@@ -394,7 +376,7 @@ const _Listbox = class _Listbox extends vividElement.VividElement {
394
376
  */
395
377
  slottedOptionsChanged(_, next) {
396
378
  this.options = next.reduce((options, item) => {
397
- if (option.isListboxOption(item)) {
379
+ if (option_definition.isListboxOption(item)) {
398
380
  options.push(item);
399
381
  }
400
382
  return options;
@@ -407,10 +389,6 @@ const _Listbox = class _Listbox extends vividElement.VividElement {
407
389
  option.ariaPosInSet = `${index + 1}`;
408
390
  option.ariaSetSize = setSize;
409
391
  });
410
- if (this.$fastController.isConnected) {
411
- this.setSelectedOptions();
412
- this.setDefaultSelectedOption();
413
- }
414
392
  }
415
393
  /**
416
394
  * Updates the filtered list of options when the typeahead buffer changes.
@@ -1,6 +1,6 @@
1
1
  import { Observable, attr, observable } from '@microsoft/fast-element';
2
2
  import { keySpace, keyEscape, keyEnter, keyTab, keyEnd, keyArrowUp, keyArrowDown, keyHome, findLastIndex, uniqueId } from '@microsoft/fast-web-utilities';
3
- import { i as isListboxOption } from './option.js';
3
+ import { i as isListboxOption } from './definition3.js';
4
4
  import { V as VividElement } from './vivid-element.js';
5
5
 
6
6
  var __defProp = Object.defineProperty;
@@ -53,14 +53,6 @@ const _Listbox = class _Listbox extends VividElement {
53
53
  get firstSelectedOption() {
54
54
  return this.selectedOptions[0] ?? null;
55
55
  }
56
- /**
57
- * Returns true if there is one or more selectable option.
58
- *
59
- * @internal
60
- */
61
- get hasSelectableOptions() {
62
- return this.options.length > 0 && !this.options.every((o) => o.disabled);
63
- }
64
56
  /**
65
57
  * The number of options.
66
58
  *
@@ -79,8 +71,19 @@ const _Listbox = class _Listbox extends VividElement {
79
71
  return this._options;
80
72
  }
81
73
  set options(value) {
74
+ const prev = this._options;
82
75
  this._options = value;
83
76
  Observable.notify(this, "options");
77
+ if (this.$fastController.isConnected) {
78
+ const newSelectedIndex = this._newDefaultSelectedIndex(
79
+ prev,
80
+ value,
81
+ this.selectedIndex
82
+ );
83
+ if (newSelectedIndex !== null) {
84
+ this.selectedIndex = newSelectedIndex;
85
+ }
86
+ }
84
87
  }
85
88
  static {
86
89
  /**
@@ -154,34 +157,11 @@ const _Listbox = class _Listbox extends VividElement {
154
157
  const re = new RegExp(`^${pattern}`, "gi");
155
158
  return this.options.filter((o) => o.text.trim().match(re));
156
159
  }
157
- /**
158
- * Determines the index of the next option which is selectable, if any.
159
- *
160
- * @param prev - the previous selected index
161
- * @param next - the next index to select
162
- *
163
- * @internal
164
- */
165
- getSelectableIndex(prev, next) {
166
- const direction = prev > next ? -1 : 1;
167
- const potentialDirection = prev + direction;
168
- let nextSelectableOption = null;
169
- switch (direction) {
170
- case -1: {
171
- nextSelectableOption = this.options.reduceRight(
172
- (nextSelectableOption2, thisOption, index) => !nextSelectableOption2 && !thisOption.disabled && index < potentialDirection ? thisOption : nextSelectableOption2,
173
- nextSelectableOption
174
- );
175
- break;
176
- }
177
- case 1: {
178
- nextSelectableOption = this.options.reduce(
179
- (nextSelectableOption2, thisOption, index) => !nextSelectableOption2 && !thisOption.disabled && index > potentialDirection ? thisOption : nextSelectableOption2,
180
- nextSelectableOption
181
- );
182
- break;
183
- }
184
- }
160
+ getNextSelectableIndex(fromIndex) {
161
+ const nextSelectableOption = this.options.reduce(
162
+ (nextSelectableOption2, thisOption, index) => !nextSelectableOption2 && !thisOption.disabled && index >= fromIndex ? thisOption : nextSelectableOption2,
163
+ null
164
+ );
185
165
  return this.options.indexOf(nextSelectableOption);
186
166
  }
187
167
  /**
@@ -299,18 +279,17 @@ const _Listbox = class _Listbox extends VividElement {
299
279
  * @internal
300
280
  */
301
281
  selectedIndexChanged(prev, next) {
302
- if (!this.hasSelectableOptions) {
303
- this.selectedIndex = -1;
304
- return;
305
- }
306
- if (this.options[this.selectedIndex]?.disabled && typeof prev === "number") {
307
- const selectableIndex = this.getSelectableIndex(prev, next);
308
- const newNext = selectableIndex > -1 ? selectableIndex : prev;
309
- this.selectedIndex = newNext;
282
+ const validNext = this._validSelectedIndex(next);
283
+ if (next !== validNext) {
284
+ this.selectedIndex = validNext;
310
285
  return;
311
286
  }
312
287
  this.setSelectedOptions();
313
288
  }
289
+ _validSelectedIndex(index) {
290
+ const outOfRange = index > this.options.length - 1 || index < -1;
291
+ return outOfRange ? -1 : index;
292
+ }
314
293
  /**
315
294
  * Updates the selectedness of each option when the list of selected options changes.
316
295
  *
@@ -365,13 +344,18 @@ const _Listbox = class _Listbox extends VividElement {
365
344
  this.selectedIndex = this.selectedIndex - 1;
366
345
  }
367
346
  }
368
- /**
369
- * Updates the selected index to match the first selected option.
370
- *
371
- * @internal
372
- */
373
- setDefaultSelectedOption() {
374
- this.selectedIndex = this.options.findIndex((el) => el.defaultSelected);
347
+ /// For this options change, determine if selectedIndex should change based on defaultSelected. Otherwise, returns null.
348
+ _newDefaultSelectedIndex(prev, next, currentSelectedIndex) {
349
+ for (const [index, newOption] of next.entries()) {
350
+ if (this._isDefaultSelected(newOption) && !prev.includes(newOption)) {
351
+ return index;
352
+ }
353
+ }
354
+ return null;
355
+ }
356
+ /// Whether an option should be considered defaultSelected
357
+ _isDefaultSelected(option) {
358
+ return option.defaultSelected;
375
359
  }
376
360
  /**
377
361
  * Sets an option as selected and gives it focus.
@@ -379,11 +363,9 @@ const _Listbox = class _Listbox extends VividElement {
379
363
  * @public
380
364
  */
381
365
  setSelectedOptions() {
382
- if (this.options.length) {
383
- this.selectedOptions = [this.options[this.selectedIndex]];
384
- this._activeDescendant = this.firstSelectedOption?.id ?? "";
385
- this.focusAndScrollOptionIntoView();
386
- }
366
+ this.selectedOptions = this.selectedIndex !== -1 ? [this.options[this.selectedIndex]] : [];
367
+ this._activeDescendant = this.firstSelectedOption?.id ?? "";
368
+ this.focusAndScrollOptionIntoView();
387
369
  }
388
370
  /**
389
371
  * Updates the list of options and resets the selected option when the slotted option content changes.
@@ -405,10 +387,6 @@ const _Listbox = class _Listbox extends VividElement {
405
387
  option.ariaPosInSet = `${index + 1}`;
406
388
  option.ariaSetSize = setSize;
407
389
  });
408
- if (this.$fastController.isConnected) {
409
- this.setSelectedOptions();
410
- this.setDefaultSelectedOption();
411
- }
412
390
  }
413
391
  /**
414
392
  * Updates the filtered list of options when the typeahead buffer changes.
@@ -8,45 +8,13 @@ const vividElement = require('./vivid-element.cjs');
8
8
  const withContextualHelp = require('./with-contextual-help.cjs');
9
9
  const withErrorText = require('./with-error-text.cjs');
10
10
  const formElement = require('./form-element.cjs');
11
+ const trappedFocus = require('./trapped-focus.cjs');
11
12
  const localized = require('./localized.cjs');
12
13
  const fastWebUtilities = require('@microsoft/fast-web-utilities');
13
- const popup_definition = require('./definition4.cjs');
14
+ const popup_definition = require('./definition5.cjs');
14
15
  const textField_definition = require('../text-field/definition.cjs');
15
16
  const button_definition = require('./definition.cjs');
16
17
 
17
- const ignoredEvents = /* @__PURE__ */ new WeakSet();
18
- const ignoreEventInFocusTraps = (event) => {
19
- ignoredEvents.add(event);
20
- };
21
- const TrappedFocus = (Base) => {
22
- class TrappedFocusElement extends Base {
23
- /**
24
- * @returns Whether focus was trapped.
25
- * @internal
26
- */
27
- _trappedFocus(event, getFocusableEls) {
28
- if (!ignoredEvents.has(event) && event.key === "Tab") {
29
- const focusableEls = getFocusableEls();
30
- const firstFocusableEl = focusableEls[0];
31
- const lastFocusableEl = focusableEls[focusableEls.length - 1];
32
- if (event.shiftKey) {
33
- if (this.shadowRoot.activeElement === firstFocusableEl) {
34
- lastFocusableEl.focus();
35
- return true;
36
- }
37
- } else {
38
- if (this.shadowRoot.activeElement === lastFocusableEl) {
39
- firstFocusableEl.focus();
40
- return true;
41
- }
42
- }
43
- }
44
- return false;
45
- }
46
- }
47
- return TrappedFocusElement;
48
- };
49
-
50
18
  const pickerFieldStyles = ":host{display:inline-block}.base{display:inline-block;inline-size:100%}.control{inline-size:100%}.dialog{display:inline-flex;flex-direction:column}.dialog--padded{padding:12px;gap:12px}.dialog .footer{display:flex;align-items:center;justify-content:flex-end;padding:8px;gap:8px}.dialog .footer--with-separator{border-top:1px solid var(--vvd-color-neutral-200)}";
51
19
 
52
20
  var __defProp = Object.defineProperty;
@@ -61,7 +29,7 @@ var __decorateClass = (decorators, target, key, kind) => {
61
29
  class PickerField extends withContextualHelp.WithContextualHelp(
62
30
  mixins.WithFeedback(
63
31
  withErrorText.WithErrorText(
64
- formElement.FormElement(TrappedFocus(localized.Localized(formAssociated.FormAssociated(vividElement.VividElement))))
32
+ formElement.FormElement(trappedFocus.TrappedFocus(localized.Localized(formAssociated.FormAssociated(vividElement.VividElement))))
65
33
  )
66
34
  )
67
35
  ) {
@@ -308,5 +276,4 @@ const PickerFieldTemplate = (context, popupContentTemplate, { withSeparator, pad
308
276
 
309
277
  exports.PickerField = PickerField;
310
278
  exports.PickerFieldTemplate = PickerFieldTemplate;
311
- exports.ignoreEventInFocusTraps = ignoreEventInFocusTraps;
312
279
  exports.pickerFieldStyles = pickerFieldStyles;
@@ -6,45 +6,13 @@ import { V as VividElement } from './vivid-element.js';
6
6
  import { W as WithContextualHelp } from './with-contextual-help.js';
7
7
  import { W as WithErrorText } from './with-error-text.js';
8
8
  import { F as FormElement } from './form-element.js';
9
+ import { T as TrappedFocus } from './trapped-focus.js';
9
10
  import { L as Localized } from './localized.js';
10
11
  import { classNames } from '@microsoft/fast-web-utilities';
11
- import { P as Popup } from './definition4.js';
12
+ import { P as Popup } from './definition5.js';
12
13
  import { VwcTextFieldElement as TextField } from '../text-field/definition.js';
13
14
  import { B as Button } from './definition.js';
14
15
 
15
- const ignoredEvents = /* @__PURE__ */ new WeakSet();
16
- const ignoreEventInFocusTraps = (event) => {
17
- ignoredEvents.add(event);
18
- };
19
- const TrappedFocus = (Base) => {
20
- class TrappedFocusElement extends Base {
21
- /**
22
- * @returns Whether focus was trapped.
23
- * @internal
24
- */
25
- _trappedFocus(event, getFocusableEls) {
26
- if (!ignoredEvents.has(event) && event.key === "Tab") {
27
- const focusableEls = getFocusableEls();
28
- const firstFocusableEl = focusableEls[0];
29
- const lastFocusableEl = focusableEls[focusableEls.length - 1];
30
- if (event.shiftKey) {
31
- if (this.shadowRoot.activeElement === firstFocusableEl) {
32
- lastFocusableEl.focus();
33
- return true;
34
- }
35
- } else {
36
- if (this.shadowRoot.activeElement === lastFocusableEl) {
37
- firstFocusableEl.focus();
38
- return true;
39
- }
40
- }
41
- }
42
- return false;
43
- }
44
- }
45
- return TrappedFocusElement;
46
- };
47
-
48
16
  const pickerFieldStyles = ":host{display:inline-block}.base{display:inline-block;inline-size:100%}.control{inline-size:100%}.dialog{display:inline-flex;flex-direction:column}.dialog--padded{padding:12px;gap:12px}.dialog .footer{display:flex;align-items:center;justify-content:flex-end;padding:8px;gap:8px}.dialog .footer--with-separator{border-top:1px solid var(--vvd-color-neutral-200)}";
49
17
 
50
18
  var __defProp = Object.defineProperty;
@@ -304,4 +272,4 @@ const PickerFieldTemplate = (context, popupContentTemplate, { withSeparator, pad
304
272
  </div>`;
305
273
  };
306
274
 
307
- export { PickerFieldTemplate as P, PickerField as a, ignoreEventInFocusTraps as i, pickerFieldStyles as p };
275
+ export { PickerFieldTemplate as P, PickerField as a, pickerFieldStyles as p };
@@ -2,7 +2,7 @@
2
2
 
3
3
  const fastWebUtilities = require('@microsoft/fast-web-utilities');
4
4
  const fastElement = require('@microsoft/fast-element');
5
- const popup_definition = require('./definition4.cjs');
5
+ const popup_definition = require('./definition5.cjs');
6
6
  const delegatesAria = require('./delegates-aria.cjs');
7
7
 
8
8
  const getDecimalPlaces = (num) => {
@@ -1,6 +1,6 @@
1
1
  import { limit, classNames, Orientation } from '@microsoft/fast-web-utilities';
2
2
  import { ref, when, html } from '@microsoft/fast-element';
3
- import { P as Popup, a as PlacementStrategy } from './definition4.js';
3
+ import { P as Popup, a as PlacementStrategy } from './definition5.js';
4
4
  import { d as delegateAria } from './delegates-aria.js';
5
5
 
6
6
  const getDecimalPlaces = (num) => {
@@ -6,6 +6,7 @@ const pickerField_template = require('./picker-field.template.cjs');
6
6
  const singleValuePicker = require('./single-value-picker.cjs');
7
7
  const fastWebUtilities = require('@microsoft/fast-web-utilities');
8
8
  const scrollIntoView = require('./scrollIntoView.cjs');
9
+ const trappedFocus = require('./trapped-focus.cjs');
9
10
  const localized = require('./localized.cjs');
10
11
 
11
12
  const isValidTimeStr = (timeStr) => {
@@ -261,7 +262,7 @@ const onBaseKeyDown = (x, event) => {
261
262
  const focusableElements = x.shadowRoot.querySelectorAll(".picker");
262
263
  const terminalElement = event.shiftKey ? focusableElements[0] : focusableElements[focusableElements.length - 1];
263
264
  if (x.shadowRoot.activeElement !== terminalElement) {
264
- pickerField_template.ignoreEventInFocusTraps(event);
265
+ trappedFocus.ignoreEventInFocusTraps(event);
265
266
  }
266
267
  x._applyFocusedClass();
267
268
  }
@@ -1,9 +1,10 @@
1
1
  import { V as VividElement, d as defineVividComponent } from './vivid-element.js';
2
2
  import { when, html, repeat, observable, attr, nullableNumberConverter, Observable, ExecutionContext, Updates, volatile, ref } from '@microsoft/fast-element';
3
- import { i as ignoreEventInFocusTraps, a as PickerField } from './picker-field.template.js';
3
+ import { a as PickerField } from './picker-field.template.js';
4
4
  import { S as SingleValuePicker } from './single-value-picker.js';
5
5
  import { classNames } from '@microsoft/fast-web-utilities';
6
6
  import { s as scrollIntoView } from './scrollIntoView.js';
7
+ import { i as ignoreEventInFocusTraps } from './trapped-focus.js';
7
8
  import { L as Localized } from './localized.js';
8
9
 
9
10
  const isValidTimeStr = (timeStr) => {
@@ -0,0 +1,37 @@
1
+ 'use strict';
2
+
3
+ const ignoredEvents = /* @__PURE__ */ new WeakSet();
4
+ const ignoreEventInFocusTraps = (event) => {
5
+ ignoredEvents.add(event);
6
+ };
7
+ const TrappedFocus = (Base) => {
8
+ class TrappedFocusElement extends Base {
9
+ /**
10
+ * @returns Whether focus was trapped.
11
+ * @internal
12
+ */
13
+ _trappedFocus(event, getFocusableEls) {
14
+ if (!ignoredEvents.has(event) && event.key === "Tab") {
15
+ const focusableEls = getFocusableEls();
16
+ const firstFocusableEl = focusableEls[0];
17
+ const lastFocusableEl = focusableEls[focusableEls.length - 1];
18
+ if (event.shiftKey) {
19
+ if (this.shadowRoot.activeElement === firstFocusableEl) {
20
+ lastFocusableEl.focus();
21
+ return true;
22
+ }
23
+ } else {
24
+ if (this.shadowRoot.activeElement === lastFocusableEl) {
25
+ firstFocusableEl.focus();
26
+ return true;
27
+ }
28
+ }
29
+ }
30
+ return false;
31
+ }
32
+ }
33
+ return TrappedFocusElement;
34
+ };
35
+
36
+ exports.TrappedFocus = TrappedFocus;
37
+ exports.ignoreEventInFocusTraps = ignoreEventInFocusTraps;