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