@vonage/vivid 3.52.0 → 3.54.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (299) hide show
  1. package/README.md +1 -1
  2. package/accordion/index.cjs +1 -1
  3. package/accordion/index.js +1 -1
  4. package/accordion-item/index.cjs +1 -1
  5. package/accordion-item/index.js +1 -1
  6. package/alert/index.cjs +3 -3
  7. package/alert/index.js +3 -3
  8. package/appearance-ui/index.cjs +1 -1
  9. package/appearance-ui/index.js +1 -1
  10. package/audio-player/index.cjs +3 -3
  11. package/audio-player/index.js +3 -3
  12. package/avatar/index.cjs +1 -1
  13. package/avatar/index.js +1 -1
  14. package/badge/index.cjs +1 -1
  15. package/badge/index.js +1 -1
  16. package/banner/index.cjs +2 -2
  17. package/banner/index.js +2 -2
  18. package/breadcrumb-item/index.cjs +1 -1
  19. package/breadcrumb-item/index.js +1 -1
  20. package/button/index.cjs +2 -2
  21. package/button/index.js +2 -2
  22. package/card/index.cjs +2 -2
  23. package/card/index.js +2 -2
  24. package/checkbox/index.cjs +3 -2
  25. package/checkbox/index.js +3 -2
  26. package/combobox/index.cjs +5 -5
  27. package/combobox/index.js +5 -5
  28. package/custom-elements.json +1162 -99
  29. package/data-grid/index.cjs +1 -1
  30. package/data-grid/index.js +1 -1
  31. package/date-picker/index.cjs +7 -6
  32. package/date-picker/index.js +7 -6
  33. package/date-range-picker/index.cjs +7 -6
  34. package/date-range-picker/index.js +7 -6
  35. package/dial-pad/index.cjs +33 -0
  36. package/dial-pad/index.js +31 -0
  37. package/dialog/index.cjs +4 -4
  38. package/dialog/index.js +4 -4
  39. package/divider/index.cjs +1 -1
  40. package/divider/index.js +1 -1
  41. package/elevation/index.cjs +1 -1
  42. package/elevation/index.js +1 -1
  43. package/empty-state/index.cjs +2 -2
  44. package/empty-state/index.js +2 -2
  45. package/fab/index.cjs +2 -2
  46. package/fab/index.js +2 -2
  47. package/file-picker/index.cjs +4 -3
  48. package/file-picker/index.js +4 -3
  49. package/header/index.cjs +2 -2
  50. package/header/index.js +2 -2
  51. package/icon/index.cjs +1 -1
  52. package/icon/index.js +1 -1
  53. package/index.cjs +132 -122
  54. package/index.js +46 -43
  55. package/layout/index.cjs +1 -1
  56. package/layout/index.js +1 -1
  57. package/lib/appearance-ui/appearance-ui.d.ts +1 -1
  58. package/lib/audio-player/audio-player.d.ts +4 -0
  59. package/lib/audio-player/locale.d.ts +2 -0
  60. package/lib/components.d.ts +2 -0
  61. package/lib/dial-pad/definition.d.ts +3 -0
  62. package/lib/dial-pad/dial-pad.d.ts +17 -0
  63. package/lib/dial-pad/dial-pad.template.d.ts +4 -0
  64. package/lib/dial-pad/locale.d.ts +18 -0
  65. package/lib/enums.d.ts +7 -0
  66. package/lib/menu/menu.d.ts +1 -0
  67. package/lib/nav-disclosure/nav-disclosure.d.ts +5 -0
  68. package/lib/text-anchor/definition.d.ts +1 -0
  69. package/lib/text-anchor/text-anchor.d.ts +5 -0
  70. package/lib/video-player/definition.d.ts +3 -0
  71. package/lib/video-player/locale.d.ts +1 -0
  72. package/lib/video-player/video-player.d.ts +17 -0
  73. package/lib/video-player/video-player.template.d.ts +4 -0
  74. package/lib/video-player/vivid-video-svg.d.ts +1 -0
  75. package/listbox/index.cjs +2 -2
  76. package/listbox/index.js +2 -2
  77. package/locales/en-GB.cjs +33 -1
  78. package/locales/en-GB.js +33 -1
  79. package/locales/en-US.cjs +201 -1
  80. package/locales/en-US.js +201 -1
  81. package/locales/ja-JP.cjs +200 -1
  82. package/locales/ja-JP.js +200 -1
  83. package/locales/zh-CN.cjs +202 -1
  84. package/locales/zh-CN.js +202 -1
  85. package/menu/index.cjs +6 -6
  86. package/menu/index.js +6 -6
  87. package/menu-item/index.cjs +2 -2
  88. package/menu-item/index.js +2 -2
  89. package/nav/index.cjs +1 -1
  90. package/nav/index.js +1 -1
  91. package/nav-disclosure/index.cjs +2 -2
  92. package/nav-disclosure/index.js +2 -2
  93. package/nav-item/index.cjs +2 -2
  94. package/nav-item/index.js +2 -2
  95. package/note/index.cjs +2 -2
  96. package/note/index.js +2 -2
  97. package/number-field/index.cjs +5 -4
  98. package/number-field/index.js +5 -4
  99. package/option/index.cjs +2 -2
  100. package/option/index.js +2 -2
  101. package/package.json +1 -1
  102. package/pagination/index.cjs +3 -3
  103. package/pagination/index.js +3 -3
  104. package/popup/index.cjs +4 -4
  105. package/popup/index.js +4 -4
  106. package/progress/index.cjs +1 -1
  107. package/progress/index.js +1 -1
  108. package/progress-ring/index.cjs +1 -1
  109. package/progress-ring/index.js +1 -1
  110. package/radio/index.cjs +1 -1
  111. package/radio/index.js +1 -1
  112. package/radio-group/index.cjs +1 -1
  113. package/radio-group/index.js +1 -1
  114. package/range-slider/index.cjs +2 -2
  115. package/range-slider/index.js +2 -2
  116. package/select/index.cjs +7 -6
  117. package/select/index.js +7 -6
  118. package/selectable-box/index.cjs +5 -4
  119. package/selectable-box/index.js +5 -4
  120. package/shared/applyMixinsWithObservables.cjs +15 -0
  121. package/shared/applyMixinsWithObservables.js +13 -0
  122. package/shared/definition.cjs +1 -1
  123. package/shared/definition.js +1 -1
  124. package/shared/definition11.cjs +3 -3
  125. package/shared/definition11.js +3 -3
  126. package/shared/definition14.cjs +2 -2
  127. package/shared/definition14.js +2 -2
  128. package/shared/definition15.cjs +8 -9
  129. package/shared/definition15.js +8 -9
  130. package/shared/definition16.cjs +3 -3
  131. package/shared/definition16.js +3 -3
  132. package/shared/definition17.cjs +2 -2
  133. package/shared/definition17.js +3 -3
  134. package/shared/definition18.cjs +3 -3
  135. package/shared/definition18.js +3 -3
  136. package/shared/definition19.cjs +3 -3
  137. package/shared/definition19.js +3 -3
  138. package/shared/definition20.cjs +196 -224
  139. package/shared/definition20.js +191 -219
  140. package/shared/definition21.cjs +264 -67
  141. package/shared/definition21.js +263 -65
  142. package/shared/definition22.cjs +66 -57
  143. package/shared/definition22.js +64 -56
  144. package/shared/definition23.cjs +42 -76
  145. package/shared/definition23.js +41 -75
  146. package/shared/definition24.cjs +70 -2402
  147. package/shared/definition24.js +69 -2401
  148. package/shared/definition25.cjs +2402 -46
  149. package/shared/definition25.js +2401 -45
  150. package/shared/definition26.cjs +63 -30
  151. package/shared/definition26.js +62 -29
  152. package/shared/definition27.cjs +28 -56
  153. package/shared/definition27.js +27 -55
  154. package/shared/definition28.cjs +35 -881
  155. package/shared/definition28.js +34 -879
  156. package/shared/definition29.cjs +922 -60
  157. package/shared/definition29.js +922 -61
  158. package/shared/definition30.cjs +68 -86
  159. package/shared/definition30.js +67 -85
  160. package/shared/definition31.cjs +98 -21
  161. package/shared/definition31.js +98 -21
  162. package/shared/definition32.cjs +24 -12
  163. package/shared/definition32.js +23 -11
  164. package/shared/definition33.cjs +11 -50
  165. package/shared/definition33.js +10 -49
  166. package/shared/definition34.cjs +26 -515
  167. package/shared/definition34.js +26 -515
  168. package/shared/definition35.cjs +448 -194
  169. package/shared/definition35.js +448 -192
  170. package/shared/definition36.cjs +256 -202
  171. package/shared/definition36.js +253 -201
  172. package/shared/definition37.cjs +204 -65
  173. package/shared/definition37.js +203 -63
  174. package/shared/definition38.cjs +63 -57
  175. package/shared/definition38.js +60 -55
  176. package/shared/definition39.cjs +65 -432
  177. package/shared/definition39.js +64 -431
  178. package/shared/definition4.cjs +2 -2
  179. package/shared/definition4.js +2 -2
  180. package/shared/definition40.cjs +441 -34
  181. package/shared/definition40.js +438 -31
  182. package/shared/definition41.cjs +34 -576
  183. package/shared/definition41.js +33 -575
  184. package/shared/definition42.cjs +531 -654
  185. package/shared/definition42.js +531 -654
  186. package/shared/definition43.cjs +690 -114
  187. package/shared/definition43.js +689 -113
  188. package/shared/definition44.cjs +124 -79
  189. package/shared/definition44.js +122 -77
  190. package/shared/definition45.cjs +78 -520
  191. package/shared/definition45.js +77 -518
  192. package/shared/definition46.cjs +520 -119
  193. package/shared/definition46.js +518 -118
  194. package/shared/definition47.cjs +118 -135
  195. package/shared/definition47.js +117 -134
  196. package/shared/definition48.cjs +151 -19
  197. package/shared/definition48.js +150 -18
  198. package/shared/definition49.cjs +21 -84
  199. package/shared/definition49.js +20 -83
  200. package/shared/definition5.cjs +100 -19
  201. package/shared/definition5.js +100 -19
  202. package/shared/definition50.cjs +52 -505
  203. package/shared/definition50.js +51 -504
  204. package/shared/definition51.cjs +526 -28
  205. package/shared/definition51.js +525 -27
  206. package/shared/definition52.cjs +28 -123
  207. package/shared/definition52.js +26 -122
  208. package/shared/definition53.cjs +110 -309
  209. package/shared/definition53.js +110 -308
  210. package/shared/definition54.cjs +255 -271
  211. package/shared/definition54.js +255 -271
  212. package/shared/definition55.cjs +315 -776
  213. package/shared/definition55.js +314 -775
  214. package/shared/definition56.cjs +818 -107
  215. package/shared/definition56.js +817 -106
  216. package/shared/definition57.cjs +85 -55
  217. package/shared/definition57.js +84 -54
  218. package/shared/definition58.cjs +125 -72
  219. package/shared/definition58.js +124 -71
  220. package/shared/definition59.cjs +72 -285
  221. package/shared/definition59.js +73 -286
  222. package/shared/definition6.cjs +1 -1
  223. package/shared/definition6.js +1 -1
  224. package/shared/definition60.cjs +298 -39
  225. package/shared/definition60.js +297 -38
  226. package/shared/definition61.cjs +66044 -1687
  227. package/shared/definition61.js +66043 -1686
  228. package/shared/definition62.cjs +50 -0
  229. package/shared/definition62.js +46 -0
  230. package/shared/definition63.cjs +1828 -0
  231. package/shared/definition63.js +1824 -0
  232. package/shared/definition7.cjs +2 -2
  233. package/shared/definition7.js +2 -2
  234. package/shared/definition8.cjs +2 -2
  235. package/shared/definition8.js +2 -2
  236. package/shared/definition9.cjs +1 -1
  237. package/shared/definition9.js +1 -1
  238. package/shared/enums.cjs +9 -0
  239. package/shared/enums.js +9 -1
  240. package/shared/icon.cjs +20 -2
  241. package/shared/icon.js +21 -3
  242. package/shared/index2.cjs +73 -37
  243. package/shared/index2.js +73 -37
  244. package/shared/key-codes2.js +1 -1
  245. package/shared/listbox.cjs +1 -1
  246. package/shared/listbox.js +1 -1
  247. package/shared/localization/Locale.d.ts +4 -0
  248. package/shared/patterns/form-elements/form-elements.d.ts +2 -3
  249. package/shared/presentationDate.cjs +16 -5
  250. package/shared/presentationDate.js +16 -5
  251. package/shared/text-anchor.cjs +6 -0
  252. package/shared/text-anchor.js +6 -0
  253. package/shared/text-anchor.template.cjs +6 -1
  254. package/shared/text-anchor.template.js +6 -1
  255. package/shared/text-field.cjs +1 -1
  256. package/shared/text-field.js +1 -1
  257. package/shared/utils/applyMixinsWithObservables.d.ts +1 -0
  258. package/shared/utils/numberConverter.d.ts +2 -0
  259. package/side-drawer/index.cjs +1 -1
  260. package/side-drawer/index.js +1 -1
  261. package/slider/index.cjs +1 -1
  262. package/slider/index.js +1 -1
  263. package/split-button/index.cjs +2 -2
  264. package/split-button/index.js +2 -2
  265. package/styles/core/all.css +1 -1
  266. package/styles/core/theme.css +1 -1
  267. package/styles/core/typography.css +1 -1
  268. package/styles/tokens/theme-dark.css +4 -4
  269. package/styles/tokens/theme-light.css +4 -4
  270. package/styles/tokens/vivid-2-compat.css +1 -1
  271. package/switch/index.cjs +2 -2
  272. package/switch/index.js +2 -2
  273. package/tab/index.cjs +2 -2
  274. package/tab/index.js +2 -2
  275. package/tab-panel/index.cjs +1 -1
  276. package/tab-panel/index.js +1 -1
  277. package/tabs/index.cjs +4 -4
  278. package/tabs/index.js +4 -4
  279. package/tag/index.cjs +2 -2
  280. package/tag/index.js +2 -2
  281. package/tag-group/index.cjs +1 -1
  282. package/tag-group/index.js +1 -1
  283. package/text-area/index.cjs +4 -3
  284. package/text-area/index.js +4 -3
  285. package/text-field/index.cjs +4 -3
  286. package/text-field/index.js +4 -3
  287. package/time-picker/index.cjs +8 -7
  288. package/time-picker/index.js +8 -7
  289. package/toggletip/index.cjs +5 -5
  290. package/toggletip/index.js +5 -5
  291. package/tooltip/index.cjs +5 -5
  292. package/tooltip/index.js +5 -5
  293. package/tree-item/index.cjs +2 -2
  294. package/tree-item/index.js +2 -2
  295. package/tree-view/index.cjs +1 -1
  296. package/tree-view/index.js +1 -1
  297. package/video-player/index.cjs +17 -0
  298. package/video-player/index.js +15 -0
  299. package/vivid.api.json +332 -0
@@ -1,10 +1,218 @@
1
- import { a as attr, F as FoundationElement, D as DOM, h as html, r as registerFactory } from './index.js';
2
- import { P as Popup, p as popupRegistries } from './definition61.js';
3
- import { b as anchored, a as anchorSlotTemplateFactory } from './anchored.js';
1
+ import { F as FoundationElement, a as attr, D as DOM, n as nullableNumberConverter, o as observable, h as html, r as registerFactory } from './index.js';
2
+ import { T as TextField, a as textFieldRegistries } from './definition55.js';
3
+ import { P as Popup, p as popupRegistries } from './definition63.js';
4
+ import { B as Button, a as buttonRegistries } from './definition11.js';
5
+ import './affix.js';
6
+ import { e as errorText, f as formElements, a as FormElementHelperText } from './index2.js';
7
+ import { L as Localized } from './localized.js';
8
+ import { T as TrappedFocus } from './trapped-focus.js';
9
+ import { a as applyMixinsWithObservables } from './applyMixinsWithObservables.js';
10
+ import { F as FormAssociated } from './form-associated.js';
11
+ import { r as ref } from './ref.js';
12
+ import { s as slotted } from './slotted.js';
4
13
  import { w as when } from './when.js';
14
+ import { r as repeat } from './repeat.js';
5
15
  import { c as classNames } from './class-names.js';
6
16
 
7
- const styles = ":host{display:var(--_popup-display, inline)}:host([slotted-anchor]){--_popup-display: contents}.content-wrapper{width:var(--toggletip-inline-size, auto);padding:16px}.headline{font:var(--vvd-typography-base-bold)}.action-items{display:flex;justify-content:flex-end;gap:10px}::slotted([slot=action-items]){margin-block-start:16px}\n";
17
+ const styles = ":host{display:inline-block}.base,.control{inline-size:100%}.dialog{display:inline-flex;flex-direction:column}.dialog .footer{display:flex;align-items:center;justify-content:flex-end;padding:8px;border-top:1px solid var(--vvd-color-neutral-200);gap:8px}.time-pickers{display:flex;overflow:hidden;padding:4px;block-size:188px;gap:4px}.time-pickers .picker{position:relative;display:flex;overflow:hidden;flex-direction:column;padding:0;border-radius:4px;margin:0;gap:4px;inline-size:50px;list-style:none;scrollbar-width:thin}.time-pickers .picker:hover{overflow-y:auto}.time-pickers .picker:after{display:block;flex-shrink:0;block-size:156px;content:\"\"}.time-pickers .picker:focus-visible{--focus-stroke-gap-color: transparent;--focus-inset: -2px;box-shadow:inset 0 0 0 3px var(--focus-stroke-gap-color, currentColor);outline:2px solid var(--focus-stroke-color, var(--vvd-color-canvas-text));outline-offset:calc(-2px - var(--focus-inset, 0px))}.time-pickers .item{display:flex;flex-shrink:0;align-items:center;justify-content:center;border-radius:4px;background-color:var(--_appearance-color-fill);block-size:28px;color:var(--_appearance-color-text);cursor:pointer;font:var(--vvd-typography-base);inline-size:50px}.time-pickers .item{--_connotation-color-primary: var(--vvd-time-picker-accent-primary, var(--vvd-color-canvas-text));--_connotation-color-firm: var(--vvd-time-picker-accent-firm, var(--vvd-color-canvas-text));--_connotation-color-faint: var(--vvd-time-picker-accent-faint, var(--vvd-color-neutral-50));--_connotation-color-soft: var(--vvd-time-picker-accent-soft, var(--vvd-color-neutral-100));--_connotation-color-dim: var(--vvd-time-picker-accent-dim, var(--vvd-color-neutral-200));--_connotation-color-pale: var(--vvd-time-picker-accent-pale, var(--vvd-color-neutral-300))}.time-pickers .item{--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: transparent;--_appearance-color-outline: transparent}.time-pickers .item:where(.hover,:hover):where(:not(.disabled,:disabled,.readonly)){--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: var(--_connotation-color-faint);--_appearance-color-outline: transparent}.time-pickers .item:where(.active,:active):where(:not(.disabled,:disabled)){--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: var(--_connotation-color-soft);--_appearance-color-outline: transparent}.time-pickers .item:where(.selected):where(:not(.disabled,:disabled)){--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: var(--_connotation-color-soft);--_appearance-color-outline: transparent}.time-pickers .item:where(.selected):where(.hover,:hover):where(:not(.disabled,:disabled,.readonly)){--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: var(--_connotation-color-dim);--_appearance-color-outline: transparent}.time-pickers .item:where(.selected):where(.disabled,:disabled){--_appearance-color-text: var(--vvd-color-neutral-300);--_appearance-color-fill: var(--vvd-color-neutral-200);--_appearance-color-outline: transparent}\n";
18
+
19
+ class _TimePicker extends FoundationElement {
20
+ }
21
+ class FormAssociatedTimePicker extends FormAssociated(_TimePicker) {
22
+ constructor() {
23
+ super(...arguments);
24
+ this.proxy = document.createElement("input");
25
+ }
26
+ }
27
+
28
+ const isValidTimeStr = (timeStr) => {
29
+ const parts = timeStr.split(":");
30
+ if (parts.length !== 3) {
31
+ return false;
32
+ }
33
+ const [hours, minutes, seconds] = parts;
34
+ if (hours.length !== 2 || minutes.length !== 2 || seconds.length !== 2) {
35
+ return false;
36
+ }
37
+ const hoursNum = parseInt(hours, 10);
38
+ const minutesNum = parseInt(minutes, 10);
39
+ const secondsNum = parseInt(seconds, 10);
40
+ if (isNaN(hoursNum) || isNaN(minutesNum) || isNaN(secondsNum)) {
41
+ return false;
42
+ }
43
+ if (hoursNum < 0 || hoursNum > 23) {
44
+ return false;
45
+ }
46
+ if (minutesNum < 0 || minutesNum > 59) {
47
+ return false;
48
+ }
49
+ if (secondsNum < 0 || secondsNum > 59) {
50
+ return false;
51
+ }
52
+ return true;
53
+ };
54
+ const parseTimePart = (partStr) => Number.parseInt(partStr, 10);
55
+ const formatTimePart = (part) => part.toString().padStart(2, "0");
56
+ const parseTimeStr = (timeStr) => {
57
+ const [hoursStr, minutesStr, secondsStr] = timeStr.split(":");
58
+ const hours = parseTimePart(hoursStr);
59
+ const minutes = parseTimePart(minutesStr);
60
+ const seconds = parseTimePart(secondsStr);
61
+ return {
62
+ hourStr: hoursStr,
63
+ hours,
64
+ minuteStr: minutesStr,
65
+ minutes,
66
+ secondStr: secondsStr,
67
+ seconds,
68
+ meridiem: hours < 12 ? "AM" : "PM"
69
+ };
70
+ };
71
+ const hoursAs12hClock = (hour) => hour % 12 || 12;
72
+
73
+ const formatPresentationTime = (timeStr, includeSeconds, use12HourClock) => {
74
+ const time = parseTimeStr(timeStr);
75
+ const hoursStr = formatTimePart(
76
+ use12HourClock ? hoursAs12hClock(time.hours) : time.hours
77
+ );
78
+ let result = `${hoursStr}:${time.minuteStr}`;
79
+ if (includeSeconds) {
80
+ result += `:${time.secondStr}`;
81
+ }
82
+ if (use12HourClock) {
83
+ result += ` ${time.meridiem}`;
84
+ }
85
+ return result;
86
+ };
87
+ const isDigit = (char) => char >= "0" && char <= "9";
88
+ const parsePresentationTime = (input, use12HourClock) => {
89
+ const cleanedInput = input.toLowerCase();
90
+ const numerals = [];
91
+ let meridiem;
92
+ for (let i = 0; i < cleanedInput.length; i++) {
93
+ const char = cleanedInput[i];
94
+ if (char === "a" && cleanedInput[i + 1] === "m") {
95
+ i++;
96
+ meridiem = "AM";
97
+ }
98
+ if (char === "p" && cleanedInput[i + 1] === "m") {
99
+ i++;
100
+ meridiem = "PM";
101
+ }
102
+ if (isDigit(char)) {
103
+ let numeral = char;
104
+ while (isDigit(cleanedInput[i + 1])) {
105
+ i++;
106
+ numeral += cleanedInput[i];
107
+ }
108
+ numerals.push(Number.parseInt(numeral, 10));
109
+ }
110
+ }
111
+ if (numerals.length === 0 || numerals.length > 3) {
112
+ throw new Error("Invalid time format");
113
+ }
114
+ if (meridiem && (numerals[0] < 1 || numerals[0] > 12)) {
115
+ throw new Error("Invalid time format");
116
+ }
117
+ if (meridiem || use12HourClock) {
118
+ if (numerals[0] === 12) {
119
+ numerals[0] = 0;
120
+ }
121
+ }
122
+ if (meridiem === "PM") {
123
+ numerals[0] = numerals[0] + 12;
124
+ }
125
+ const [hours, minutes = 0, seconds = 0] = numerals;
126
+ if (hours > 23 || minutes > 59 || seconds > 59) {
127
+ throw new Error("Invalid value");
128
+ }
129
+ return [hours, minutes, seconds].map(formatTimePart).join(":");
130
+ };
131
+
132
+ const fallsIntoMeridiem = (meridiem, hour) => meridiem === "AM" && hour < 12 || meridiem === "PM" && hour >= 12;
133
+ const getHoursOptions = (min, max, forMeridiem) => {
134
+ const result = [];
135
+ const minHour = min ? parseTimeStr(min).hours : 0;
136
+ const maxHour = max ? parseTimeStr(max).hours : 23;
137
+ for (let i = minHour; i <= maxHour; i++) {
138
+ if (forMeridiem && !fallsIntoMeridiem(forMeridiem, i)) {
139
+ continue;
140
+ }
141
+ result.push({
142
+ value: formatTimePart(i),
143
+ label: formatTimePart(forMeridiem ? hoursAs12hClock(i) : i)
144
+ });
145
+ }
146
+ return result;
147
+ };
148
+ const getMinutesOptions = (step, value, min, max) => {
149
+ const result = [];
150
+ let minMinute = 0;
151
+ let maxMinute = 59;
152
+ if (min) {
153
+ const { hourStr: minHourStr, minutes: minMinutes } = parseTimeStr(min);
154
+ if (value && parseTimeStr(value).hourStr === minHourStr) {
155
+ minMinute = minMinutes;
156
+ }
157
+ }
158
+ if (max) {
159
+ const { hourStr: maxHourStr, minutes: maxMinutes } = parseTimeStr(max);
160
+ if (value && parseTimeStr(value).hourStr === maxHourStr) {
161
+ maxMinute = maxMinutes;
162
+ }
163
+ }
164
+ for (let i = minMinute; i <= maxMinute; i += Math.max(1, step ?? 1)) {
165
+ const minutes = formatTimePart(i);
166
+ result.push({
167
+ value: minutes,
168
+ label: minutes
169
+ });
170
+ }
171
+ return result;
172
+ };
173
+ const getSecondsOptions = (step, value, min, max) => {
174
+ const result = [];
175
+ let minSecond = 0;
176
+ let maxSecond = 59;
177
+ if (min) {
178
+ const minTime = parseTimeStr(min);
179
+ if (value && (parseTimeStr(value).hourStr === minTime.hourStr && parseTimeStr(value).minuteStr) === minTime.minuteStr) {
180
+ minSecond = minTime.seconds;
181
+ }
182
+ }
183
+ if (max) {
184
+ const maxTime = parseTimeStr(max);
185
+ if (value && (parseTimeStr(value).hourStr === maxTime.hourStr && parseTimeStr(value).minuteStr) === maxTime.minuteStr) {
186
+ maxSecond = maxTime.seconds;
187
+ }
188
+ }
189
+ for (let i = minSecond; i <= maxSecond; i += Math.max(1, step)) {
190
+ const seconds = formatTimePart(i);
191
+ result.push({
192
+ value: seconds,
193
+ label: seconds
194
+ });
195
+ }
196
+ return result;
197
+ };
198
+ const getMeridiesOptions = (min, max) => {
199
+ const result = [];
200
+ const hideAM = min ? parseTimeStr(min).meridiem === "PM" : false;
201
+ if (!hideAM) {
202
+ result.push({
203
+ value: "AM",
204
+ label: "AM"
205
+ });
206
+ }
207
+ const hidePM = max ? parseTimeStr(max).meridiem === "AM" : false;
208
+ if (!hidePM) {
209
+ result.push({
210
+ value: "PM",
211
+ label: "PM"
212
+ });
213
+ }
214
+ return result;
215
+ };
8
216
 
9
217
  var __defProp = Object.defineProperty;
10
218
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -34,142 +242,645 @@ var __privateMethod = (obj, member, method) => {
34
242
  __accessCheck(obj, member, "access private method");
35
243
  return method;
36
244
  };
37
- var _ANCHOR_ARIA_LABEL_SUFFIX, _setupAnchor, setupAnchor_fn, _updateAnchor, updateAnchor_fn, _cleanupAnchor, cleanupAnchor_fn, _openIfClosed, _updateListeners, updateListeners_fn, _closeOnClickOutside, _closeOnEscape;
38
- let Toggletip = class extends FoundationElement {
245
+ var _getFocusableEls, _updateValueDueToUserInteraction, updateValueDueToUserInteraction_fn, _onFocusIn, _onFocusOut, _dismissOnClickOutside, _openPopupIfPossible, openPopupIfPossible_fn, _scrollToItem, scrollToItem_fn;
246
+ const ValidTimeFilter = {
247
+ fromView: (value) => {
248
+ if (value && isValidTimeStr(value)) {
249
+ return value;
250
+ }
251
+ return "";
252
+ },
253
+ toView(value) {
254
+ return value;
255
+ }
256
+ };
257
+ let TimePicker = class extends FormAssociatedTimePicker {
39
258
  constructor() {
40
- super(...arguments);
41
- __privateAdd(this, _setupAnchor);
42
- __privateAdd(this, _updateAnchor);
43
- __privateAdd(this, _cleanupAnchor);
44
- __privateAdd(this, _updateListeners);
45
- __privateAdd(this, _ANCHOR_ARIA_LABEL_SUFFIX, " ; Show more information");
46
- this.alternate = false;
47
- this.placement = "right";
48
- this.open = false;
49
- __privateAdd(this, _openIfClosed, () => {
50
- if (!this.open)
51
- DOM.queueUpdate(() => this.open = true);
259
+ super();
260
+ __privateAdd(this, _updateValueDueToUserInteraction);
261
+ __privateAdd(this, _openPopupIfPossible);
262
+ __privateAdd(this, _scrollToItem);
263
+ this.readOnly = false;
264
+ this.minutesStep = null;
265
+ this.secondsStep = null;
266
+ __privateAdd(this, _getFocusableEls, () => this.shadowRoot.querySelectorAll(`
267
+ .dialog [tabindex="0"],
268
+ .dialog .vwc-button:not(:disabled)
269
+ `));
270
+ __privateAdd(this, _onFocusIn, () => {
271
+ this.$emit("focus", void 0, { bubbles: false });
52
272
  });
53
- __privateAdd(this, _closeOnClickOutside, (e) => {
54
- const clickedOutside = !this.contains(e.target);
55
- const clickedOnAnchor = this._anchorEl?.contains(e.target);
56
- if (clickedOutside || clickedOnAnchor)
57
- this.open = false;
273
+ __privateAdd(this, _onFocusOut, () => {
274
+ this.$emit("blur", void 0, { bubbles: false });
58
275
  });
59
- __privateAdd(this, _closeOnEscape, (e) => {
60
- if (e.key === "Escape")
61
- this.open = false;
276
+ this._popupOpen = false;
277
+ __privateAdd(this, _dismissOnClickOutside, (event) => {
278
+ if (!this._popupOpen) {
279
+ return;
280
+ }
281
+ const path = event.composedPath();
282
+ const elementsToIgnoreClicksOn = [this._dialogEl, this._clockButtonEl];
283
+ if (!elementsToIgnoreClicksOn.some((element) => path.includes(element))) {
284
+ this._closePopup(false);
285
+ }
62
286
  });
287
+ this._presentationValue = "";
288
+ this.value = "";
289
+ this.min = "";
290
+ this.max = "";
291
+ this.proxy.type = "time";
292
+ this.proxy.step = "1";
63
293
  }
64
- openChanged(oldValue, newValue) {
65
- if (oldValue === void 0)
66
- return;
67
- if (newValue) {
68
- this.setAttribute("role", "status");
69
- } else {
70
- this.removeAttribute("role");
294
+ /**
295
+ * @internal
296
+ */
297
+ readOnlyChanged() {
298
+ if (this.proxy instanceof HTMLInputElement) {
299
+ this.proxy.readOnly = this.readOnly;
300
+ this.validate();
301
+ }
302
+ }
303
+ /**
304
+ * @internal
305
+ */
306
+ minChanged(_, newMin) {
307
+ if (this.proxy instanceof HTMLInputElement) {
308
+ this.proxy.min = newMin;
309
+ this.validate();
310
+ }
311
+ }
312
+ /**
313
+ * @internal
314
+ */
315
+ maxChanged(_, newMax) {
316
+ if (this.proxy instanceof HTMLInputElement) {
317
+ this.proxy.max = newMax;
318
+ this.validate();
71
319
  }
72
- __privateMethod(this, _updateListeners, updateListeners_fn).call(this);
73
- if (this._anchorEl) {
74
- __privateMethod(this, _updateAnchor, updateAnchor_fn).call(this, this._anchorEl);
320
+ }
321
+ // --- Core ---
322
+ /**
323
+ * @internal
324
+ */
325
+ get _displaySeconds() {
326
+ return this.secondsStep !== null;
327
+ }
328
+ /**
329
+ * @internal
330
+ */
331
+ get _use12hClock() {
332
+ return this.clock ? this.clock === "12h" : this.locale.timePicker.defaultTo12HourClock;
333
+ }
334
+ /**
335
+ * @internal
336
+ */
337
+ valueChanged(previous, next) {
338
+ super.valueChanged(previous, next);
339
+ if (this.value) {
340
+ if (!isValidTimeStr(this.value)) {
341
+ this.value = "";
342
+ return;
343
+ }
344
+ this._presentationValue = formatPresentationTime(
345
+ this.value,
346
+ this._displaySeconds,
347
+ this._use12hClock
348
+ );
349
+ } else {
350
+ this._presentationValue = "";
75
351
  }
76
352
  }
77
353
  connectedCallback() {
78
354
  super.connectedCallback();
79
- __privateMethod(this, _updateListeners, updateListeners_fn).call(this);
355
+ document.addEventListener("click", __privateGet(this, _dismissOnClickOutside));
356
+ this.addEventListener("focusin", __privateGet(this, _onFocusIn));
357
+ this.addEventListener("focusout", __privateGet(this, _onFocusOut));
80
358
  }
81
359
  disconnectedCallback() {
82
360
  super.disconnectedCallback();
83
- __privateMethod(this, _updateListeners, updateListeners_fn).call(this);
361
+ document.removeEventListener("click", __privateGet(this, _dismissOnClickOutside));
362
+ this.removeEventListener("focusin", __privateGet(this, _onFocusIn));
363
+ this.removeEventListener("focusout", __privateGet(this, _onFocusOut));
84
364
  }
85
365
  /**
86
366
  * @internal
87
367
  */
88
- _anchorElChanged(oldValue, newValue) {
89
- if (oldValue)
90
- __privateMethod(this, _cleanupAnchor, cleanupAnchor_fn).call(this, oldValue);
91
- if (newValue)
92
- __privateMethod(this, _setupAnchor, setupAnchor_fn).call(this, newValue);
368
+ _closePopup(restoreFocusToTextField = true) {
369
+ this._popupOpen = false;
370
+ if (restoreFocusToTextField) {
371
+ this._textFieldEl.focus();
372
+ }
373
+ }
374
+ /**
375
+ * On keydown anywhere in the time picker.
376
+ * @internal
377
+ */
378
+ _onBaseKeyDown(event) {
379
+ if (event.key === "Escape") {
380
+ this._closePopup();
381
+ return false;
382
+ }
383
+ if (this._trappedFocus(event, __privateGet(this, _getFocusableEls))) {
384
+ return false;
385
+ }
386
+ return true;
387
+ }
388
+ /**
389
+ * @internal
390
+ */
391
+ _presentationValueChanged() {
392
+ this.dirtyValue = true;
393
+ this.validate();
394
+ }
395
+ /**
396
+ * @internal
397
+ */
398
+ get _textFieldPlaceholder() {
399
+ let format = "hh:mm";
400
+ if (this._displaySeconds) {
401
+ format += ":ss";
402
+ }
403
+ if (this._use12hClock) {
404
+ format += " aa";
405
+ }
406
+ return format;
407
+ }
408
+ /**
409
+ * @internal
410
+ */
411
+ _onTextFieldInput(event) {
412
+ const textField = event.currentTarget;
413
+ this._presentationValue = textField.value;
414
+ }
415
+ /**
416
+ * @internal
417
+ */
418
+ _onTextFieldChange() {
419
+ if (this._presentationValue === "") {
420
+ __privateMethod(this, _updateValueDueToUserInteraction, updateValueDueToUserInteraction_fn).call(this, "");
421
+ return;
422
+ }
423
+ try {
424
+ __privateMethod(this, _updateValueDueToUserInteraction, updateValueDueToUserInteraction_fn).call(this, parsePresentationTime(this._presentationValue, this._use12hClock));
425
+ } catch (_) {
426
+ return;
427
+ }
428
+ }
429
+ // --- Clock button ---
430
+ /**
431
+ * @internal
432
+ */
433
+ get _clockButtonLabel() {
434
+ if (this.value) {
435
+ return this.locale.timePicker.changeTimeLabel(
436
+ formatPresentationTime(
437
+ this.value,
438
+ this._displaySeconds,
439
+ this._use12hClock
440
+ )
441
+ );
442
+ }
443
+ return this.locale.timePicker.chooseTimeLabel;
444
+ }
445
+ /**
446
+ * @internal
447
+ */
448
+ _onClockButtonClick() {
449
+ if (this._popupOpen) {
450
+ this._closePopup();
451
+ } else {
452
+ __privateMethod(this, _openPopupIfPossible, openPopupIfPossible_fn).call(this);
453
+ DOM.processUpdates();
454
+ if (this._selectedHour) {
455
+ __privateMethod(this, _scrollToItem, scrollToItem_fn).call(this, "hours", this._selectedHour, "start");
456
+ }
457
+ if (this._selectedMinute) {
458
+ __privateMethod(this, _scrollToItem, scrollToItem_fn).call(this, "minutes", this._selectedMinute, "start");
459
+ }
460
+ if (this._displaySeconds && this._selectedSecond) {
461
+ __privateMethod(this, _scrollToItem, scrollToItem_fn).call(this, "seconds", this._selectedSecond, "start");
462
+ }
463
+ if (this._use12hClock && this._selectedMeridiem) {
464
+ __privateMethod(this, _scrollToItem, scrollToItem_fn).call(this, "meridies", this._selectedMeridiem, "start");
465
+ }
466
+ __privateGet(this, _getFocusableEls).call(this)[0].focus();
467
+ }
468
+ }
469
+ // --- Pickers ---
470
+ /**
471
+ * @internal
472
+ */
473
+ get _hours() {
474
+ return getHoursOptions(
475
+ this.min,
476
+ this.max,
477
+ this._use12hClock ? this._selectedMeridiem ?? this._meridies[0].value : void 0
478
+ );
479
+ }
480
+ /**
481
+ * @internal
482
+ */
483
+ get _selectedHour() {
484
+ return this.value ? parseTimeStr(this.value).hourStr : void 0;
485
+ }
486
+ /**
487
+ * @internal
488
+ */
489
+ set _selectedHour(value) {
490
+ if (this.value) {
491
+ const { minuteStr, secondStr } = parseTimeStr(this.value);
492
+ this.value = `${value}:${minuteStr}:${secondStr}`;
493
+ } else {
494
+ this.value = `${value}:00:00`;
495
+ }
496
+ }
497
+ /**
498
+ * @internal
499
+ */
500
+ get _minutes() {
501
+ return getMinutesOptions(this.minutesStep, this.value, this.min, this.max);
502
+ }
503
+ /**
504
+ * @internal
505
+ */
506
+ get _selectedMinute() {
507
+ return this.value ? parseTimeStr(this.value).minuteStr : void 0;
508
+ }
509
+ /**
510
+ * @internal
511
+ */
512
+ set _selectedMinute(value) {
513
+ if (this.value) {
514
+ const { hourStr, secondStr } = parseTimeStr(this.value);
515
+ this.value = `${hourStr}:${value}:${secondStr}`;
516
+ } else {
517
+ this.value = `00:${value}:00`;
518
+ }
519
+ }
520
+ /**
521
+ * @internal
522
+ */
523
+ get _seconds() {
524
+ return getSecondsOptions(this.secondsStep, this.value, this.min, this.max);
525
+ }
526
+ /**
527
+ * @internal
528
+ */
529
+ get _selectedSecond() {
530
+ return this.value ? parseTimeStr(this.value).secondStr : void 0;
531
+ }
532
+ /**
533
+ * @internal
534
+ */
535
+ set _selectedSecond(value) {
536
+ if (this.value) {
537
+ const { hourStr, minuteStr } = parseTimeStr(this.value);
538
+ this.value = `${hourStr}:${minuteStr}:${value}`;
539
+ } else {
540
+ this.value = `00:00:${value}`;
541
+ }
542
+ }
543
+ /**
544
+ * @internal
545
+ */
546
+ get _meridies() {
547
+ return getMeridiesOptions(this.min, this.max);
548
+ }
549
+ /**
550
+ * @internal
551
+ */
552
+ get _selectedMeridiem() {
553
+ return this.value ? parseTimeStr(this.value).meridiem : void 0;
554
+ }
555
+ /**
556
+ * @internal
557
+ */
558
+ set _selectedMeridiem(value) {
559
+ if (this.value) {
560
+ const { hours, minuteStr, secondStr } = parseTimeStr(this.value);
561
+ let adjustedHours = hours;
562
+ if (value === "AM" && hours >= 12) {
563
+ adjustedHours -= 12;
564
+ } else if (value === "PM" && hours < 12) {
565
+ adjustedHours += 12;
566
+ }
567
+ this.value = `${formatTimePart(adjustedHours)}:${minuteStr}:${secondStr}`;
568
+ } else {
569
+ if (value === "AM") {
570
+ this.value = "00:00:00";
571
+ } else {
572
+ this.value = "12:00:00";
573
+ }
574
+ }
575
+ }
576
+ /**
577
+ * @internal
578
+ */
579
+ _onPickerKeyDown(picker, options, selectedValue, setSelectedValue, event) {
580
+ const offset = {
581
+ ArrowUp: -1,
582
+ ArrowDown: 1
583
+ }[event.key];
584
+ if (offset) {
585
+ event.preventDefault();
586
+ const index = options.findIndex((h) => h.value === selectedValue);
587
+ const newRawIndex = index === -1 ? 0 : index + offset;
588
+ const newIndex = (newRawIndex + options.length) % options.length;
589
+ const newValue = options[newIndex].value;
590
+ setSelectedValue(newValue);
591
+ __privateMethod(this, _scrollToItem, scrollToItem_fn).call(this, picker, newValue, "nearest");
592
+ __privateMethod(this, _updateValueDueToUserInteraction, updateValueDueToUserInteraction_fn).call(this, this.value);
593
+ }
594
+ return true;
595
+ }
596
+ /**
597
+ * @internal
598
+ */
599
+ _onPickerItemClick(picker, setSelectedValue, value) {
600
+ setSelectedValue(value);
601
+ __privateMethod(this, _scrollToItem, scrollToItem_fn).call(this, picker, value, "start");
602
+ __privateMethod(this, _updateValueDueToUserInteraction, updateValueDueToUserInteraction_fn).call(this, this.value);
603
+ const nextPickerEl = this.shadowRoot.querySelector(
604
+ `#${picker} + .picker`
605
+ );
606
+ if (nextPickerEl) {
607
+ nextPickerEl.focus();
608
+ } else {
609
+ this._closePopup();
610
+ }
611
+ }
612
+ // --- Dialog footer ---
613
+ /**
614
+ * @internal
615
+ */
616
+ _onOkClick() {
617
+ this._closePopup();
618
+ }
619
+ /**
620
+ * @internal
621
+ */
622
+ _onClearClick() {
623
+ __privateMethod(this, _updateValueDueToUserInteraction, updateValueDueToUserInteraction_fn).call(this, "");
624
+ this._closePopup();
625
+ }
626
+ // --- Validation ---
627
+ /**
628
+ * @internal
629
+ */
630
+ validate() {
631
+ if (this.proxy) {
632
+ this.proxy.setCustomValidity(this._getCustomValidationError() ?? "");
633
+ }
634
+ super.validate(this._textFieldEl?.querySelector("input") ?? void 0);
635
+ }
636
+ /**
637
+ * @internal
638
+ */
639
+ _getCustomValidationError() {
640
+ if (this._isPresentationValueInvalid()) {
641
+ return this.locale.timePicker.invalidTimeError;
642
+ }
643
+ return null;
644
+ }
645
+ /**
646
+ * @internal
647
+ */
648
+ _isPresentationValueInvalid() {
649
+ if (this._presentationValue === "") {
650
+ return false;
651
+ }
652
+ try {
653
+ parsePresentationTime(this._presentationValue, this._use12hClock);
654
+ return false;
655
+ } catch (_) {
656
+ return true;
657
+ }
93
658
  }
94
659
  };
95
- _ANCHOR_ARIA_LABEL_SUFFIX = new WeakMap();
96
- _setupAnchor = new WeakSet();
97
- setupAnchor_fn = function(a) {
98
- a.addEventListener("click", __privateGet(this, _openIfClosed), true);
99
- a.ariaLabel = (a.ariaLabel ?? "") + __privateGet(this, _ANCHOR_ARIA_LABEL_SUFFIX);
100
- __privateMethod(this, _updateAnchor, updateAnchor_fn).call(this, a);
101
- };
102
- _updateAnchor = new WeakSet();
103
- updateAnchor_fn = function(a) {
104
- a.setAttribute("aria-expanded", this.open.toString());
660
+ _getFocusableEls = new WeakMap();
661
+ _updateValueDueToUserInteraction = new WeakSet();
662
+ updateValueDueToUserInteraction_fn = function(newValue) {
663
+ this.value = newValue;
664
+ this.$emit("change");
665
+ this.$emit("input");
105
666
  };
106
- _cleanupAnchor = new WeakSet();
107
- cleanupAnchor_fn = function(a) {
108
- a.removeEventListener("click", __privateGet(this, _openIfClosed), true);
109
- if (a.ariaLabel)
110
- a.ariaLabel = a.ariaLabel.replace(__privateGet(this, _ANCHOR_ARIA_LABEL_SUFFIX), "");
667
+ _onFocusIn = new WeakMap();
668
+ _onFocusOut = new WeakMap();
669
+ _dismissOnClickOutside = new WeakMap();
670
+ _openPopupIfPossible = new WeakSet();
671
+ openPopupIfPossible_fn = function() {
672
+ if (!this.readOnly) {
673
+ this._popupOpen = true;
674
+ }
111
675
  };
112
- _openIfClosed = new WeakMap();
113
- _updateListeners = new WeakSet();
114
- updateListeners_fn = function() {
115
- document.removeEventListener("click", __privateGet(this, _closeOnClickOutside));
116
- document.removeEventListener("keydown", __privateGet(this, _closeOnEscape));
117
- if (this.open && this.isConnected) {
118
- document.addEventListener("click", __privateGet(this, _closeOnClickOutside));
119
- document.addEventListener("keydown", __privateGet(this, _closeOnEscape));
676
+ _scrollToItem = new WeakSet();
677
+ scrollToItem_fn = function(picker, selectedValue, position) {
678
+ const element = this.shadowRoot.querySelector(
679
+ `#${picker}-${selectedValue}`
680
+ );
681
+ if (!element) {
682
+ return;
683
+ }
684
+ const parent = element.parentElement;
685
+ switch (position) {
686
+ case "start":
687
+ parent.scrollTop = element.offsetTop;
688
+ break;
689
+ case "nearest":
690
+ if (element.offsetTop < parent.scrollTop) {
691
+ parent.scrollTop = element.offsetTop;
692
+ }
693
+ if (element.offsetTop + element.offsetHeight > parent.scrollTop + parent.offsetHeight) {
694
+ parent.scrollTop = element.offsetTop + element.offsetHeight - parent.offsetHeight;
695
+ }
696
+ break;
120
697
  }
121
698
  };
122
- _closeOnClickOutside = new WeakMap();
123
- _closeOnEscape = new WeakMap();
699
+ __decorateClass([
700
+ attr({ attribute: "readonly", mode: "boolean" })
701
+ ], TimePicker.prototype, "readOnly", 2);
702
+ __decorateClass([
703
+ attr({ attribute: "minutes-step", converter: nullableNumberConverter })
704
+ ], TimePicker.prototype, "minutesStep", 2);
705
+ __decorateClass([
706
+ attr({ attribute: "seconds-step", converter: nullableNumberConverter })
707
+ ], TimePicker.prototype, "secondsStep", 2);
124
708
  __decorateClass([
125
709
  attr
126
- ], Toggletip.prototype, "headline", 2);
710
+ ], TimePicker.prototype, "clock", 2);
127
711
  __decorateClass([
128
- attr({ mode: "boolean" })
129
- ], Toggletip.prototype, "alternate", 2);
712
+ attr({ converter: ValidTimeFilter })
713
+ ], TimePicker.prototype, "min", 2);
130
714
  __decorateClass([
131
- attr({ mode: "fromView" })
132
- ], Toggletip.prototype, "placement", 2);
715
+ attr({ converter: ValidTimeFilter })
716
+ ], TimePicker.prototype, "max", 2);
133
717
  __decorateClass([
134
- attr({ mode: "boolean" })
135
- ], Toggletip.prototype, "open", 2);
136
- Toggletip = __decorateClass([
137
- anchored
138
- ], Toggletip);
718
+ observable
719
+ ], TimePicker.prototype, "_popupOpen", 2);
720
+ __decorateClass([
721
+ observable
722
+ ], TimePicker.prototype, "_presentationValue", 2);
723
+ TimePicker = __decorateClass([
724
+ errorText,
725
+ formElements
726
+ ], TimePicker);
727
+ applyMixinsWithObservables(
728
+ TimePicker,
729
+ Localized,
730
+ FormElementHelperText,
731
+ TrappedFocus
732
+ );
139
733
 
140
- const getClasses = (_) => classNames("control");
141
- const ToggletipTemplate = (context) => {
142
- const popup = context.tagFor(Popup);
143
- const anchorSlotTemplate = anchorSlotTemplateFactory();
734
+ const renderPicker = (id, getLabel, getSelected, setSelected, getOptions) => {
144
735
  return html`
145
- ${anchorSlotTemplate}
146
- <${popup}
147
- class="${getClasses}"
148
- arrow
149
- :anchor="${(x) => x._anchorEl}"
150
- :open="${(x) => x.open}"
151
- ?alternate="${(x) => !x.alternate}"
152
- placement="${(x) => x.placement}"
153
- exportparts="vvd-theme-alternate"
736
+ <ul
737
+ id="${id}"
738
+ class="picker"
739
+ role="listbox"
740
+ tabindex="0"
741
+ aria-label="${getLabel}"
742
+ aria-activedescendant="${(x) => getSelected(x) ? `${id}-${getSelected(x)}` : void 0}"
743
+ @keydown="${(x, c) => x._onPickerKeyDown(
744
+ id,
745
+ getOptions(x),
746
+ getSelected(x),
747
+ setSelected(x),
748
+ c.event
749
+ )}"
154
750
  >
155
- <div class="content-wrapper">
156
- ${when(
157
- (x) => x.headline,
158
- html`<header class="headline">${(x) => x.headline}</header>`
751
+ ${repeat(
752
+ getOptions,
753
+ html`
754
+ <li
755
+ id="${(x) => `${id}-${x.value}`}"
756
+ class="${(x, c) => classNames("item", [
757
+ "selected",
758
+ getSelected(c.parent) === x.value
759
+ ])}"
760
+ role="option"
761
+ aria-selected="${(x, c) => getSelected(c.parent) === x.value}"
762
+ @click="${(x, c) => c.parent._onPickerItemClick(id, setSelected(c.parent), x.value)}"
763
+ >
764
+ ${(x) => x.label}
765
+ </li>
766
+ `
159
767
  )}
160
- <slot></slot>
161
- <footer class="action-items"><slot name="action-items"></slot></footer>
162
- </div>
163
- </${popup}>
768
+ </ul>
164
769
  `;
165
770
  };
771
+ const TimePickerTemplate = (context, _) => {
772
+ const popupTag = context.tagFor(Popup);
773
+ const textFieldTag = context.tagFor(TextField);
774
+ const buttonTag = context.tagFor(Button);
775
+ return html`<div class="base" @keydown="${(x, { event }) => x._onBaseKeyDown(event)}">
776
+ <${textFieldTag} id="text-field"
777
+ ${ref("_textFieldEl")}
778
+ class="control"
779
+ label="${(x) => x.label}"
780
+ helper-text="${(x) => x.helperText}"
781
+ error-text="${(x) => x.errorValidationMessage}"
782
+ placeholder="${(x) => x._textFieldPlaceholder}"
783
+ current-value="${(x) => x._presentationValue}"
784
+ ?disabled="${(x) => x.disabled}"
785
+ ?readonly="${(x) => x.readOnly}"
786
+ @input="${(x, c) => x._onTextFieldInput(c.event)}"
787
+ @change="${(x) => x._onTextFieldChange()}"
788
+ >
789
+ <slot
790
+ slot="${(x) => x._helperTextSlottedContent?.length ? "helper-text" : void 0}"
791
+ name="helper-text"
792
+ ${slotted("_helperTextSlottedContent")}
793
+ ></slot>
794
+ <${buttonTag}
795
+ id="clock-button"
796
+ ${ref("_clockButtonEl")}
797
+ slot="action-items"
798
+ size="condensed"
799
+ icon="clock-line"
800
+ appearance="ghost"
801
+ ?disabled="${(x) => x.disabled || x.readOnly}"
802
+ aria-label="${(x) => x._clockButtonLabel}"
803
+ @click="${(x) => x._onClockButtonClick()}"
804
+ ></${buttonTag}>
805
+ </${textFieldTag}>
806
+ <${popupTag}
807
+ ?open="${(x) => x._popupOpen}"
808
+ :anchor="${(x) => x._textFieldEl}"
809
+ placement="bottom-start"
810
+ class="popup">
811
+ <div class="dialog" role="dialog" ${ref(
812
+ "_dialogEl"
813
+ )} aria-modal="true" aria-label="${(x) => x.locale.timePicker.chooseTimeLabel}">
814
+ <div class="time-pickers">
815
+ ${renderPicker(
816
+ "hours",
817
+ (x) => x.locale.timePicker.hoursLabel,
818
+ (x) => x._selectedHour,
819
+ (x) => (v) => x._selectedHour = v,
820
+ (x) => x._hours
821
+ )}
822
+ ${renderPicker(
823
+ "minutes",
824
+ (x) => x.locale.timePicker.minutesLabel,
825
+ (x) => x._selectedMinute,
826
+ (x) => (v) => x._selectedMinute = v,
827
+ (x) => x._minutes
828
+ )}
829
+ ${when(
830
+ (x) => x._displaySeconds,
831
+ renderPicker(
832
+ "seconds",
833
+ (x) => x.locale.timePicker.secondsLabel,
834
+ (x) => x._selectedSecond,
835
+ (x) => (v) => x._selectedSecond = v,
836
+ (x) => x._seconds
837
+ )
838
+ )}
839
+ ${when(
840
+ (x) => x._use12hClock,
841
+ renderPicker(
842
+ "meridies",
843
+ (x) => x.locale.timePicker.meridiesLabel,
844
+ (x) => x._selectedMeridiem,
845
+ (x) => (v) => x._selectedMeridiem = v,
846
+ (x) => x._meridies
847
+ )
848
+ )}
849
+ </div>
850
+ <div class="footer">
851
+ <${buttonTag}
852
+ class="vwc-button"
853
+ size="condensed"
854
+ label="${(x) => x.locale.timePicker.clearLabel}"
855
+ @click="${(x) => x._onClearClick()}"
856
+ ></${buttonTag}>
857
+ <${buttonTag}
858
+ class="vwc-button"
859
+ size="condensed"
860
+ appearance="filled"
861
+ label="${(x) => x.locale.timePicker.okLabel}"
862
+ @click="${(x) => x._onOkClick()}"
863
+ ></${buttonTag}>
864
+ </div>
865
+ </div>
866
+ </${popupTag}>
867
+ </div>`;
868
+ };
166
869
 
167
- const toggletipDefinition = Toggletip.compose({
168
- baseName: "toggletip",
169
- template: ToggletipTemplate,
170
- styles
870
+ const timePickerDefinition = TimePicker.compose({
871
+ baseName: "time-picker",
872
+ template: TimePickerTemplate,
873
+ styles,
874
+ shadowOptions: {
875
+ delegatesFocus: true
876
+ }
171
877
  });
172
- const toggletipRegistries = [toggletipDefinition(), ...popupRegistries];
173
- const registerToggletip = registerFactory(toggletipRegistries);
878
+ const timePickerRegistries = [
879
+ timePickerDefinition(),
880
+ ...textFieldRegistries,
881
+ ...popupRegistries,
882
+ ...buttonRegistries
883
+ ];
884
+ const registerTimePicker = registerFactory(timePickerRegistries);
174
885
 
175
- export { toggletipRegistries as a, registerToggletip as r, toggletipDefinition as t };
886
+ export { timePickerRegistries as a, registerTimePicker as r, timePickerDefinition as t };